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/disk_cache/backend_impl.h" | 5 #include "net/disk_cache/backend_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 10 matching lines...) Expand all Loading... | |
21 #include "base/threading/thread_restrictions.h" | 21 #include "base/threading/thread_restrictions.h" |
22 #include "base/time.h" | 22 #include "base/time.h" |
23 #include "base/timer.h" | 23 #include "base/timer.h" |
24 #include "net/base/net_errors.h" | 24 #include "net/base/net_errors.h" |
25 #include "net/disk_cache/cache_util.h" | 25 #include "net/disk_cache/cache_util.h" |
26 #include "net/disk_cache/entry_impl.h" | 26 #include "net/disk_cache/entry_impl.h" |
27 #include "net/disk_cache/errors.h" | 27 #include "net/disk_cache/errors.h" |
28 #include "net/disk_cache/experiments.h" | 28 #include "net/disk_cache/experiments.h" |
29 #include "net/disk_cache/file.h" | 29 #include "net/disk_cache/file.h" |
30 #include "net/disk_cache/mem_backend_impl.h" | 30 #include "net/disk_cache/mem_backend_impl.h" |
31 #include "net/disk_cache/very_simple/very_simple_backend_impl.h" | |
31 | 32 |
32 // This has to be defined before including histogram_macros.h from this file. | 33 // This has to be defined before including histogram_macros.h from this file. |
33 #define NET_DISK_CACHE_BACKEND_IMPL_CC_ | 34 #define NET_DISK_CACHE_BACKEND_IMPL_CC_ |
34 #include "net/disk_cache/histogram_macros.h" | 35 #include "net/disk_cache/histogram_macros.h" |
35 | 36 |
36 using base::Time; | 37 using base::Time; |
37 using base::TimeDelta; | 38 using base::TimeDelta; |
38 using base::TimeTicks; | 39 using base::TimeTicks; |
39 | 40 |
40 namespace { | 41 namespace { |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
259 bool force, base::MessageLoopProxy* thread, | 260 bool force, base::MessageLoopProxy* thread, |
260 net::NetLog* net_log, Backend** backend, | 261 net::NetLog* net_log, Backend** backend, |
261 const net::CompletionCallback& callback) { | 262 const net::CompletionCallback& callback) { |
262 DCHECK(!callback.is_null()); | 263 DCHECK(!callback.is_null()); |
263 if (type == net::MEMORY_CACHE) { | 264 if (type == net::MEMORY_CACHE) { |
264 *backend = MemBackendImpl::CreateBackend(max_bytes, net_log); | 265 *backend = MemBackendImpl::CreateBackend(max_bytes, net_log); |
265 return *backend ? net::OK : net::ERR_FAILED; | 266 return *backend ? net::OK : net::ERR_FAILED; |
266 } | 267 } |
267 DCHECK(thread); | 268 DCHECK(thread); |
268 | 269 |
270 #if defined(USE_VERY_SIMPLE_BACKEND) | |
271 return VerySimpleBackendImpl::BackendFactory(path). | |
pasko-google - do not use
2013/02/05 21:20:33
This discards logic of the CacheCreator that, whet
gavinp
2013/02/08 23:17:51
I think this is a good idea. And I think that this
| |
272 CreateBackend(net_log, backend, callback); | |
rvargas (doing something else)
2013/02/06 03:28:40
- Why is this split in two? (build factory + Creat
gavinp
2013/02/08 23:17:51
Done.
| |
273 #else | |
269 return BackendImpl::CreateBackend(path, force, max_bytes, type, kNone, thread, | 274 return BackendImpl::CreateBackend(path, force, max_bytes, type, kNone, thread, |
270 net_log, backend, callback); | 275 net_log, backend, callback); |
276 #endif | |
271 } | 277 } |
272 | 278 |
273 // Returns the preferred maximum number of bytes for the cache given the | 279 // Returns the preferred maximum number of bytes for the cache given the |
274 // number of available bytes. | 280 // number of available bytes. |
275 int PreferedCacheSize(int64 available) { | 281 int PreferedCacheSize(int64 available) { |
276 // Return 80% of the available space if there is not enough space to use | 282 // Return 80% of the available space if there is not enough space to use |
277 // kDefaultCacheSize. | 283 // kDefaultCacheSize. |
278 if (available < kDefaultCacheSize * 10 / 8) | 284 if (available < kDefaultCacheSize * 10 / 8) |
279 return static_cast<int32>(available * 8 / 10); | 285 return static_cast<int32>(available * 8 / 10); |
280 | 286 |
(...skipping 1955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2236 if (total_memory > kMaxBuffersSize || total_memory <= 0) | 2242 if (total_memory > kMaxBuffersSize || total_memory <= 0) |
2237 total_memory = kMaxBuffersSize; | 2243 total_memory = kMaxBuffersSize; |
2238 | 2244 |
2239 done = true; | 2245 done = true; |
2240 } | 2246 } |
2241 | 2247 |
2242 return static_cast<int>(total_memory); | 2248 return static_cast<int>(total_memory); |
2243 } | 2249 } |
2244 | 2250 |
2245 } // namespace disk_cache | 2251 } // namespace disk_cache |
OLD | NEW |