Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: net/quic/core/quic_client_session_base.cc

Issue 2611613003: Add quic_logging (Closed)
Patch Set: fix failed test? Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/core/quic_client_promised_info_test.cc ('k') | net/quic/core/quic_config.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/core/quic_client_session_base.h" 5 #include "net/quic/core/quic_client_session_base.h"
6 6
7 #include "net/quic/core/quic_client_promised_info.h" 7 #include "net/quic/core/quic_client_promised_info.h"
8 #include "net/quic/core/quic_flags.h" 8 #include "net/quic/core/quic_flags.h"
9 #include "net/quic/core/spdy_utils.h" 9 #include "net/quic/core/spdy_utils.h"
10 #include "net/quic/platform/api/quic_logging.h"
10 11
11 using base::StringPiece; 12 using base::StringPiece;
12 using std::string; 13 using std::string;
13 14
14 namespace net { 15 namespace net {
15 16
16 QuicClientSessionBase::QuicClientSessionBase( 17 QuicClientSessionBase::QuicClientSessionBase(
17 QuicConnection* connection, 18 QuicConnection* connection,
18 QuicClientPushPromiseIndex* push_promise_index, 19 QuicClientPushPromiseIndex* push_promise_index,
19 const QuicConfig& config) 20 const QuicConfig& config)
20 : QuicSpdySession(connection, nullptr, config), 21 : QuicSpdySession(connection, nullptr, config),
21 push_promise_index_(push_promise_index), 22 push_promise_index_(push_promise_index),
22 largest_promised_stream_id_(kInvalidStreamId) {} 23 largest_promised_stream_id_(kInvalidStreamId) {}
23 24
24 QuicClientSessionBase::~QuicClientSessionBase() { 25 QuicClientSessionBase::~QuicClientSessionBase() {
25 // all promised streams for this session 26 // all promised streams for this session
26 for (auto& it : promised_by_id_) { 27 for (auto& it : promised_by_id_) {
27 DVLOG(1) << "erase stream " << it.first << " url " << it.second->url(); 28 QUIC_DVLOG(1) << "erase stream " << it.first << " url " << it.second->url();
28 push_promise_index_->promised_by_url()->erase(it.second->url()); 29 push_promise_index_->promised_by_url()->erase(it.second->url());
29 } 30 }
30 delete connection(); 31 delete connection();
31 } 32 }
32 33
33 void QuicClientSessionBase::OnConfigNegotiated() { 34 void QuicClientSessionBase::OnConfigNegotiated() {
34 QuicSpdySession::OnConfigNegotiated(); 35 QuicSpdySession::OnConfigNegotiated();
35 } 36 }
36 37
37 void QuicClientSessionBase::OnCryptoHandshakeEvent(CryptoHandshakeEvent event) { 38 void QuicClientSessionBase::OnCryptoHandshakeEvent(CryptoHandshakeEvent event) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 80
80 bool QuicClientSessionBase::HandlePromised(QuicStreamId /* associated_id */, 81 bool QuicClientSessionBase::HandlePromised(QuicStreamId /* associated_id */,
81 QuicStreamId id, 82 QuicStreamId id,
82 const SpdyHeaderBlock& headers) { 83 const SpdyHeaderBlock& headers) {
83 // Due to pathalogical packet re-ordering, it is possible that 84 // Due to pathalogical packet re-ordering, it is possible that
84 // frames for the promised stream have already arrived, and the 85 // frames for the promised stream have already arrived, and the
85 // promised stream could be active or closed. 86 // promised stream could be active or closed.
86 if (IsClosedStream(id)) { 87 if (IsClosedStream(id)) {
87 // There was a RST on the data stream already, perhaps 88 // There was a RST on the data stream already, perhaps
88 // QUIC_REFUSED_STREAM? 89 // QUIC_REFUSED_STREAM?
89 DVLOG(1) << "Promise ignored for stream " << id 90 QUIC_DVLOG(1) << "Promise ignored for stream " << id
90 << " that is already closed"; 91 << " that is already closed";
91 return false; 92 return false;
92 } 93 }
93 94
94 if (push_promise_index_->promised_by_url()->size() >= get_max_promises()) { 95 if (push_promise_index_->promised_by_url()->size() >= get_max_promises()) {
95 DVLOG(1) << "Too many promises, rejecting promise for stream " << id; 96 QUIC_DVLOG(1) << "Too many promises, rejecting promise for stream " << id;
96 ResetPromised(id, QUIC_REFUSED_STREAM); 97 ResetPromised(id, QUIC_REFUSED_STREAM);
97 return false; 98 return false;
98 } 99 }
99 100
100 const string url = SpdyUtils::GetUrlFromHeaderBlock(headers); 101 const string url = SpdyUtils::GetUrlFromHeaderBlock(headers);
101 QuicClientPromisedInfo* old_promised = GetPromisedByUrl(url); 102 QuicClientPromisedInfo* old_promised = GetPromisedByUrl(url);
102 if (old_promised) { 103 if (old_promised) {
103 DVLOG(1) << "Promise for stream " << id << " is duplicate URL " << url 104 QUIC_DVLOG(1) << "Promise for stream " << id << " is duplicate URL " << url
104 << " of previous promise for stream " << old_promised->id(); 105 << " of previous promise for stream " << old_promised->id();
105 ResetPromised(id, QUIC_DUPLICATE_PROMISE_URL); 106 ResetPromised(id, QUIC_DUPLICATE_PROMISE_URL);
106 return false; 107 return false;
107 } 108 }
108 109
109 if (GetPromisedById(id)) { 110 if (GetPromisedById(id)) {
110 // OnPromiseHeadersComplete() would have closed the connection if 111 // OnPromiseHeadersComplete() would have closed the connection if
111 // promised id is a duplicate. 112 // promised id is a duplicate.
112 QUIC_BUG << "Duplicate promise for id " << id; 113 QUIC_BUG << "Duplicate promise for id " << id;
113 return false; 114 return false;
114 } 115 }
115 116
116 QuicClientPromisedInfo* promised = new QuicClientPromisedInfo(this, id, url); 117 QuicClientPromisedInfo* promised = new QuicClientPromisedInfo(this, id, url);
117 std::unique_ptr<QuicClientPromisedInfo> promised_owner(promised); 118 std::unique_ptr<QuicClientPromisedInfo> promised_owner(promised);
118 promised->Init(); 119 promised->Init();
119 DVLOG(1) << "stream " << id << " emplace url " << url; 120 QUIC_DVLOG(1) << "stream " << id << " emplace url " << url;
120 (*push_promise_index_->promised_by_url())[url] = promised; 121 (*push_promise_index_->promised_by_url())[url] = promised;
121 promised_by_id_[id] = std::move(promised_owner); 122 promised_by_id_[id] = std::move(promised_owner);
122 promised->OnPromiseHeaders(headers); 123 promised->OnPromiseHeaders(headers);
123 return true; 124 return true;
124 } 125 }
125 126
126 QuicClientPromisedInfo* QuicClientSessionBase::GetPromisedByUrl( 127 QuicClientPromisedInfo* QuicClientSessionBase::GetPromisedByUrl(
127 const string& url) { 128 const string& url) {
128 QuicPromisedByUrlMap::iterator it = 129 QuicPromisedByUrlMap::iterator it =
129 push_promise_index_->promised_by_url()->find(url); 130 push_promise_index_->promised_by_url()->find(url);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 bool locally_reset) { 174 bool locally_reset) {
174 QuicSpdySession::CloseStreamInner(stream_id, locally_reset); 175 QuicSpdySession::CloseStreamInner(stream_id, locally_reset);
175 headers_stream()->MaybeReleaseSequencerBuffer(); 176 headers_stream()->MaybeReleaseSequencerBuffer();
176 } 177 }
177 178
178 bool QuicClientSessionBase::ShouldReleaseHeadersStreamSequencerBuffer() { 179 bool QuicClientSessionBase::ShouldReleaseHeadersStreamSequencerBuffer() {
179 return num_active_requests() == 0 && promised_by_id_.empty(); 180 return num_active_requests() == 0 && promised_by_id_.empty();
180 } 181 }
181 182
182 } // namespace net 183 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_client_promised_info_test.cc ('k') | net/quic/core/quic_config.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698