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

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: Nit 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's id. If it already 67 // callback with the cache's id. 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 id for the given key. If not found returns 72 // Get the cache id for the given key. If not found returns
68 // CACHE_STORAGE_ERROR_NOT_FOUND. 73 // CACHE_STORAGE_ERROR_NOT_FOUND.
69 void GetCache(const std::string& cache_name, 74 void GetCache(const std::string& cache_name,
70 const CacheAndErrorCallback& callback); 75 const CacheAndErrorCallback& callback);
71 76
72 // Calls the callback with whether or not the cache exists. 77 // Calls the callback with whether or not the cache exists.
73 void HasCache(const std::string& cache_name, 78 void HasCache(const std::string& cache_name,
74 const BoolAndErrorCallback& callback); 79 const BoolAndErrorCallback& callback);
75 80
76 // Deletes the cache if it exists. If it doesn't exist, 81 // Deletes the cache if it exists. If it doesn't exist,
77 // CACHE_STORAGE_ERROR_NOT_FOUND is returned. 82 // CACHE_STORAGE_ERROR_NOT_FOUND is returned.
78 void DeleteCache(const std::string& cache_name, 83 void DeleteCache(const std::string& cache_name,
79 const BoolAndErrorCallback& callback); 84 const BoolAndErrorCallback& callback);
80 85
81 // Calls the callback with a vector of cache names (keys) available. 86 // Calls the callback with a vector of cache names (keys) available.
82 void EnumerateCaches(const StringsAndErrorCallback& callback); 87 void EnumerateCaches(const StringsAndErrorCallback& callback);
83 88
84 // TODO(jkarlin): Add match() function. 89 // TODO(jkarlin): Add match() function.
85 90
91 void CloseAllCaches();
92
86 private: 93 private:
87 class MemoryLoader; 94 class MemoryLoader;
88 class SimpleCacheLoader; 95 class SimpleCacheLoader;
89 class CacheLoader; 96 class CacheLoader;
90 97
91 typedef std::map<std::string, base::WeakPtr<ServiceWorkerCache> > CacheMap; 98 typedef std::map<std::string, base::WeakPtr<ServiceWorkerCache> > CacheMap;
92 99
93 // Return a ServiceWorkerCache for the given name if the name is known. If the 100 // Return a ServiceWorkerCache for the given name if the name is known. If the
94 // ServiceWorkerCache has been deleted, creates a new one. 101 // ServiceWorkerCache has been deleted, creates a new one.
95 scoped_refptr<ServiceWorkerCache> GetLoadedCache( 102 scoped_refptr<ServiceWorkerCache> GetLoadedCache(
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 scoped_ptr<CacheLoader> cache_loader_; 153 scoped_ptr<CacheLoader> cache_loader_;
147 154
148 base::WeakPtrFactory<ServiceWorkerCacheStorage> weak_factory_; 155 base::WeakPtrFactory<ServiceWorkerCacheStorage> weak_factory_;
149 156
150 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCacheStorage); 157 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCacheStorage);
151 }; 158 };
152 159
153 } // namespace content 160 } // namespace content
154 161
155 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_H_ 162 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698