OLD | NEW |
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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 int buf_len) { | 402 int buf_len) { |
403 if (!buf_len) | 403 if (!buf_len) |
404 return; | 404 return; |
405 | 405 |
406 // Do lazy initialization of disk cache if needed. | 406 // Do lazy initialization of disk cache if needed. |
407 if (!disk_cache_.get()) { | 407 if (!disk_cache_.get()) { |
408 // We don't care about the result. | 408 // We don't care about the result. |
409 CreateBackend(NULL, net::CompletionCallback()); | 409 CreateBackend(NULL, net::CompletionCallback()); |
410 } | 410 } |
411 | 411 |
412 HttpCache::Transaction* trans = new HttpCache::Transaction(this); | 412 HttpCache::Transaction* trans = new HttpCache::Transaction(this, NULL); |
413 MetadataWriter* writer = new MetadataWriter(trans); | 413 MetadataWriter* writer = new MetadataWriter(trans); |
414 | 414 |
415 // The writer will self destruct when done. | 415 // The writer will self destruct when done. |
416 writer->Write(url, expected_response_time, buf, buf_len); | 416 writer->Write(url, expected_response_time, buf, buf_len); |
417 } | 417 } |
418 | 418 |
419 void HttpCache::CloseAllConnections() { | 419 void HttpCache::CloseAllConnections() { |
420 net::HttpNetworkLayer* network = | 420 net::HttpNetworkLayer* network = |
421 static_cast<net::HttpNetworkLayer*>(network_layer_.get()); | 421 static_cast<net::HttpNetworkLayer*>(network_layer_.get()); |
422 HttpNetworkSession* session = network->GetSession(); | 422 HttpNetworkSession* session = network->GetSession(); |
(...skipping 14 matching lines...) Expand all Loading... |
437 if (!disk_cache_.get()) | 437 if (!disk_cache_.get()) |
438 return; | 438 return; |
439 | 439 |
440 HttpRequestInfo request_info; | 440 HttpRequestInfo request_info; |
441 request_info.url = url; | 441 request_info.url = url; |
442 request_info.method = http_method; | 442 request_info.method = http_method; |
443 std::string key = GenerateCacheKey(&request_info); | 443 std::string key = GenerateCacheKey(&request_info); |
444 disk_cache_->OnExternalCacheHit(key); | 444 disk_cache_->OnExternalCacheHit(key); |
445 } | 445 } |
446 | 446 |
447 int HttpCache::CreateTransaction(scoped_ptr<HttpTransaction>* trans) { | 447 int HttpCache::CreateTransaction(scoped_ptr<HttpTransaction>* trans, |
| 448 HttpTransactionDelegate* delegate) { |
448 // Do lazy initialization of disk cache if needed. | 449 // Do lazy initialization of disk cache if needed. |
449 if (!disk_cache_.get()) { | 450 if (!disk_cache_.get()) { |
450 // We don't care about the result. | 451 // We don't care about the result. |
451 CreateBackend(NULL, net::CompletionCallback()); | 452 CreateBackend(NULL, net::CompletionCallback()); |
452 } | 453 } |
453 | 454 |
454 trans->reset(new HttpCache::Transaction(this)); | 455 trans->reset(new HttpCache::Transaction(this, delegate)); |
455 return OK; | 456 return OK; |
456 } | 457 } |
457 | 458 |
458 HttpCache* HttpCache::GetCache() { | 459 HttpCache* HttpCache::GetCache() { |
459 return this; | 460 return this; |
460 } | 461 } |
461 | 462 |
462 HttpNetworkSession* HttpCache::GetSession() { | 463 HttpNetworkSession* HttpCache::GetSession() { |
463 net::HttpNetworkLayer* network = | 464 net::HttpNetworkLayer* network = |
464 static_cast<net::HttpNetworkLayer*>(network_layer_.get()); | 465 static_cast<net::HttpNetworkLayer*>(network_layer_.get()); |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1146 building_backend_ = false; | 1147 building_backend_ = false; |
1147 DeletePendingOp(pending_op); | 1148 DeletePendingOp(pending_op); |
1148 } | 1149 } |
1149 | 1150 |
1150 // The cache may be gone when we return from the callback. | 1151 // The cache may be gone when we return from the callback. |
1151 if (!item->DoCallback(result, backend)) | 1152 if (!item->DoCallback(result, backend)) |
1152 item->NotifyTransaction(result, NULL); | 1153 item->NotifyTransaction(result, NULL); |
1153 } | 1154 } |
1154 | 1155 |
1155 } // namespace net | 1156 } // namespace net |
OLD | NEW |