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

Side by Side Diff: net/disk_cache/disk_cache.cc

Issue 2626173003: Calculate the size of all cache entries between two points in time. (Closed)
Patch Set: revert cache_storage_cache_unittest.cc Created 3 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/disk_cache/disk_cache.h ('k') | net/disk_cache/disk_cache_test_base.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 <utility> 5 #include <utility>
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 backend_type_(backend_type), 81 backend_type_(backend_type),
82 #if !defined(OS_ANDROID) 82 #if !defined(OS_ANDROID)
83 flags_(flags), 83 flags_(flags),
84 #endif 84 #endif
85 thread_(thread), 85 thread_(thread),
86 backend_(backend), 86 backend_(backend),
87 callback_(callback), 87 callback_(callback),
88 net_log_(net_log) { 88 net_log_(net_log) {
89 } 89 }
90 90
91 CacheCreator::~CacheCreator() { 91 CacheCreator::~CacheCreator() {}
92 }
93 92
94 int CacheCreator::Run() { 93 int CacheCreator::Run() {
95 #if defined(OS_ANDROID) 94 #if defined(OS_ANDROID)
96 static const bool kSimpleBackendIsDefault = true; 95 static const bool kSimpleBackendIsDefault = true;
97 #else 96 #else
98 static const bool kSimpleBackendIsDefault = false; 97 static const bool kSimpleBackendIsDefault = false;
99 #endif 98 #endif
100 if (backend_type_ == net::CACHE_BACKEND_SIMPLE || 99 if (backend_type_ == net::CACHE_BACKEND_SIMPLE ||
101 (backend_type_ == net::CACHE_BACKEND_DEFAULT && 100 (backend_type_ == net::CACHE_BACKEND_DEFAULT &&
102 kSimpleBackendIsDefault)) { 101 kSimpleBackendIsDefault)) {
103 disk_cache::SimpleBackendImpl* simple_cache = 102 disk_cache::SimpleBackendImpl* simple_cache =
104 new disk_cache::SimpleBackendImpl( 103 new disk_cache::SimpleBackendImpl(path_, max_bytes_, type_, thread_,
105 path_, max_bytes_, type_, thread_, net_log_); 104 net_log_);
106 created_cache_.reset(simple_cache); 105 created_cache_.reset(simple_cache);
107 return simple_cache->Init( 106 return simple_cache->Init(
108 base::Bind(&CacheCreator::OnIOComplete, base::Unretained(this))); 107 base::Bind(&CacheCreator::OnIOComplete, base::Unretained(this)));
109 } 108 }
110 109
111 // Avoid references to blockfile functions on Android to reduce binary size. 110 // Avoid references to blockfile functions on Android to reduce binary size.
112 #if defined(OS_ANDROID) 111 #if defined(OS_ANDROID)
113 return net::ERR_FAILED; 112 return net::ERR_FAILED;
114 #else 113 #else
115 disk_cache::BackendImpl* new_cache = 114 disk_cache::BackendImpl* new_cache =
116 new disk_cache::BackendImpl(path_, thread_, net_log_); 115 new disk_cache::BackendImpl(path_, thread_, net_log_);
117 created_cache_.reset(new_cache); 116 created_cache_.reset(new_cache);
118 new_cache->SetMaxSize(max_bytes_); 117 new_cache->SetMaxSize(max_bytes_);
119 new_cache->SetType(type_); 118 new_cache->SetType(type_);
120 new_cache->SetFlags(flags_); 119 new_cache->SetFlags(flags_);
121 int rv = new_cache->Init( 120 int rv = new_cache->Init(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 const scoped_refptr<base::SingleThreadTaskRunner>& thread, 168 const scoped_refptr<base::SingleThreadTaskRunner>& thread,
170 net::NetLog* net_log, 169 net::NetLog* net_log,
171 std::unique_ptr<Backend>* backend, 170 std::unique_ptr<Backend>* backend,
172 const net::CompletionCallback& callback) { 171 const net::CompletionCallback& callback) {
173 DCHECK(!callback.is_null()); 172 DCHECK(!callback.is_null());
174 if (type == net::MEMORY_CACHE) { 173 if (type == net::MEMORY_CACHE) {
175 *backend = disk_cache::MemBackendImpl::CreateBackend(max_bytes, net_log); 174 *backend = disk_cache::MemBackendImpl::CreateBackend(max_bytes, net_log);
176 return *backend ? net::OK : net::ERR_FAILED; 175 return *backend ? net::OK : net::ERR_FAILED;
177 } 176 }
178 DCHECK(thread.get()); 177 DCHECK(thread.get());
179 CacheCreator* creator = new CacheCreator(path, 178 CacheCreator* creator =
180 force, 179 new CacheCreator(path, force, max_bytes, type, backend_type, kNone,
181 max_bytes, 180 thread, net_log, backend, callback);
182 type,
183 backend_type,
184 kNone,
185 thread,
186 net_log,
187 backend,
188 callback);
189 return creator->Run(); 181 return creator->Run();
190 } 182 }
191 183
184 int Backend::CalculateSizeOfEntriesBetween(base::Time initial_time,
185 base::Time end_time,
186 const CompletionCallback& callback) {
187 return net::ERR_NOT_IMPLEMENTED;
188 }
189
192 } // namespace disk_cache 190 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/disk_cache.h ('k') | net/disk_cache/disk_cache_test_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698