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 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 HttpCache* HttpCache::GetCache() { | 454 HttpCache* HttpCache::GetCache() { |
455 return this; | 455 return this; |
456 } | 456 } |
457 | 457 |
458 HttpNetworkSession* HttpCache::GetSession() { | 458 HttpNetworkSession* HttpCache::GetSession() { |
459 net::HttpNetworkLayer* network = | 459 net::HttpNetworkLayer* network = |
460 static_cast<net::HttpNetworkLayer*>(network_layer_.get()); | 460 static_cast<net::HttpNetworkLayer*>(network_layer_.get()); |
461 return network->GetSession(); | 461 return network->GetSession(); |
462 } | 462 } |
463 | 463 |
| 464 scoped_ptr<HttpTransactionFactory> |
| 465 HttpCache::SetHttpNetworkTransactionFactoryForTesting( |
| 466 scoped_ptr<HttpTransactionFactory> new_network_layer) { |
| 467 scoped_ptr<HttpTransactionFactory> old_network_layer(network_layer_.Pass()); |
| 468 network_layer_ = new_network_layer.Pass(); |
| 469 return old_network_layer.Pass(); |
| 470 } |
| 471 |
464 //----------------------------------------------------------------------------- | 472 //----------------------------------------------------------------------------- |
465 | 473 |
466 int HttpCache::CreateBackend(disk_cache::Backend** backend, | 474 int HttpCache::CreateBackend(disk_cache::Backend** backend, |
467 const net::CompletionCallback& callback) { | 475 const net::CompletionCallback& callback) { |
468 if (!backend_factory_.get()) | 476 if (!backend_factory_.get()) |
469 return ERR_FAILED; | 477 return ERR_FAILED; |
470 | 478 |
471 building_backend_ = true; | 479 building_backend_ = true; |
472 | 480 |
473 scoped_ptr<WorkItem> item(new WorkItem(WI_CREATE_BACKEND, NULL, callback, | 481 scoped_ptr<WorkItem> item(new WorkItem(WI_CREATE_BACKEND, NULL, callback, |
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1159 building_backend_ = false; | 1167 building_backend_ = false; |
1160 DeletePendingOp(pending_op); | 1168 DeletePendingOp(pending_op); |
1161 } | 1169 } |
1162 | 1170 |
1163 // The cache may be gone when we return from the callback. | 1171 // The cache may be gone when we return from the callback. |
1164 if (!item->DoCallback(result, disk_cache_.get())) | 1172 if (!item->DoCallback(result, disk_cache_.get())) |
1165 item->NotifyTransaction(result, NULL); | 1173 item->NotifyTransaction(result, NULL); |
1166 } | 1174 } |
1167 | 1175 |
1168 } // namespace net | 1176 } // namespace net |
OLD | NEW |