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

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

Issue 6125001: Fixed first pass at adding http/backend cache events to the NetLog. ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix Created 9 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 | Annotate | Revision Log
« no previous file with comments | « net/http/http_cache.h ('k') | net/http/http_cache_transaction.h » ('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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 thread_(thread) { 48 thread_(thread) {
49 } 49 }
50 50
51 HttpCache::DefaultBackend::~DefaultBackend() {} 51 HttpCache::DefaultBackend::~DefaultBackend() {}
52 52
53 // static 53 // static
54 HttpCache::BackendFactory* HttpCache::DefaultBackend::InMemory(int max_bytes) { 54 HttpCache::BackendFactory* HttpCache::DefaultBackend::InMemory(int max_bytes) {
55 return new DefaultBackend(MEMORY_CACHE, FilePath(), max_bytes, NULL); 55 return new DefaultBackend(MEMORY_CACHE, FilePath(), max_bytes, NULL);
56 } 56 }
57 57
58 int HttpCache::DefaultBackend::CreateBackend(disk_cache::Backend** backend, 58 int HttpCache::DefaultBackend::CreateBackend(NetLog* net_log,
59 disk_cache::Backend** backend,
59 CompletionCallback* callback) { 60 CompletionCallback* callback) {
60 DCHECK_GE(max_bytes_, 0); 61 DCHECK_GE(max_bytes_, 0);
61 return disk_cache::CreateCacheBackend(type_, path_, max_bytes_, true, 62 return disk_cache::CreateCacheBackend(type_, path_, max_bytes_, true,
62 thread_, backend, callback); 63 thread_, net_log, backend, callback);
63 } 64 }
64 65
65 //----------------------------------------------------------------------------- 66 //-----------------------------------------------------------------------------
66 67
67 HttpCache::ActiveEntry::ActiveEntry(disk_cache::Entry* e) 68 HttpCache::ActiveEntry::ActiveEntry(disk_cache::Entry* entry)
68 : disk_entry(e), 69 : disk_entry(entry),
69 writer(NULL), 70 writer(NULL),
70 will_process_pending_queue(false), 71 will_process_pending_queue(false),
71 doomed(false) { 72 doomed(false) {
72 } 73 }
73 74
74 HttpCache::ActiveEntry::~ActiveEntry() { 75 HttpCache::ActiveEntry::~ActiveEntry() {
75 if (disk_entry) { 76 if (disk_entry) {
76 disk_entry->Close(); 77 disk_entry->Close();
77 disk_entry = NULL; 78 disk_entry = NULL;
78 } 79 }
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 HttpCache::HttpCache(HostResolver* host_resolver, 282 HttpCache::HttpCache(HostResolver* host_resolver,
282 CertVerifier* cert_verifier, 283 CertVerifier* cert_verifier,
283 DnsRRResolver* dnsrr_resolver, 284 DnsRRResolver* dnsrr_resolver,
284 DnsCertProvenanceChecker* dns_cert_checker_, 285 DnsCertProvenanceChecker* dns_cert_checker_,
285 ProxyService* proxy_service, 286 ProxyService* proxy_service,
286 SSLConfigService* ssl_config_service, 287 SSLConfigService* ssl_config_service,
287 HttpAuthHandlerFactory* http_auth_handler_factory, 288 HttpAuthHandlerFactory* http_auth_handler_factory,
288 HttpNetworkDelegate* network_delegate, 289 HttpNetworkDelegate* network_delegate,
289 NetLog* net_log, 290 NetLog* net_log,
290 BackendFactory* backend_factory) 291 BackendFactory* backend_factory)
291 : backend_factory_(backend_factory), 292 : net_log_(net_log),
293 backend_factory_(backend_factory),
292 building_backend_(false), 294 building_backend_(false),
293 mode_(NORMAL), 295 mode_(NORMAL),
294 ssl_host_info_factory_(new SSLHostInfoFactoryAdaptor( 296 ssl_host_info_factory_(new SSLHostInfoFactoryAdaptor(
295 ALLOW_THIS_IN_INITIALIZER_LIST(this))), 297 ALLOW_THIS_IN_INITIALIZER_LIST(this))),
296 network_layer_(HttpNetworkLayer::CreateFactory(host_resolver, 298 network_layer_(HttpNetworkLayer::CreateFactory(host_resolver,
297 cert_verifier, dnsrr_resolver, dns_cert_checker_, 299 cert_verifier, dnsrr_resolver, dns_cert_checker_,
298 ssl_host_info_factory_.get(), 300 ssl_host_info_factory_.get(),
299 proxy_service, ssl_config_service, 301 proxy_service, ssl_config_service,
300 http_auth_handler_factory, network_delegate, net_log)), 302 http_auth_handler_factory, network_delegate, net_log)),
301 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)) { 303 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)) {
302 } 304 }
303 305
304 HttpCache::HttpCache(HttpNetworkSession* session, 306 HttpCache::HttpCache(HttpNetworkSession* session,
305 BackendFactory* backend_factory) 307 BackendFactory* backend_factory)
306 : backend_factory_(backend_factory), 308 : net_log_(session->net_log()),
309 backend_factory_(backend_factory),
307 building_backend_(false), 310 building_backend_(false),
308 mode_(NORMAL), 311 mode_(NORMAL),
309 network_layer_(HttpNetworkLayer::CreateFactory(session)), 312 network_layer_(HttpNetworkLayer::CreateFactory(session)),
310 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)) { 313 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)) {
311 } 314 }
312 315
313 HttpCache::HttpCache(HttpTransactionFactory* network_layer, 316 HttpCache::HttpCache(HttpTransactionFactory* network_layer,
317 NetLog* net_log,
314 BackendFactory* backend_factory) 318 BackendFactory* backend_factory)
315 : backend_factory_(backend_factory), 319 : net_log_(net_log),
320 backend_factory_(backend_factory),
316 building_backend_(false), 321 building_backend_(false),
317 mode_(NORMAL), 322 mode_(NORMAL),
318 network_layer_(network_layer), 323 network_layer_(network_layer),
319 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)) { 324 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)) {
320 } 325 }
321 326
322 HttpCache::~HttpCache() { 327 HttpCache::~HttpCache() {
323 // If we have any active entries remaining, then we need to deactivate them. 328 // If we have any active entries remaining, then we need to deactivate them.
324 // We may have some pending calls to OnProcessPendingQueue, but since those 329 // We may have some pending calls to OnProcessPendingQueue, but since those
325 // won't run (due to our destruction), we can simply ignore the corresponding 330 // won't run (due to our destruction), we can simply ignore the corresponding
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 pending_op->pending_queue.push_back(item.release()); 462 pending_op->pending_queue.push_back(item.release());
458 return ERR_IO_PENDING; 463 return ERR_IO_PENDING;
459 } 464 }
460 465
461 DCHECK(pending_op->pending_queue.empty()); 466 DCHECK(pending_op->pending_queue.empty());
462 467
463 pending_op->writer = item.release(); 468 pending_op->writer = item.release();
464 BackendCallback* my_callback = new BackendCallback(this, pending_op); 469 BackendCallback* my_callback = new BackendCallback(this, pending_op);
465 pending_op->callback = my_callback; 470 pending_op->callback = my_callback;
466 471
467 int rv = backend_factory_->CreateBackend(&pending_op->backend, my_callback); 472 int rv = backend_factory_->CreateBackend(net_log_, &pending_op->backend,
473 my_callback);
468 if (rv != ERR_IO_PENDING) { 474 if (rv != ERR_IO_PENDING) {
469 pending_op->writer->ClearCallback(); 475 pending_op->writer->ClearCallback();
470 my_callback->Run(rv); 476 my_callback->Run(rv);
471 } 477 }
472 478
473 return rv; 479 return rv;
474 } 480 }
475 481
476 int HttpCache::GetBackendForTransaction(Transaction* trans) { 482 int HttpCache::GetBackendForTransaction(Transaction* trans) {
477 if (disk_cache_.get()) 483 if (disk_cache_.get())
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 building_backend_ = false; 1093 building_backend_ = false;
1088 DeletePendingOp(pending_op); 1094 DeletePendingOp(pending_op);
1089 } 1095 }
1090 1096
1091 // The cache may be gone when we return from the callback. 1097 // The cache may be gone when we return from the callback.
1092 if (!item->DoCallback(result, backend)) 1098 if (!item->DoCallback(result, backend))
1093 item->NotifyTransaction(result, NULL); 1099 item->NotifyTransaction(result, NULL);
1094 } 1100 }
1095 1101
1096 } // namespace net 1102 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_cache.h ('k') | net/http/http_cache_transaction.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698