OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/cache_storage/cache_storage_cache.h" | 5 #include "content/browser/cache_storage/cache_storage_cache.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/barrier_closure.h" | 9 #include "base/barrier_closure.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/guid.h" | 11 #include "base/guid.h" |
| 12 #include "base/message_loop/message_loop_proxy.h" |
12 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
13 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
14 #include "content/browser/cache_storage/cache_storage.pb.h" | 15 #include "content/browser/cache_storage/cache_storage.pb.h" |
15 #include "content/browser/cache_storage/cache_storage_scheduler.h" | 16 #include "content/browser/cache_storage/cache_storage_scheduler.h" |
16 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
17 #include "content/public/common/referrer.h" | 18 #include "content/public/common/referrer.h" |
18 #include "net/base/completion_callback.h" | 19 #include "net/base/completion_callback.h" |
19 #include "net/base/io_buffer.h" | 20 #include "net/base/io_buffer.h" |
20 #include "net/base/net_errors.h" | 21 #include "net/base/net_errors.h" |
21 #include "net/disk_cache/disk_cache.h" | 22 #include "net/disk_cache/disk_cache.h" |
(...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1172 scoped_ptr<ScopedBackendPtr> backend_ptr(new ScopedBackendPtr()); | 1173 scoped_ptr<ScopedBackendPtr> backend_ptr(new ScopedBackendPtr()); |
1173 | 1174 |
1174 // Temporary pointer so that backend_ptr can be Pass()'d in Bind below. | 1175 // Temporary pointer so that backend_ptr can be Pass()'d in Bind below. |
1175 ScopedBackendPtr* backend = backend_ptr.get(); | 1176 ScopedBackendPtr* backend = backend_ptr.get(); |
1176 | 1177 |
1177 net::CompletionCallback create_cache_callback = | 1178 net::CompletionCallback create_cache_callback = |
1178 base::Bind(&CacheStorageCache::CreateBackendDidCreate, | 1179 base::Bind(&CacheStorageCache::CreateBackendDidCreate, |
1179 weak_ptr_factory_.GetWeakPtr(), callback, | 1180 weak_ptr_factory_.GetWeakPtr(), callback, |
1180 base::Passed(backend_ptr.Pass())); | 1181 base::Passed(backend_ptr.Pass())); |
1181 | 1182 |
1182 // TODO(jkarlin): Use the cache task runner that ServiceWorkerCacheCore | 1183 // TODO(jkarlin): Use the cache MessageLoopProxy that ServiceWorkerCacheCore |
1183 // has for disk caches. | 1184 // has for disk caches. |
1184 int rv = disk_cache::CreateCacheBackend( | 1185 int rv = disk_cache::CreateCacheBackend( |
1185 cache_type, net::CACHE_BACKEND_SIMPLE, path_, kMaxCacheBytes, | 1186 cache_type, net::CACHE_BACKEND_SIMPLE, path_, kMaxCacheBytes, |
1186 false, /* force */ | 1187 false, /* force */ |
1187 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE).get(), | 1188 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE).get(), |
1188 NULL, backend, create_cache_callback); | 1189 NULL, backend, create_cache_callback); |
1189 if (rv != net::ERR_IO_PENDING) | 1190 if (rv != net::ERR_IO_PENDING) |
1190 create_cache_callback.Run(rv); | 1191 create_cache_callback.Run(rv); |
1191 } | 1192 } |
1192 | 1193 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1265 CacheStorageError error, | 1266 CacheStorageError error, |
1266 scoped_ptr<Requests> requests) { | 1267 scoped_ptr<Requests> requests) { |
1267 base::WeakPtr<CacheStorageCache> cache = weak_ptr_factory_.GetWeakPtr(); | 1268 base::WeakPtr<CacheStorageCache> cache = weak_ptr_factory_.GetWeakPtr(); |
1268 | 1269 |
1269 callback.Run(error, requests.Pass()); | 1270 callback.Run(error, requests.Pass()); |
1270 if (cache) | 1271 if (cache) |
1271 scheduler_->CompleteOperationAndRunNext(); | 1272 scheduler_->CompleteOperationAndRunNext(); |
1272 } | 1273 } |
1273 | 1274 |
1274 } // namespace content | 1275 } // namespace content |
OLD | NEW |