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