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 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 // |this| is deleted. | 447 // |this| is deleted. |
448 } | 448 } |
449 | 449 |
450 //----------------------------------------------------------------------------- | 450 //----------------------------------------------------------------------------- |
451 HttpCache::HttpCache(const net::HttpNetworkSession::Params& params, | 451 HttpCache::HttpCache(const net::HttpNetworkSession::Params& params, |
452 BackendFactory* backend_factory) | 452 BackendFactory* backend_factory) |
453 : net_log_(params.net_log), | 453 : net_log_(params.net_log), |
454 backend_factory_(backend_factory), | 454 backend_factory_(backend_factory), |
455 building_backend_(false), | 455 building_backend_(false), |
456 bypass_lock_for_test_(false), | 456 bypass_lock_for_test_(false), |
| 457 fail_conditionalization_for_test_(false), |
457 use_stale_while_revalidate_(params.use_stale_while_revalidate), | 458 use_stale_while_revalidate_(params.use_stale_while_revalidate), |
458 mode_(NORMAL), | 459 mode_(NORMAL), |
459 network_layer_(new HttpNetworkLayer(new HttpNetworkSession(params))), | 460 network_layer_(new HttpNetworkLayer(new HttpNetworkSession(params))), |
460 weak_factory_(this) { | 461 weak_factory_(this) { |
461 SetupQuicServerInfoFactory(network_layer_->GetSession()); | 462 SetupQuicServerInfoFactory(network_layer_->GetSession()); |
462 } | 463 } |
463 | 464 |
464 | 465 |
465 // This call doesn't change the shared |session|'s QuicServerInfoFactory because | 466 // This call doesn't change the shared |session|'s QuicServerInfoFactory because |
466 // |session| is shared. | 467 // |session| is shared. |
467 HttpCache::HttpCache(HttpNetworkSession* session, | 468 HttpCache::HttpCache(HttpNetworkSession* session, |
468 BackendFactory* backend_factory) | 469 BackendFactory* backend_factory) |
469 : net_log_(session->net_log()), | 470 : net_log_(session->net_log()), |
470 backend_factory_(backend_factory), | 471 backend_factory_(backend_factory), |
471 building_backend_(false), | 472 building_backend_(false), |
472 bypass_lock_for_test_(false), | 473 bypass_lock_for_test_(false), |
| 474 fail_conditionalization_for_test_(false), |
473 use_stale_while_revalidate_(session->params().use_stale_while_revalidate), | 475 use_stale_while_revalidate_(session->params().use_stale_while_revalidate), |
474 mode_(NORMAL), | 476 mode_(NORMAL), |
475 network_layer_(new HttpNetworkLayer(session)), | 477 network_layer_(new HttpNetworkLayer(session)), |
476 weak_factory_(this) { | 478 weak_factory_(this) { |
477 } | 479 } |
478 | 480 |
479 HttpCache::HttpCache(HttpTransactionFactory* network_layer, | 481 HttpCache::HttpCache(HttpTransactionFactory* network_layer, |
480 NetLog* net_log, | 482 NetLog* net_log, |
481 BackendFactory* backend_factory) | 483 BackendFactory* backend_factory) |
482 : net_log_(net_log), | 484 : net_log_(net_log), |
483 backend_factory_(backend_factory), | 485 backend_factory_(backend_factory), |
484 building_backend_(false), | 486 building_backend_(false), |
485 bypass_lock_for_test_(false), | 487 bypass_lock_for_test_(false), |
| 488 fail_conditionalization_for_test_(false), |
486 use_stale_while_revalidate_(false), | 489 use_stale_while_revalidate_(false), |
487 mode_(NORMAL), | 490 mode_(NORMAL), |
488 network_layer_(network_layer), | 491 network_layer_(network_layer), |
489 weak_factory_(this) { | 492 weak_factory_(this) { |
490 SetupQuicServerInfoFactory(network_layer_->GetSession()); | 493 SetupQuicServerInfoFactory(network_layer_->GetSession()); |
491 HttpNetworkSession* session = network_layer_->GetSession(); | 494 HttpNetworkSession* session = network_layer_->GetSession(); |
492 if (session) | 495 if (session) |
493 use_stale_while_revalidate_ = session->params().use_stale_while_revalidate; | 496 use_stale_while_revalidate_ = session->params().use_stale_while_revalidate; |
494 } | 497 } |
495 | 498 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 // Do lazy initialization of disk cache if needed. | 627 // Do lazy initialization of disk cache if needed. |
625 if (!disk_cache_.get()) { | 628 if (!disk_cache_.get()) { |
626 // We don't care about the result. | 629 // We don't care about the result. |
627 CreateBackend(NULL, net::CompletionCallback()); | 630 CreateBackend(NULL, net::CompletionCallback()); |
628 } | 631 } |
629 | 632 |
630 HttpCache::Transaction* transaction = | 633 HttpCache::Transaction* transaction = |
631 new HttpCache::Transaction(priority, this); | 634 new HttpCache::Transaction(priority, this); |
632 if (bypass_lock_for_test_) | 635 if (bypass_lock_for_test_) |
633 transaction->BypassLockForTest(); | 636 transaction->BypassLockForTest(); |
| 637 if (fail_conditionalization_for_test_) |
| 638 transaction->FailConditionalizationForTest(); |
634 | 639 |
635 trans->reset(transaction); | 640 trans->reset(transaction); |
636 return OK; | 641 return OK; |
637 } | 642 } |
638 | 643 |
639 HttpCache* HttpCache::GetCache() { | 644 HttpCache* HttpCache::GetCache() { |
640 return this; | 645 return this; |
641 } | 646 } |
642 | 647 |
643 HttpNetworkSession* HttpCache::GetSession() { | 648 HttpNetworkSession* HttpCache::GetSession() { |
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1406 building_backend_ = false; | 1411 building_backend_ = false; |
1407 DeletePendingOp(pending_op); | 1412 DeletePendingOp(pending_op); |
1408 } | 1413 } |
1409 | 1414 |
1410 // The cache may be gone when we return from the callback. | 1415 // The cache may be gone when we return from the callback. |
1411 if (!item->DoCallback(result, disk_cache_.get())) | 1416 if (!item->DoCallback(result, disk_cache_.get())) |
1412 item->NotifyTransaction(result, NULL); | 1417 item->NotifyTransaction(result, NULL); |
1413 } | 1418 } |
1414 | 1419 |
1415 } // namespace net | 1420 } // namespace net |
OLD | NEW |