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

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

Issue 1599143002: Remove CertCacheTrial (DiskBasedCertCache). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: crbug.com doesn't like trailing slashes Created 4 years, 11 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
« no previous file with comments | « net/http/http_cache.h ('k') | net/http/http_cache_transaction.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 16 matching lines...) Expand all
27 #include "base/thread_task_runner_handle.h" 27 #include "base/thread_task_runner_handle.h"
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_based_cert_cache.h"
38 #include "net/http/disk_cache_based_quic_server_info.h" 37 #include "net/http/disk_cache_based_quic_server_info.h"
39 #include "net/http/http_cache_transaction.h" 38 #include "net/http/http_cache_transaction.h"
40 #include "net/http/http_network_layer.h" 39 #include "net/http/http_network_layer.h"
41 #include "net/http/http_network_session.h" 40 #include "net/http/http_network_session.h"
42 #include "net/http/http_request_info.h" 41 #include "net/http/http_request_info.h"
43 #include "net/http/http_response_headers.h" 42 #include "net/http/http_response_headers.h"
44 #include "net/http/http_response_info.h" 43 #include "net/http/http_response_info.h"
45 #include "net/http/http_util.h" 44 #include "net/http/http_util.h"
46 #include "net/quic/crypto/quic_server_info.h" 45 #include "net/quic/crypto/quic_server_info.h"
47 46
48 #if defined(OS_POSIX) 47 #if defined(OS_POSIX)
49 #include <unistd.h> 48 #include <unistd.h>
50 #endif 49 #endif
51 50
52 namespace {
53
54 bool UseCertCache() {
55 return base::FieldTrialList::FindFullName("CertCacheTrial") ==
56 "ExperimentGroup";
57 }
58
59 } // namespace
60
61 namespace net { 51 namespace net {
62 52
63 HttpCache::DefaultBackend::DefaultBackend( 53 HttpCache::DefaultBackend::DefaultBackend(
64 CacheType type, 54 CacheType type,
65 BackendType backend_type, 55 BackendType backend_type,
66 const base::FilePath& path, 56 const base::FilePath& path,
67 int max_bytes, 57 int max_bytes,
68 const scoped_refptr<base::SingleThreadTaskRunner>& thread) 58 const scoped_refptr<base::SingleThreadTaskRunner>& thread)
69 : type_(type), 59 : type_(type),
70 backend_type_(backend_type), 60 backend_type_(backend_type),
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 entry->pending_queue.clear(); 337 entry->pending_queue.clear();
348 entry->readers.clear(); 338 entry->readers.clear();
349 entry->writer = NULL; 339 entry->writer = NULL;
350 DeactivateEntry(entry); 340 DeactivateEntry(entry);
351 } 341 }
352 342
353 STLDeleteElements(&doomed_entries_); 343 STLDeleteElements(&doomed_entries_);
354 344
355 // Before deleting pending_ops_, we have to make sure that the disk cache is 345 // Before deleting pending_ops_, we have to make sure that the disk cache is
356 // done with said operations, or it will attempt to use deleted data. 346 // done with said operations, or it will attempt to use deleted data.
357 cert_cache_.reset();
358 disk_cache_.reset(); 347 disk_cache_.reset();
359 348
360 PendingOpsMap::iterator pending_it = pending_ops_.begin(); 349 PendingOpsMap::iterator pending_it = pending_ops_.begin();
361 for (; pending_it != pending_ops_.end(); ++pending_it) { 350 for (; pending_it != pending_ops_.end(); ++pending_it) {
362 // We are not notifying the transactions about the cache going away, even 351 // We are not notifying the transactions about the cache going away, even
363 // though they are waiting for a callback that will never fire. 352 // though they are waiting for a callback that will never fire.
364 PendingOp* pending_op = pending_it->second; 353 PendingOp* pending_op = pending_it->second;
365 delete pending_op->writer; 354 delete pending_op->writer;
366 bool delete_pending_op = true; 355 bool delete_pending_op = true;
367 if (building_backend_) { 356 if (building_backend_) {
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 // We don't need the callback anymore. 1126 // We don't need the callback anymore.
1138 pending_op->callback.Reset(); 1127 pending_op->callback.Reset();
1139 1128
1140 if (backend_factory_.get()) { 1129 if (backend_factory_.get()) {
1141 // We may end up calling OnBackendCreated multiple times if we have pending 1130 // We may end up calling OnBackendCreated multiple times if we have pending
1142 // work items. The first call saves the backend and releases the factory, 1131 // work items. The first call saves the backend and releases the factory,
1143 // and the last call clears building_backend_. 1132 // and the last call clears building_backend_.
1144 backend_factory_.reset(); // Reclaim memory. 1133 backend_factory_.reset(); // Reclaim memory.
1145 if (result == OK) { 1134 if (result == OK) {
1146 disk_cache_ = std::move(pending_op->backend); 1135 disk_cache_ = std::move(pending_op->backend);
1147 if (UseCertCache())
1148 cert_cache_.reset(new DiskBasedCertCache(disk_cache_.get()));
1149 } 1136 }
1150 } 1137 }
1151 1138
1152 if (!pending_op->pending_queue.empty()) { 1139 if (!pending_op->pending_queue.empty()) {
1153 WorkItem* pending_item = pending_op->pending_queue.front(); 1140 WorkItem* pending_item = pending_op->pending_queue.front();
1154 pending_op->pending_queue.pop_front(); 1141 pending_op->pending_queue.pop_front();
1155 DCHECK_EQ(WI_CREATE_BACKEND, pending_item->operation()); 1142 DCHECK_EQ(WI_CREATE_BACKEND, pending_item->operation());
1156 1143
1157 // We want to process a single callback at a time, because the cache may 1144 // We want to process a single callback at a time, because the cache may
1158 // go away from the callback. 1145 // go away from the callback.
1159 pending_op->writer = pending_item; 1146 pending_op->writer = pending_item;
1160 1147
1161 base::ThreadTaskRunnerHandle::Get()->PostTask( 1148 base::ThreadTaskRunnerHandle::Get()->PostTask(
1162 FROM_HERE, base::Bind(&HttpCache::OnBackendCreated, GetWeakPtr(), 1149 FROM_HERE, base::Bind(&HttpCache::OnBackendCreated, GetWeakPtr(),
1163 result, pending_op)); 1150 result, pending_op));
1164 } else { 1151 } else {
1165 building_backend_ = false; 1152 building_backend_ = false;
1166 DeletePendingOp(pending_op); 1153 DeletePendingOp(pending_op);
1167 } 1154 }
1168 1155
1169 // The cache may be gone when we return from the callback. 1156 // The cache may be gone when we return from the callback.
1170 if (!item->DoCallback(result, disk_cache_.get())) 1157 if (!item->DoCallback(result, disk_cache_.get()))
1171 item->NotifyTransaction(result, NULL); 1158 item->NotifyTransaction(result, NULL);
1172 } 1159 }
1173 1160
1174 } // namespace net 1161 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_cache.h ('k') | net/http/http_cache_transaction.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698