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

Side by Side Diff: net/http/http_cache.cc

Issue 182993003: Add the ability for DevTools to wrap network transactions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « net/http/http_cache.h ('k') | net/net.gyp » ('j') | net/net.gyp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/http/http_cache.h" 5 #include "net/http/http_cache.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 10
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 HttpCache* const http_cache_; 284 HttpCache* const http_cache_;
285 }; 285 };
286 286
287 //----------------------------------------------------------------------------- 287 //-----------------------------------------------------------------------------
288 HttpCache::HttpCache(const net::HttpNetworkSession::Params& params, 288 HttpCache::HttpCache(const net::HttpNetworkSession::Params& params,
289 BackendFactory* backend_factory) 289 BackendFactory* backend_factory)
290 : net_log_(params.net_log), 290 : net_log_(params.net_log),
291 backend_factory_(backend_factory), 291 backend_factory_(backend_factory),
292 building_backend_(false), 292 building_backend_(false),
293 mode_(NORMAL), 293 mode_(NORMAL),
294 quic_server_info_factory_(params.enable_quic_persist_server_info ?
295 new QuicServerInfoFactoryAdaptor(this) : NULL),
296 network_layer_(new HttpNetworkLayer(new HttpNetworkSession(params))) { 294 network_layer_(new HttpNetworkLayer(new HttpNetworkSession(params))) {
297 HttpNetworkSession* session = network_layer_->GetSession(); 295 SetupQuicServerInfoFactory(network_layer_->GetSession());
298 session->quic_stream_factory()->set_quic_server_info_factory(
299 quic_server_info_factory_.get());
300 } 296 }
301 297
302 298
303 // This call doesn't change the shared |session|'s QuicServerInfoFactory because 299 // This call doesn't change the shared |session|'s QuicServerInfoFactory because
304 // |session| is shared. 300 // |session| is shared.
305 HttpCache::HttpCache(HttpNetworkSession* session, 301 HttpCache::HttpCache(HttpNetworkSession* session,
306 BackendFactory* backend_factory) 302 BackendFactory* backend_factory)
307 : net_log_(session->net_log()), 303 : net_log_(session->net_log()),
308 backend_factory_(backend_factory), 304 backend_factory_(backend_factory),
309 building_backend_(false), 305 building_backend_(false),
310 mode_(NORMAL), 306 mode_(NORMAL),
311 network_layer_(new HttpNetworkLayer(session)) { 307 network_layer_(new HttpNetworkLayer(session)) {
312 } 308 }
313 309
314 HttpCache::HttpCache(HttpTransactionFactory* network_layer, 310 HttpCache::HttpCache(HttpTransactionFactory* network_layer,
315 NetLog* net_log, 311 NetLog* net_log,
316 BackendFactory* backend_factory) 312 BackendFactory* backend_factory)
317 : net_log_(net_log), 313 : net_log_(net_log),
318 backend_factory_(backend_factory), 314 backend_factory_(backend_factory),
319 building_backend_(false), 315 building_backend_(false),
320 mode_(NORMAL), 316 mode_(NORMAL),
321 network_layer_(network_layer) { 317 network_layer_(network_layer) {
318 SetupQuicServerInfoFactory(network_layer_->GetSession());
322 } 319 }
323 320
324 HttpCache::~HttpCache() { 321 HttpCache::~HttpCache() {
325 // If we have any active entries remaining, then we need to deactivate them. 322 // If we have any active entries remaining, then we need to deactivate them.
326 // We may have some pending calls to OnProcessPendingQueue, but since those 323 // We may have some pending calls to OnProcessPendingQueue, but since those
327 // won't run (due to our destruction), we can simply ignore the corresponding 324 // won't run (due to our destruction), we can simply ignore the corresponding
328 // will_process_pending_queue flag. 325 // will_process_pending_queue flag.
329 while (!active_entries_.empty()) { 326 while (!active_entries_.empty()) {
330 ActiveEntry* entry = active_entries_.begin()->second; 327 ActiveEntry* entry = active_entries_.begin()->second;
331 entry->will_process_pending_queue = false; 328 entry->will_process_pending_queue = false;
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 for (; it != pending_queue.end(); ++it) { 990 for (; it != pending_queue.end(); ++it) {
994 if ((*it)->Matches(trans)) { 991 if ((*it)->Matches(trans)) {
995 delete *it; 992 delete *it;
996 pending_queue.erase(it); 993 pending_queue.erase(it);
997 return true; 994 return true;
998 } 995 }
999 } 996 }
1000 return false; 997 return false;
1001 } 998 }
1002 999
1000 void HttpCache::SetupQuicServerInfoFactory(HttpNetworkSession* session) {
1001 if (session->params().enable_quic_persist_server_info &&
1002 !session->quic_stream_factory()->has_quic_server_info_factory()) {
1003 DCHECK(!quic_server_info_factory_);
1004 quic_server_info_factory_.reset(new QuicServerInfoFactoryAdaptor(this));
1005 session->quic_stream_factory()->set_quic_server_info_factory(
1006 quic_server_info_factory_.get());
1007 }
1008 }
1009
1003 void HttpCache::ProcessPendingQueue(ActiveEntry* entry) { 1010 void HttpCache::ProcessPendingQueue(ActiveEntry* entry) {
1004 // Multiple readers may finish with an entry at once, so we want to batch up 1011 // Multiple readers may finish with an entry at once, so we want to batch up
1005 // calls to OnProcessPendingQueue. This flag also tells us that we should 1012 // calls to OnProcessPendingQueue. This flag also tells us that we should
1006 // not delete the entry before OnProcessPendingQueue runs. 1013 // not delete the entry before OnProcessPendingQueue runs.
1007 if (entry->will_process_pending_queue) 1014 if (entry->will_process_pending_queue)
1008 return; 1015 return;
1009 entry->will_process_pending_queue = true; 1016 entry->will_process_pending_queue = true;
1010 1017
1011 base::MessageLoop::current()->PostTask( 1018 base::MessageLoop::current()->PostTask(
1012 FROM_HERE, 1019 FROM_HERE,
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 building_backend_ = false; 1180 building_backend_ = false;
1174 DeletePendingOp(pending_op); 1181 DeletePendingOp(pending_op);
1175 } 1182 }
1176 1183
1177 // The cache may be gone when we return from the callback. 1184 // The cache may be gone when we return from the callback.
1178 if (!item->DoCallback(result, disk_cache_.get())) 1185 if (!item->DoCallback(result, disk_cache_.get()))
1179 item->NotifyTransaction(result, NULL); 1186 item->NotifyTransaction(result, NULL);
1180 } 1187 }
1181 1188
1182 } // namespace net 1189 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_cache.h ('k') | net/net.gyp » ('j') | net/net.gyp » ('J')

Powered by Google App Engine
This is Rietveld 408576698