Landing Recent QUIC changes until 4/15/2016 17:20 UTC
Fix a few spurious string allocations in QuicCryptoServerStream and QuicCryptoStream. No functional change. Not flag protected.
Merge internal change: 119967190
https://codereview.chromium.org/1906803004/
Quic will push urls in x-associate-content and link headers upon ResponseHeadersComplete(). Change AcceptQuicClient() to start the request pipeline from PICKING_SERVICE for server push stream. Protected by FLAGS_quic_server_push.
Implemented server push feature in QUIC. This feature will be enabled by
both flag and connection option "kSPSH".
Merge internal change: 119871679
https://codereview.chromium.org/1905073002/
Split out QuicAlarm creation from QuicConnectionHelper to new QuicAlarmFactory. No behavior change, not protected.
This is in preparation for gRPC-over-QUIC to use a separate
QuicAlarmFactory for each GrpcQuicConnection. Currently there exists a
single Helper (and after this CL a single AlarmFactory) per Dispatcher,
and this is used to create alarms for all Connections.
gRPC-over-QUIC needs to add per-connection locking to connection alarms
before firing them, and a followup CL will create a different
AlarmFactory for each gRPC-over-QUIC connection, each with its own
mutex (rather than sharing one mutex across the alarms of connections
which is obviously terrible).
Merge internal change: 119778209
https://codereview.chromium.org/1905843003/
Make QuicDispatcher's helper argument be a unique_ptr to make ownership clear. No behavior change.
(also removes very out of date QuicDispatcher constructor comment)
Merge internal change: 119753783
https://codereview.chromium.org/1907773002/
Deprecate FLAGS_quic_sslr_byte_conservation.
Merge internal change: 119678304
https://codereview.chromium.org/1906703002/
Deprecate FLAGS_quic_consolidate_onstreamframe_errors
Merge internal change: 119653892
https://codereview.chromium.org/1906473004/
Add a server push disabled test.
Merge internal change: 119645068
https://codereview.chromium.org/1911653003/
Cleanup: Migrate references from scoped_ptr to std::unique_ptr. scoped_ptr is now just an alias for unique_ptr, so this is a purely textual change. base/scoped_ptr.h will be removed soon.
Merge internal change: 119583512
https://codereview.chromium.org/1909453005/
Cleanup: Migrate references from scoped_ptr to std::unique_ptr. scoped_ptr is now just an alias for unique_ptr, so this is a purely textual change. base/scoped_ptr.h will be removed soon.
Merge internal change: 119581790
https://codereview.chromium.org/1911653002/
Cleanup: Migrate references from scoped_ptr to std::unique_ptr. scoped_ptr is now just an alias for unique_ptr, so this is a purely textual change. base/scoped_ptr.h will be removed soon.
Merge internal change: 119576588
https://codereview.chromium.org/1908723002/
Plumbs new SpdyFramerVisitorInterface method handling through QUIC test utilities, including the test client and test server. Preparation for CL 103292114.
Merge internal change: 119568788
https://codereview.chromium.org/1910593004/
Fixes QuicSpdyStream::ConsumeHeaderList to prod the sequencer when headers are consumed. Not yet used in production.
Merge internal change: 119562680
https://codereview.chromium.org/1910483004/
Stop returning unused return value from QuicPacketCreator::CopyToBuffer. No functional change. Not flag protected.
Merge internal change: 119557380
https://codereview.chromium.org/1897153007/
ignore invalid error code in QuicFramer when process GoAway, ConnectionClose, RstStream frames to do normal goaway, connection close, and stream reset. Flag protected by FLAGS_quic_ignore_invalid_error_code.
Merge internal change: 119551887
https://codereview.chromium.org/1904833002/
Adds a DebugString() method to QuicHeaderList.
Merge internal change: 119529330
https://codereview.chromium.org/1907683002/
Review URL: https://codereview.chromium.org/1908103002
Cr-Commit-Position: refs/heads/master@{#389035}
diff --git a/net/quic/quic_chromium_alarm_factory.cc b/net/quic/quic_chromium_alarm_factory.cc
new file mode 100644
index 0000000..8973b97
--- /dev/null
+++ b/net/quic/quic_chromium_alarm_factory.cc
@@ -0,0 +1,117 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/quic/quic_chromium_alarm_factory.h"
+
+#include "base/bind.h"
+#include "base/location.h"
+#include "base/logging.h"
+#include "base/metrics/sparse_histogram.h"
+#include "base/task_runner.h"
+#include "base/time/time.h"
+
+namespace net {
+
+namespace {
+
+class QuicChromeAlarm : public QuicAlarm {
+ public:
+ QuicChromeAlarm(const QuicClock* clock,
+ base::TaskRunner* task_runner,
+ QuicArenaScopedPtr<QuicAlarm::Delegate> delegate)
+ : QuicAlarm(std::move(delegate)),
+ clock_(clock),
+ task_runner_(task_runner),
+ task_deadline_(QuicTime::Zero()),
+ weak_factory_(this) {}
+
+ protected:
+ void SetImpl() override {
+ DCHECK(deadline().IsInitialized());
+ if (task_deadline_.IsInitialized()) {
+ if (task_deadline_ <= deadline()) {
+ // Since tasks can not be un-posted, OnAlarm will be invoked which
+ // will notice that deadline has not yet been reached, and will set
+ // the alarm for the new deadline.
+ return;
+ }
+ // The scheduled task is after new deadline. Invalidate the weak ptrs
+ // so that task does not execute when we're not expecting it.
+ weak_factory_.InvalidateWeakPtrs();
+ }
+
+ int64_t delay_us = deadline().Subtract(clock_->Now()).ToMicroseconds();
+ if (delay_us < 0) {
+ delay_us = 0;
+ }
+ task_runner_->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&QuicChromeAlarm::OnAlarm, weak_factory_.GetWeakPtr()),
+ base::TimeDelta::FromMicroseconds(delay_us));
+ task_deadline_ = deadline();
+ }
+
+ void CancelImpl() override {
+ DCHECK(!deadline().IsInitialized());
+ // Since tasks can not be un-posted, OnAlarm will be invoked which
+ // will notice that deadline is not Initialized and will do nothing.
+ }
+
+ private:
+ void OnAlarm() {
+ DCHECK(task_deadline_.IsInitialized());
+ task_deadline_ = QuicTime::Zero();
+ // The alarm may have been cancelled.
+ if (!deadline().IsInitialized()) {
+ return;
+ }
+
+ // The alarm may have been re-set to a later time.
+ if (clock_->Now() < deadline()) {
+ SetImpl();
+ return;
+ }
+
+ Fire();
+ }
+
+ const QuicClock* clock_;
+ base::TaskRunner* task_runner_;
+ // If a task has been posted to the message loop, this is the time it
+ // was scheduled to fire. Tracking this allows us to avoid posting a
+ // new tast if the new deadline is in the future, but permits us to
+ // post a new task when the new deadline now earlier than when
+ // previously posted.
+ QuicTime task_deadline_;
+ base::WeakPtrFactory<QuicChromeAlarm> weak_factory_;
+};
+
+} // namespace
+
+QuicChromiumAlarmFactory::QuicChromiumAlarmFactory(
+ base::TaskRunner* task_runner,
+ const QuicClock* clock)
+ : task_runner_(task_runner), clock_(clock), weak_factory_(this) {}
+
+QuicChromiumAlarmFactory::~QuicChromiumAlarmFactory() {}
+
+QuicArenaScopedPtr<QuicAlarm> QuicChromiumAlarmFactory::CreateAlarm(
+ QuicArenaScopedPtr<QuicAlarm::Delegate> delegate,
+ QuicConnectionArena* arena) {
+ if (arena != nullptr) {
+ return arena->New<QuicChromeAlarm>(clock_, task_runner_,
+ std::move(delegate));
+ } else {
+ return QuicArenaScopedPtr<QuicAlarm>(
+ new QuicChromeAlarm(clock_, task_runner_, std::move(delegate)));
+ }
+}
+
+QuicAlarm* QuicChromiumAlarmFactory::CreateAlarm(
+ QuicAlarm::Delegate* delegate) {
+ return new QuicChromeAlarm(clock_, task_runner_,
+ QuicArenaScopedPtr<QuicAlarm::Delegate>(delegate));
+}
+
+} // namespace net