From 1c61f50ca906af5da88061e7acdd12e1c7377b43 Mon Sep 17 00:00:00 2001 From: Jelle Foks Date: Thu, 31 Oct 2024 20:20:16 -0700 Subject: [PATCH 1/7] ApproximateNow --- net/quic/platform/impl/quic_chromium_clock.cc | 18 +++++++++++++++++- net/quic/platform/impl/quic_chromium_clock.h | 2 ++ net/quic/quic_chromium_packet_reader.cc | 8 ++++++-- .../src/quiche/quic/core/quic_connection.cc | 14 ++++++++++++++ 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/net/quic/platform/impl/quic_chromium_clock.cc b/net/quic/platform/impl/quic_chromium_clock.cc index 1379171fc8a1..11f5b421e01d 100644 --- a/net/quic/platform/impl/quic_chromium_clock.cc +++ b/net/quic/platform/impl/quic_chromium_clock.cc @@ -10,6 +10,11 @@ namespace quic { +namespace { +QuicTime approximate_now_{QuicTime::Zero()}; +int approximate_now_usage_counter_{0}; +} // namespace + QuicChromiumClock* QuicChromiumClock::GetInstance() { static base::NoDestructor instance; return instance.get(); @@ -19,16 +24,27 @@ QuicChromiumClock::QuicChromiumClock() = default; QuicChromiumClock::~QuicChromiumClock() = default; +void QuicChromiumClock::ZeroApproximateNow() { + approximate_now_ = QuicTime::Zero(); + approximate_now_usage_counter_ = 0; +}; + QuicTime QuicChromiumClock::ApproximateNow() const { // At the moment, Chrome does not have a distinct notion of ApproximateNow(). // We should consider implementing this using MessageLoop::recent_time_. + if (approximate_now_.IsInitialized() && + ++approximate_now_usage_counter_ < 16) { + return approximate_now_; + } return Now(); } QuicTime QuicChromiumClock::Now() const { int64_t ticks = (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds(); DCHECK_GE(ticks, 0); - return CreateTimeFromMicroseconds(ticks); + approximate_now_ = CreateTimeFromMicroseconds(ticks); + approximate_now_usage_counter_ = 0; + return approximate_now_; } QuicWallTime QuicChromiumClock::WallNow() const { diff --git a/net/quic/platform/impl/quic_chromium_clock.h b/net/quic/platform/impl/quic_chromium_clock.h index cc6d124635bb..773f06281445 100644 --- a/net/quic/platform/impl/quic_chromium_clock.h +++ b/net/quic/platform/impl/quic_chromium_clock.h @@ -24,6 +24,8 @@ class NET_EXPORT_PRIVATE QuicChromiumClock : public QuicClock { ~QuicChromiumClock() override; + void ZeroApproximateNow(); + // QuicClock implementation: QuicTime ApproximateNow() const override; QuicTime Now() const override; diff --git a/net/quic/quic_chromium_packet_reader.cc b/net/quic/quic_chromium_packet_reader.cc index bf70f51749c2..7884f3e20a82 100644 --- a/net/quic/quic_chromium_packet_reader.cc +++ b/net/quic/quic_chromium_packet_reader.cc @@ -10,6 +10,7 @@ #include "base/task/single_thread_task_runner.h" #include "net/base/net_errors.h" #include "net/quic/address_utils.h" +#include "net/quic/platform/impl/quic_chromium_clock.h" #include "net/third_party/quiche/src/quiche/quic/core/quic_clock.h" namespace net { @@ -92,6 +93,7 @@ int QuicChromiumPacketReader::StartReadingMultiplePackets() { } bool QuicChromiumPacketReader::ProcessMultiplePacketReadResult(int result) { + quic::QuicChromiumClock::GetInstance()->ZeroApproximateNow(); read_pending_ = false; if (result <= 0 && net_log_.IsCapturing()) { net_log_.AddEventWithIntParams(NetLogEventType::QUIC_READ_ERROR, @@ -129,7 +131,7 @@ bool QuicChromiumPacketReader::ProcessMultiplePacketReadResult(int result) { continue; } quic::QuicReceivedPacket packet(read_packet->buffer, read_packet->result, - clock_->Now()); + clock_->ApproximateNow()); if (!(visitor_->OnPacket(packet, quick_local_address, quick_peer_address) && self)) { return false; @@ -202,6 +204,7 @@ void QuicChromiumPacketReader::StartReading() { } bool QuicChromiumPacketReader::ProcessReadResult(int result) { + quic::QuicChromiumClock::GetInstance()->ZeroApproximateNow(); read_pending_ = false; if (result <= 0 && net_log_.IsCapturing()) { net_log_.AddEventWithIntParams(NetLogEventType::QUIC_READ_ERROR, @@ -221,7 +224,8 @@ bool QuicChromiumPacketReader::ProcessReadResult(int result) { return visitor_->OnReadError(result, socket_); } - quic::QuicReceivedPacket packet(read_buffer_->data(), result, clock_->Now()); + quic::QuicReceivedPacket packet(read_buffer_->data(), result, + clock_->ApproximateNow()); IPEndPoint local_address; IPEndPoint peer_address; socket_->GetLocalAddress(&local_address); diff --git a/net/third_party/quiche/src/quiche/quic/core/quic_connection.cc b/net/third_party/quiche/src/quiche/quic/core/quic_connection.cc index 6aa3e47ac853..321ee7873f5e 100644 --- a/net/third_party/quiche/src/quiche/quic/core/quic_connection.cc +++ b/net/third_party/quiche/src/quiche/quic/core/quic_connection.cc @@ -3304,7 +3304,14 @@ bool QuicConnection::CanWrite(HasRetransmittableData retransmittable) { return false; } +#if defined(STARBOARD) + // Not reading the precise clock is a significant CPU usage reduction. + // Either this clock is accurate enough, or we are already throttling by more + // than the difference due to the reading task taking a long time. + QuicTime now = clock_->ApproximateNow(); +#else QuicTime now = clock_->Now(); +#endif QuicTime::Delta delay = sent_packet_manager_.TimeUntilSend(now); if (delay.IsInfinite()) { send_alarm_->Cancel(); @@ -3327,7 +3334,14 @@ bool QuicConnection::CanWrite(HasRetransmittableData retransmittable) { } QuicTime QuicConnection::CalculatePacketSentTime() { +#if defined(STARBOARD) + // Not reading the precise clock is a significant CPU usage reduction. + // Either this clock is accurate enough, or we are already throttling by more + // than the difference due to the reading task taking a long time. + const QuicTime now = clock_->ApproximateNow(); +#else const QuicTime now = clock_->Now(); +#endif if (!supports_release_time_ || per_packet_options_ == nullptr) { // Don't change the release delay. return now; From 3fbb649eba78f697ae3d01f26ac7cb00732c5ae9 Mon Sep 17 00:00:00 2001 From: Jelle Foks Date: Tue, 5 Nov 2024 11:24:28 -0800 Subject: [PATCH 2/7] Small improvement for PostTaskAndReply --- base/task/sequenced_task_runner.cc | 9 +++++++++ base/task/sequenced_task_runner.h | 4 ++++ base/threading/post_task_and_reply_impl.cc | 15 +++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/base/task/sequenced_task_runner.cc b/base/task/sequenced_task_runner.cc index eeaccb81077c..1e9d1e4725de 100644 --- a/base/task/sequenced_task_runner.cc +++ b/base/task/sequenced_task_runner.cc @@ -104,11 +104,20 @@ bool SequencedTaskRunner::PostDelayedTaskAt( : delayed_run_time - TimeTicks::Now()); } +#if defined(STARBOARD) +// static +scoped_refptr* + SequencedTaskRunner::null_sequenced_task_runner_( + new scoped_refptr); +#endif + // static const scoped_refptr& SequencedTaskRunner::GetCurrentDefault() { #if defined(STARBOARD) auto current_default_handle = GetCurrentDefaultHandle(); + return (!current_default_handle ? *null_sequenced_task_runner_ + : current_default_handle->task_runner_); #endif CHECK(current_default_handle) << "Error: This caller requires a sequenced context (i.e. the current " diff --git a/base/task/sequenced_task_runner.h b/base/task/sequenced_task_runner.h index 660db0c1bc10..6563505420d5 100644 --- a/base/task/sequenced_task_runner.h +++ b/base/task/sequenced_task_runner.h @@ -336,6 +336,10 @@ class BASE_EXPORT SequencedTaskRunner : public TaskRunner { virtual bool DeleteOrReleaseSoonInternal(const Location& from_here, void (*deleter)(const void*), const void* object); + +#if defined(STARBOARD) + static scoped_refptr* null_sequenced_task_runner_; +#endif }; // Sample usage with std::unique_ptr : diff --git a/base/threading/post_task_and_reply_impl.cc b/base/threading/post_task_and_reply_impl.cc index fb72de394510..bf6f1c6de48d 100644 --- a/base/threading/post_task_and_reply_impl.cc +++ b/base/threading/post_task_and_reply_impl.cc @@ -141,6 +141,20 @@ bool PostTaskAndReplyImpl::PostTaskAndReply(const Location& from_here, DCHECK(task) << from_here.ToString(); DCHECK(reply) << from_here.ToString(); +#if defined(STARBOARD) + // This is a slight performance optimization for Starboard. + // With Starboard, HasCurrentDefault() and GetCurrentDefault() are quite + // expensive, and GetCurrentDefault() is safe to call and will return + // nullptr when needed. + const auto& current_context = SequencedTaskRunner::GetCurrentDefault(); + const bool has_sequenced_context = !!current_context; + const bool post_task_success = PostTask( + from_here, + BindOnce(&PostTaskAndReplyRelay::RunTaskAndPostReply, + PostTaskAndReplyRelay( + from_here, std::move(task), std::move(reply), + has_sequenced_context ? current_context : nullptr))); +#else const bool has_sequenced_context = SequencedTaskRunner::HasCurrentDefault(); const bool post_task_success = PostTask( @@ -150,6 +164,7 @@ bool PostTaskAndReplyImpl::PostTaskAndReply(const Location& from_here, has_sequenced_context ? SequencedTaskRunner::GetCurrentDefault() : nullptr))); +#endif // PostTaskAndReply() requires a SequencedTaskRunner::CurrentDefaultHandle to // post the reply. Having no SequencedTaskRunner::CurrentDefaultHandle is From f427d1feae975f6daada515daea441b3970cff51 Mon Sep 17 00:00:00 2001 From: Jelle Foks Date: Mon, 11 Nov 2024 15:29:01 -0800 Subject: [PATCH 3/7] Don't track QuicSession.PacketWriteTime This accounted for 25% of CPU time of QuicChromiumPacketWriter::WritePacketToSocketImpl --- net/quic/quic_chromium_packet_writer.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/quic/quic_chromium_packet_writer.cc b/net/quic/quic_chromium_packet_writer.cc index e54fa65ee30f..ee3b6bd631f9 100644 --- a/net/quic/quic_chromium_packet_writer.cc +++ b/net/quic/quic_chromium_packet_writer.cc @@ -141,7 +141,10 @@ void QuicChromiumPacketWriter::WritePacketToSocket( } quic::WriteResult QuicChromiumPacketWriter::WritePacketToSocketImpl() { +#if !defined(STARBOARD) + // Tracking the histogram takes 25% of the CPU time on some devices. base::TimeTicks now = base::TimeTicks::Now(); +#endif int rv = socket_->Write(packet_.get(), packet_->size(), write_callback_, kTrafficAnnotation); @@ -168,12 +171,15 @@ quic::WriteResult QuicChromiumPacketWriter::WritePacketToSocketImpl() { } } +#if !defined(STARBOARD) + // Tracking the histogram here takes 25% of the CPU time on some devices. base::TimeDelta delta = base::TimeTicks::Now() - now; if (status == quic::WRITE_STATUS_OK) { UMA_HISTOGRAM_TIMES("Net.QuicSession.PacketWriteTime.Synchronous", delta); } else if (quic::IsWriteBlockedStatus(status)) { UMA_HISTOGRAM_TIMES("Net.QuicSession.PacketWriteTime.Asynchronous", delta); } +#endif return quic::WriteResult(status, rv); } From a30caf4c3cbb2b30cee1b35c2bcddd38a874ec73 Mon Sep 17 00:00:00 2001 From: Jelle Foks Date: Mon, 11 Nov 2024 16:54:38 -0800 Subject: [PATCH 4/7] Disable lifecycle tracing for performance --- base/task/sequence_manager/task_queue_impl.cc | 4 ++++ base/task/sequence_manager/task_queue_impl.h | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/base/task/sequence_manager/task_queue_impl.cc b/base/task/sequence_manager/task_queue_impl.cc index 6d92e7bfe5ae..681cfa9b994a 100644 --- a/base/task/sequence_manager/task_queue_impl.cc +++ b/base/task/sequence_manager/task_queue_impl.cc @@ -1402,6 +1402,9 @@ void TaskQueueImpl::ActivateDelayedFenceIfNeeded(const Task& task) { main_thread_only().delayed_fence = absl::nullopt; } +#if !defined(STARBOARD) +// We disable the "lifecycles" tracing group in Cobalt for performance +// reasons. void TaskQueueImpl::MaybeReportIpcTaskQueuedFromMainThread( const Task& pending_task) { if (!pending_task.ipc_hash) @@ -1502,6 +1505,7 @@ void TaskQueueImpl::ReportIpcTaskQueued( &ctx, pending_task.posted_from)); }); } +#endif void TaskQueueImpl::OnQueueUnblocked() { DCHECK(IsQueueEnabled()); diff --git a/base/task/sequence_manager/task_queue_impl.h b/base/task/sequence_manager/task_queue_impl.h index e631d9b7eb8a..3a426e7ef57e 100644 --- a/base/task/sequence_manager/task_queue_impl.h +++ b/base/task/sequence_manager/task_queue_impl.h @@ -536,6 +536,22 @@ class BASE_EXPORT TaskQueueImpl { // Reports the task if it was due to IPC and was posted to a disabled queue. // This should be called after WillQueueTask has been called for the task. +#if defined(STARBOARD) + // We disable the "lifecycles" tracing group in Cobalt for performance + // reasons. + void MaybeReportIpcTaskQueuedFromMainThread(const Task& pending_task) {}; + bool ShouldReportIpcTaskQueuedFromAnyThreadLocked( + base::TimeDelta* time_since_disabled) + EXCLUSIVE_LOCKS_REQUIRED(any_thread_lock_) { + return false; + } + void MaybeReportIpcTaskQueuedFromAnyThreadLocked(const Task& pending_task) + EXCLUSIVE_LOCKS_REQUIRED(any_thread_lock_) {} + void MaybeReportIpcTaskQueuedFromAnyThreadUnlocked(const Task& pending_task) { + } + void ReportIpcTaskQueued(const Task& pending_task, + const base::TimeDelta& time_since_disabled) {} +#else // !defined(STARBOARD) void MaybeReportIpcTaskQueuedFromMainThread(const Task& pending_task); bool ShouldReportIpcTaskQueuedFromAnyThreadLocked( base::TimeDelta* time_since_disabled) @@ -545,6 +561,7 @@ class BASE_EXPORT TaskQueueImpl { void MaybeReportIpcTaskQueuedFromAnyThreadUnlocked(const Task& pending_task); void ReportIpcTaskQueued(const Task& pending_task, const base::TimeDelta& time_since_disabled); +#endif // !defined(STARBOARD) // Invoked when the queue becomes enabled and not blocked by a fence. void OnQueueUnblocked(); From 8112ef7932fc272c8c76368e43ccddb01770a515 Mon Sep 17 00:00:00 2001 From: Jelle Foks Date: Mon, 11 Nov 2024 17:59:09 -0800 Subject: [PATCH 5/7] Less UMA histograms for packets --- net/quic/quic_connection_logger.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/net/quic/quic_connection_logger.cc b/net/quic/quic_connection_logger.cc index 3d61be149314..d36a68efec88 100644 --- a/net/quic/quic_connection_logger.cc +++ b/net/quic/quic_connection_logger.cc @@ -179,6 +179,7 @@ void QuicConnectionLogger::OnPacketSent( const quic::QuicFrames& retransmittable_frames, const quic::QuicFrames& nonretransmittable_frames, quic::QuicTime sent_time) { +#if !defined(STARBOARD) // 4.4.1.4. Minimum Packet Size // The payload of a UDP datagram carrying the Initial packet MUST be // expanded to at least 1200 octets @@ -211,6 +212,7 @@ void QuicConnectionLogger::OnPacketSent( NOTREACHED(); break; } +#endif event_logger_.OnPacketSent(packet_number, packet_length, has_crypto_handshake, transmission_type, encryption_level, @@ -241,6 +243,9 @@ void QuicConnectionLogger::OnPacketReceived( const quic::QuicSocketAddress& self_address, const quic::QuicSocketAddress& peer_address, const quic::QuicEncryptedPacket& packet) { +#if !defined(STARBOARD) + // We disable the packet receiving histogram in Cobalt for performance + // reasons. if (local_address_from_self_.GetFamily() == ADDRESS_FAMILY_UNSPECIFIED) { local_address_from_self_ = ToIPEndPoint(self_address); UMA_HISTOGRAM_ENUMERATION( @@ -248,6 +253,7 @@ void QuicConnectionLogger::OnPacketReceived( GetRealAddressFamily(ToIPEndPoint(self_address).address()), ADDRESS_FAMILY_LAST); } +#endif previous_received_packet_size_ = last_received_packet_size_; last_received_packet_size_ = packet.length(); @@ -301,7 +307,10 @@ void QuicConnectionLogger::OnPacketHeader(const quic::QuicPacketHeader& header, if (!largest_received_packet_number_.IsInitialized()) { largest_received_packet_number_ = header.packet_number; } else if (largest_received_packet_number_ < header.packet_number) { +#if !defined(STARBOARD) uint64_t delta = header.packet_number - largest_received_packet_number_; + // We disable the packet header histograms in Cobalt for performance + // reasons. if (delta > 1) { // There is a gap between the largest packet previously received and // the current packet. This indicates either loss, or out-of-order @@ -310,8 +319,12 @@ void QuicConnectionLogger::OnPacketHeader(const quic::QuicPacketHeader& header, "Net.QuicSession.PacketGapReceived", static_cast(delta - 1)); } +#endif largest_received_packet_number_ = header.packet_number; } +#if !defined(STARBOARD) + // We disable the packet header histograms in Cobalt for performance + // reasons. if (header.packet_number - first_received_packet_number_ < received_packets_.size()) { received_packets_[header.packet_number - first_received_packet_number_] = @@ -335,6 +348,7 @@ void QuicConnectionLogger::OnPacketHeader(const quic::QuicPacketHeader& header, } no_packet_received_after_ping_ = false; } +#endif last_received_packet_number_ = header.packet_number; event_logger_.OnPacketHeader(header, receive_time, level); } From 74bbb5a410c9f366583704324b1ce372cf467f5e Mon Sep 17 00:00:00 2001 From: Jelle Foks Date: Thu, 21 Nov 2024 09:52:46 -0800 Subject: [PATCH 6/7] Remove unused approximate_now_usage_counter_ --- net/quic/platform/impl/quic_chromium_clock.cc | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/net/quic/platform/impl/quic_chromium_clock.cc b/net/quic/platform/impl/quic_chromium_clock.cc index 11f5b421e01d..bfc7df7a2e40 100644 --- a/net/quic/platform/impl/quic_chromium_clock.cc +++ b/net/quic/platform/impl/quic_chromium_clock.cc @@ -11,8 +11,7 @@ namespace quic { namespace { -QuicTime approximate_now_{QuicTime::Zero()}; -int approximate_now_usage_counter_{0}; +QuicTime s_approximate_now{QuicTime::Zero()}; } // namespace QuicChromiumClock* QuicChromiumClock::GetInstance() { @@ -25,16 +24,14 @@ QuicChromiumClock::QuicChromiumClock() = default; QuicChromiumClock::~QuicChromiumClock() = default; void QuicChromiumClock::ZeroApproximateNow() { - approximate_now_ = QuicTime::Zero(); - approximate_now_usage_counter_ = 0; + s_approximate_now = QuicTime::Zero(); }; QuicTime QuicChromiumClock::ApproximateNow() const { // At the moment, Chrome does not have a distinct notion of ApproximateNow(). // We should consider implementing this using MessageLoop::recent_time_. - if (approximate_now_.IsInitialized() && - ++approximate_now_usage_counter_ < 16) { - return approximate_now_; + if (s_approximate_now.IsInitialized()) { + return s_approximate_now; } return Now(); } @@ -42,9 +39,8 @@ QuicTime QuicChromiumClock::ApproximateNow() const { QuicTime QuicChromiumClock::Now() const { int64_t ticks = (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds(); DCHECK_GE(ticks, 0); - approximate_now_ = CreateTimeFromMicroseconds(ticks); - approximate_now_usage_counter_ = 0; - return approximate_now_; + s_approximate_now = CreateTimeFromMicroseconds(ticks); + return s_approximate_now; } QuicWallTime QuicChromiumClock::WallNow() const { From ae5cb67161f789ed2f85539d89c0ced6a59d95bc Mon Sep 17 00:00:00 2001 From: Jelle Foks Date: Thu, 21 Nov 2024 10:02:19 -0800 Subject: [PATCH 7/7] Add missing STARBOARD define blocks --- net/quic/platform/impl/quic_chromium_clock.cc | 10 ++++++++++ net/quic/platform/impl/quic_chromium_clock.h | 2 ++ net/quic/quic_chromium_packet_reader.cc | 11 ++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/net/quic/platform/impl/quic_chromium_clock.cc b/net/quic/platform/impl/quic_chromium_clock.cc index bfc7df7a2e40..38eeb6cf53d4 100644 --- a/net/quic/platform/impl/quic_chromium_clock.cc +++ b/net/quic/platform/impl/quic_chromium_clock.cc @@ -10,9 +10,11 @@ namespace quic { +#if defined(STARBOARD) namespace { QuicTime s_approximate_now{QuicTime::Zero()}; } // namespace +#endif QuicChromiumClock* QuicChromiumClock::GetInstance() { static base::NoDestructor instance; @@ -23,24 +25,32 @@ QuicChromiumClock::QuicChromiumClock() = default; QuicChromiumClock::~QuicChromiumClock() = default; +#if defined(STARBOARD) void QuicChromiumClock::ZeroApproximateNow() { s_approximate_now = QuicTime::Zero(); }; +#endif QuicTime QuicChromiumClock::ApproximateNow() const { // At the moment, Chrome does not have a distinct notion of ApproximateNow(). // We should consider implementing this using MessageLoop::recent_time_. +#if defined(STARBOARD) if (s_approximate_now.IsInitialized()) { return s_approximate_now; } +#endif return Now(); } QuicTime QuicChromiumClock::Now() const { int64_t ticks = (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds(); DCHECK_GE(ticks, 0); +#if defined(STARBOARD) s_approximate_now = CreateTimeFromMicroseconds(ticks); return s_approximate_now; +#else + return CreateTimeFromMicroseconds(ticks); +#endif } QuicWallTime QuicChromiumClock::WallNow() const { diff --git a/net/quic/platform/impl/quic_chromium_clock.h b/net/quic/platform/impl/quic_chromium_clock.h index 773f06281445..d0269d7c6cd3 100644 --- a/net/quic/platform/impl/quic_chromium_clock.h +++ b/net/quic/platform/impl/quic_chromium_clock.h @@ -24,7 +24,9 @@ class NET_EXPORT_PRIVATE QuicChromiumClock : public QuicClock { ~QuicChromiumClock() override; +#if defined(STARBOARD) void ZeroApproximateNow(); +#endif // QuicClock implementation: QuicTime ApproximateNow() const override; diff --git a/net/quic/quic_chromium_packet_reader.cc b/net/quic/quic_chromium_packet_reader.cc index 7884f3e20a82..fc2f3dc98bbd 100644 --- a/net/quic/quic_chromium_packet_reader.cc +++ b/net/quic/quic_chromium_packet_reader.cc @@ -10,9 +10,12 @@ #include "base/task/single_thread_task_runner.h" #include "net/base/net_errors.h" #include "net/quic/address_utils.h" -#include "net/quic/platform/impl/quic_chromium_clock.h" #include "net/third_party/quiche/src/quiche/quic/core/quic_clock.h" +#if defined(STARBOARD) +#include "net/quic/platform/impl/quic_chromium_clock.h" +#endif + namespace net { namespace { @@ -204,7 +207,9 @@ void QuicChromiumPacketReader::StartReading() { } bool QuicChromiumPacketReader::ProcessReadResult(int result) { +#if defined(STARBOARD) quic::QuicChromiumClock::GetInstance()->ZeroApproximateNow(); +#endif read_pending_ = false; if (result <= 0 && net_log_.IsCapturing()) { net_log_.AddEventWithIntParams(NetLogEventType::QUIC_READ_ERROR, @@ -224,8 +229,12 @@ bool QuicChromiumPacketReader::ProcessReadResult(int result) { return visitor_->OnReadError(result, socket_); } +#if defined(STARBOARD) quic::QuicReceivedPacket packet(read_buffer_->data(), result, clock_->ApproximateNow()); +#else + quic::QuicReceivedPacket packet(read_buffer_->data(), result, clock_->Now()); +#endif IPEndPoint local_address; IPEndPoint peer_address; socket_->GetLocalAddress(&local_address);