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

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

Issue 2692813002: Server push cancellation: add a finch trial parameter (Closed)
Patch Set: sync with internal code Created 3 years, 10 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
OLDNEW
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
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
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)
322 net_log_ = session->net_log(); 323 return;
323 if (is_main_cache && 324
324 !session->quic_stream_factory()->has_quic_server_info_factory()) { 325 net_log_ = session->net_log();
325 // QuicStreamFactory takes ownership of QuicServerInfoFactoryAdaptor. 326 if (!is_main_cache)
326 session->quic_stream_factory()->set_quic_server_info_factory( 327 return;
327 new QuicServerInfoFactoryAdaptor(this)); 328
328 } 329 session->SetServerPushDelegate(
330 base::MakeUnique<HttpCacheLookupManager>(this));
331
332 if (!session->quic_stream_factory()->has_quic_server_info_factory()) {
333 // QuicStreamFactory takes ownership of QuicServerInfoFactoryAdaptor.
334 session->quic_stream_factory()->set_quic_server_info_factory(
335 new QuicServerInfoFactoryAdaptor(this));
329 } 336 }
330 } 337 }
331 338
332 HttpCache::~HttpCache() { 339 HttpCache::~HttpCache() {
333 // Transactions should see an invalid cache after this point; otherwise they 340 // Transactions should see an invalid cache after this point; otherwise they
334 // could see an inconsistent object (half destroyed). 341 // could see an inconsistent object (half destroyed).
335 weak_factory_.InvalidateWeakPtrs(); 342 weak_factory_.InvalidateWeakPtrs();
336 343
337 // If we have any active entries remaining, then we need to deactivate them. 344 // If we have any active entries remaining, then we need to deactivate them.
338 // We may have some pending calls to OnProcessPendingQueue, but since those 345 // We may have some pending calls to OnProcessPendingQueue, but since those
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 building_backend_ = false; 1163 building_backend_ = false;
1157 DeletePendingOp(pending_op); 1164 DeletePendingOp(pending_op);
1158 } 1165 }
1159 1166
1160 // The cache may be gone when we return from the callback. 1167 // The cache may be gone when we return from the callback.
1161 if (!item->DoCallback(result, disk_cache_.get())) 1168 if (!item->DoCallback(result, disk_cache_.get()))
1162 item->NotifyTransaction(result, NULL); 1169 item->NotifyTransaction(result, NULL);
1163 } 1170 }
1164 1171
1165 } // namespace net 1172 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698