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

Side by Side Diff: net/tools/quic/quic_simple_server_session.cc

Issue 2518063007: Pass QuicInMemoryCache directly instead of using a singleton. (Closed)
Patch Set: Fix Cronet compile error Created 4 years 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/tools/quic/quic_simple_server_session.h" 5 #include "net/tools/quic/quic_simple_server_session.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "net/quic/core/proto/cached_network_parameters.pb.h" 11 #include "net/quic/core/proto/cached_network_parameters.pb.h"
12 #include "net/quic/core/quic_connection.h" 12 #include "net/quic/core/quic_connection.h"
13 #include "net/quic/core/quic_flags.h" 13 #include "net/quic/core/quic_flags.h"
14 #include "net/quic/core/quic_spdy_session.h" 14 #include "net/quic/core/quic_spdy_session.h"
15 #include "net/tools/quic/quic_simple_server_stream.h" 15 #include "net/tools/quic/quic_simple_server_stream.h"
16 #include "url/gurl.h" 16 #include "url/gurl.h"
17 17
18 using std::string; 18 using std::string;
19 19
20 namespace net { 20 namespace net {
21 21
22 QuicSimpleServerSession::QuicSimpleServerSession( 22 QuicSimpleServerSession::QuicSimpleServerSession(
23 const QuicConfig& config, 23 const QuicConfig& config,
24 QuicConnection* connection, 24 QuicConnection* connection,
25 QuicSession::Visitor* visitor, 25 QuicSession::Visitor* visitor,
26 QuicCryptoServerStream::Helper* helper, 26 QuicCryptoServerStream::Helper* helper,
27 const QuicCryptoServerConfig* crypto_config, 27 const QuicCryptoServerConfig* crypto_config,
28 QuicCompressedCertsCache* compressed_certs_cache) 28 QuicCompressedCertsCache* compressed_certs_cache,
29 QuicInMemoryCache* in_memory_cache)
29 : QuicServerSessionBase(config, 30 : QuicServerSessionBase(config,
30 connection, 31 connection,
31 visitor, 32 visitor,
32 helper, 33 helper,
33 crypto_config, 34 crypto_config,
34 compressed_certs_cache), 35 compressed_certs_cache),
35 highest_promised_stream_id_(0) {} 36 highest_promised_stream_id_(0),
37 in_memory_cache_(in_memory_cache) {}
36 38
37 QuicSimpleServerSession::~QuicSimpleServerSession() { 39 QuicSimpleServerSession::~QuicSimpleServerSession() {
38 delete connection(); 40 delete connection();
39 } 41 }
40 42
41 QuicCryptoServerStreamBase* 43 QuicCryptoServerStreamBase*
42 QuicSimpleServerSession::CreateQuicCryptoServerStream( 44 QuicSimpleServerSession::CreateQuicCryptoServerStream(
43 const QuicCryptoServerConfig* crypto_config, 45 const QuicCryptoServerConfig* crypto_config,
44 QuicCompressedCertsCache* compressed_certs_cache) { 46 QuicCompressedCertsCache* compressed_certs_cache) {
45 return new QuicCryptoServerStream(crypto_config, compressed_certs_cache, 47 return new QuicCryptoServerStream(crypto_config, compressed_certs_cache,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // Procese promised push request as many as possible. 89 // Procese promised push request as many as possible.
88 HandlePromisedPushRequests(); 90 HandlePromisedPushRequests();
89 } 91 }
90 92
91 QuicSpdyStream* QuicSimpleServerSession::CreateIncomingDynamicStream( 93 QuicSpdyStream* QuicSimpleServerSession::CreateIncomingDynamicStream(
92 QuicStreamId id) { 94 QuicStreamId id) {
93 if (!ShouldCreateIncomingDynamicStream(id)) { 95 if (!ShouldCreateIncomingDynamicStream(id)) {
94 return nullptr; 96 return nullptr;
95 } 97 }
96 98
97 QuicSpdyStream* stream = new QuicSimpleServerStream(id, this); 99 QuicSpdyStream* stream =
100 new QuicSimpleServerStream(id, this, in_memory_cache_);
98 ActivateStream(base::WrapUnique(stream)); 101 ActivateStream(base::WrapUnique(stream));
99 return stream; 102 return stream;
100 } 103 }
101 104
102 QuicSimpleServerStream* QuicSimpleServerSession::CreateOutgoingDynamicStream( 105 QuicSimpleServerStream* QuicSimpleServerSession::CreateOutgoingDynamicStream(
103 SpdyPriority priority) { 106 SpdyPriority priority) {
104 if (!ShouldCreateOutgoingDynamicStream()) { 107 if (!ShouldCreateOutgoingDynamicStream()) {
105 return nullptr; 108 return nullptr;
106 } 109 }
107 110
108 QuicSimpleServerStream* stream = 111 QuicSimpleServerStream* stream = new QuicSimpleServerStream(
109 new QuicSimpleServerStream(GetNextOutgoingStreamId(), this); 112 GetNextOutgoingStreamId(), this, in_memory_cache_);
110 stream->SetPriority(priority); 113 stream->SetPriority(priority);
111 ActivateStream(base::WrapUnique(stream)); 114 ActivateStream(base::WrapUnique(stream));
112 return stream; 115 return stream;
113 } 116 }
114 117
115 void QuicSimpleServerSession::CloseStreamInner(QuicStreamId stream_id, 118 void QuicSimpleServerSession::CloseStreamInner(QuicStreamId stream_id,
116 bool locally_reset) { 119 bool locally_reset) {
117 QuicSpdySession::CloseStreamInner(stream_id, locally_reset); 120 QuicSpdySession::CloseStreamInner(stream_id, locally_reset);
118 HandlePromisedPushRequests(); 121 HandlePromisedPushRequests();
119 } 122 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 DVLOG(1) << "created server push stream " << promised_stream->id(); 202 DVLOG(1) << "created server push stream " << promised_stream->id();
200 203
201 SpdyHeaderBlock request_headers(std::move(promised_info.request_headers)); 204 SpdyHeaderBlock request_headers(std::move(promised_info.request_headers));
202 205
203 promised_streams_.pop_front(); 206 promised_streams_.pop_front();
204 promised_stream->PushResponse(std::move(request_headers)); 207 promised_stream->PushResponse(std::move(request_headers));
205 } 208 }
206 } 209 }
207 210
208 } // namespace net 211 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_simple_server_session.h ('k') | net/tools/quic/quic_simple_server_session_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698