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

Side by Side Diff: content/browser/service_worker/service_worker_cache_storage.h

Issue 651983002: [ServiceWorkerCache] Implement storage::QuotaClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from PS 10+11 Created 6 years, 2 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
OLDNEW
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 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 CACHE_STORAGE_ERROR_STORAGE, 42 CACHE_STORAGE_ERROR_STORAGE,
43 CACHE_STORAGE_ERROR_CLOSING 43 CACHE_STORAGE_ERROR_CLOSING
44 }; 44 };
45 typedef std::vector<std::string> StringVector; 45 typedef std::vector<std::string> StringVector;
46 typedef base::Callback<void(bool, CacheStorageError)> BoolAndErrorCallback; 46 typedef base::Callback<void(bool, CacheStorageError)> BoolAndErrorCallback;
47 typedef base::Callback<void(const scoped_refptr<ServiceWorkerCache>&, 47 typedef base::Callback<void(const scoped_refptr<ServiceWorkerCache>&,
48 CacheStorageError)> CacheAndErrorCallback; 48 CacheStorageError)> CacheAndErrorCallback;
49 typedef base::Callback<void(const StringVector&, CacheStorageError)> 49 typedef base::Callback<void(const StringVector&, CacheStorageError)>
50 StringsAndErrorCallback; 50 StringsAndErrorCallback;
51 51
52 static const char kIndexFileName[];
53
52 ServiceWorkerCacheStorage( 54 ServiceWorkerCacheStorage(
53 const base::FilePath& origin_path, 55 const base::FilePath& origin_path,
54 bool memory_only, 56 bool memory_only,
55 base::SequencedTaskRunner* cache_task_runner, 57 base::SequencedTaskRunner* cache_task_runner,
56 net::URLRequestContext* request_context, 58 net::URLRequestContext* request_context,
57 base::WeakPtr<storage::BlobStorageContext> blob_context); 59 base::WeakPtr<storage::BlobStorageContext> blob_context,
60 const GURL& origin);
58 61
62 // Any unfinished asynchronous operations may not complete or call their
63 // callbacks.
59 virtual ~ServiceWorkerCacheStorage(); 64 virtual ~ServiceWorkerCacheStorage();
60 65
61 // Create a ServiceWorkerCache if it doesn't already exist and call the 66 // Create a ServiceWorkerCache if it doesn't already exist and call the
62 // callback with the cache. If it already 67 // callback with the cache. If it already
63 // exists the callback is called with CACHE_STORAGE_ERROR_EXISTS. 68 // exists the callback is called with CACHE_STORAGE_ERROR_EXISTS.
64 void CreateCache(const std::string& cache_name, 69 void CreateCache(const std::string& cache_name,
65 const CacheAndErrorCallback& callback); 70 const CacheAndErrorCallback& callback);
66 71
67 // Get the cache for the given key. If not found returns 72 // Get the cache for the given key. If not found returns
68 // CACHE_STORAGE_ERROR_NOT_FOUND. 73 // CACHE_STORAGE_ERROR_NOT_FOUND.
(...skipping 12 matching lines...) Expand all
81 // Deletes the cache if it exists. If it doesn't exist, 86 // Deletes the cache if it exists. If it doesn't exist,
82 // CACHE_STORAGE_ERROR_NOT_FOUND is returned. 87 // CACHE_STORAGE_ERROR_NOT_FOUND is returned.
83 void DeleteCache(const std::string& cache_name, 88 void DeleteCache(const std::string& cache_name,
84 const BoolAndErrorCallback& callback); 89 const BoolAndErrorCallback& callback);
85 90
86 // Calls the callback with a vector of cache names (keys) available. 91 // Calls the callback with a vector of cache names (keys) available.
87 void EnumerateCaches(const StringsAndErrorCallback& callback); 92 void EnumerateCaches(const StringsAndErrorCallback& callback);
88 93
89 // TODO(jkarlin): Add match() function. 94 // TODO(jkarlin): Add match() function.
90 95
96 void CloseAllCaches();
97
91 private: 98 private:
92 class MemoryLoader; 99 class MemoryLoader;
93 class SimpleCacheLoader; 100 class SimpleCacheLoader;
94 class CacheLoader; 101 class CacheLoader;
95 102
96 typedef std::map<std::string, base::WeakPtr<ServiceWorkerCache> > CacheMap; 103 typedef std::map<std::string, base::WeakPtr<ServiceWorkerCache> > CacheMap;
97 104
98 // Return a ServiceWorkerCache for the given name if the name is known. If the 105 // Return a ServiceWorkerCache for the given name if the name is known. If the
99 // ServiceWorkerCache has been deleted, creates a new one. 106 // ServiceWorkerCache has been deleted, creates a new one.
100 scoped_refptr<ServiceWorkerCache> GetLoadedCache( 107 scoped_refptr<ServiceWorkerCache> GetLoadedCache(
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 scoped_ptr<CacheLoader> cache_loader_; 158 scoped_ptr<CacheLoader> cache_loader_;
152 159
153 base::WeakPtrFactory<ServiceWorkerCacheStorage> weak_factory_; 160 base::WeakPtrFactory<ServiceWorkerCacheStorage> weak_factory_;
154 161
155 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCacheStorage); 162 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCacheStorage);
156 }; 163 };
157 164
158 } // namespace content 165 } // namespace content
159 166
160 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_H_ 167 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698