Chromium Code Reviews| 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 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 #include "base/threading/worker_pool.h" | 28 #include "base/threading/worker_pool.h" |
| 29 #include "base/time/default_clock.h" | 29 #include "base/time/default_clock.h" |
| 30 #include "base/time/time.h" | 30 #include "base/time/time.h" |
| 31 #include "net/base/cache_type.h" | 31 #include "net/base/cache_type.h" |
| 32 #include "net/base/io_buffer.h" | 32 #include "net/base/io_buffer.h" |
| 33 #include "net/base/load_flags.h" | 33 #include "net/base/load_flags.h" |
| 34 #include "net/base/net_errors.h" | 34 #include "net/base/net_errors.h" |
| 35 #include "net/base/upload_data_stream.h" | 35 #include "net/base/upload_data_stream.h" |
| 36 #include "net/disk_cache/disk_cache.h" | 36 #include "net/disk_cache/disk_cache.h" |
| 37 #include "net/http/disk_cache_based_quic_server_info.h" | 37 #include "net/http/disk_cache_based_quic_server_info.h" |
| 38 #include "net/http/http_cache_lookup_manager.h" | |
| 38 #include "net/http/http_cache_transaction.h" | 39 #include "net/http/http_cache_transaction.h" |
| 39 #include "net/http/http_network_layer.h" | 40 #include "net/http/http_network_layer.h" |
| 40 #include "net/http/http_network_session.h" | 41 #include "net/http/http_network_session.h" |
| 41 #include "net/http/http_request_info.h" | 42 #include "net/http/http_request_info.h" |
| 42 #include "net/http/http_response_headers.h" | 43 #include "net/http/http_response_headers.h" |
| 43 #include "net/http/http_response_info.h" | 44 #include "net/http/http_response_info.h" |
| 44 #include "net/http/http_util.h" | 45 #include "net/http/http_util.h" |
| 45 #include "net/log/net_log_with_source.h" | 46 #include "net/log/net_log_with_source.h" |
| 46 #include "net/quic/chromium/quic_server_info.h" | 47 #include "net/quic/chromium/quic_server_info.h" |
| 47 | 48 |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 311 bypass_lock_for_test_(false), | 312 bypass_lock_for_test_(false), |
| 312 fail_conditionalization_for_test_(false), | 313 fail_conditionalization_for_test_(false), |
| 313 mode_(NORMAL), | 314 mode_(NORMAL), |
| 314 network_layer_(std::move(network_layer)), | 315 network_layer_(std::move(network_layer)), |
| 315 clock_(new base::DefaultClock()), | 316 clock_(new base::DefaultClock()), |
| 316 weak_factory_(this) { | 317 weak_factory_(this) { |
| 317 HttpNetworkSession* session = network_layer_->GetSession(); | 318 HttpNetworkSession* session = network_layer_->GetSession(); |
| 318 // Session may be NULL in unittests. | 319 // Session may be NULL in unittests. |
| 319 // TODO(mmenke): Seems like tests could be changed to provide a session, | 320 // TODO(mmenke): Seems like tests could be changed to provide a session, |
| 320 // rather than having logic only used in unit tests here. | 321 // rather than having logic only used in unit tests here. |
| 321 if (session) { | 322 if (session) { |
|
Ryan Hamilton
2017/02/16 15:15:07
nit: as long as you're here:
if (!session)
retu
Zhongyi Shi
2017/02/19 20:19:53
Done.
| |
| 322 net_log_ = session->net_log(); | 323 net_log_ = session->net_log(); |
| 323 if (is_main_cache && | 324 if (!is_main_cache) |
| 324 !session->quic_stream_factory()->has_quic_server_info_factory()) { | 325 return; |
| 326 | |
| 327 session->SetServerPushDelegate( | |
| 328 base::MakeUnique<HttpCacheLookupManager>(this)); | |
| 329 | |
| 330 if (!session->quic_stream_factory()->has_quic_server_info_factory()) { | |
| 325 // QuicStreamFactory takes ownership of QuicServerInfoFactoryAdaptor. | 331 // QuicStreamFactory takes ownership of QuicServerInfoFactoryAdaptor. |
| 326 session->quic_stream_factory()->set_quic_server_info_factory( | 332 session->quic_stream_factory()->set_quic_server_info_factory( |
| 327 new QuicServerInfoFactoryAdaptor(this)); | 333 new QuicServerInfoFactoryAdaptor(this)); |
| 328 } | 334 } |
| 329 } | 335 } |
| 330 } | 336 } |
| 331 | 337 |
| 332 HttpCache::~HttpCache() { | 338 HttpCache::~HttpCache() { |
| 333 // Transactions should see an invalid cache after this point; otherwise they | 339 // Transactions should see an invalid cache after this point; otherwise they |
| 334 // could see an inconsistent object (half destroyed). | 340 // could see an inconsistent object (half destroyed). |
| (...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1156 building_backend_ = false; | 1162 building_backend_ = false; |
| 1157 DeletePendingOp(pending_op); | 1163 DeletePendingOp(pending_op); |
| 1158 } | 1164 } |
| 1159 | 1165 |
| 1160 // The cache may be gone when we return from the callback. | 1166 // The cache may be gone when we return from the callback. |
| 1161 if (!item->DoCallback(result, disk_cache_.get())) | 1167 if (!item->DoCallback(result, disk_cache_.get())) |
| 1162 item->NotifyTransaction(result, NULL); | 1168 item->NotifyTransaction(result, NULL); |
| 1163 } | 1169 } |
| 1164 | 1170 |
| 1165 } // namespace net | 1171 } // namespace net |
| OLD | NEW |