| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_CACHE_STORAGE_CACHE_STORAGE_DISPATCHER_HOST_H_ | 5 #ifndef CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_DISPATCHER_HOST_H_ |
| 6 #define CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_DISPATCHER_HOST_H_ | 6 #define CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_DISPATCHER_HOST_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // BrowserMessageFilter implementation | 34 // BrowserMessageFilter implementation |
| 35 void OnDestruct() const override; | 35 void OnDestruct() const override; |
| 36 bool OnMessageReceived(const IPC::Message& message) override; | 36 bool OnMessageReceived(const IPC::Message& message) override; |
| 37 | 37 |
| 38 private: | 38 private: |
| 39 // Friends to allow OnDestruct() delegation | 39 // Friends to allow OnDestruct() delegation |
| 40 friend class BrowserThread; | 40 friend class BrowserThread; |
| 41 friend class base::DeleteHelper<CacheStorageDispatcherHost>; | 41 friend class base::DeleteHelper<CacheStorageDispatcherHost>; |
| 42 | 42 |
| 43 typedef int32_t CacheID; // TODO(jkarlin): Bump to 64 bit. | 43 typedef int32_t CacheID; // TODO(jkarlin): Bump to 64 bit. |
| 44 typedef std::map<CacheID, scoped_refptr<CacheStorageCache>> IDToCacheMap; | 44 typedef std::map<CacheID, std::unique_ptr<CacheStorageCacheHandle>> |
| 45 IDToCacheMap; |
| 45 typedef std::map<std::string, std::list<storage::BlobDataHandle>> | 46 typedef std::map<std::string, std::list<storage::BlobDataHandle>> |
| 46 UUIDToBlobDataHandleList; | 47 UUIDToBlobDataHandleList; |
| 47 | 48 |
| 48 ~CacheStorageDispatcherHost() override; | 49 ~CacheStorageDispatcherHost() override; |
| 49 | 50 |
| 50 // Called by Init() on IO thread. | 51 // Called by Init() on IO thread. |
| 51 void CreateCacheListener(CacheStorageContextImpl* context); | 52 void CreateCacheListener(CacheStorageContextImpl* context); |
| 52 | 53 |
| 53 // The message receiver functions for the CacheStorage API: | 54 // The message receiver functions for the CacheStorage API: |
| 54 void OnCacheStorageHas(int thread_id, | 55 void OnCacheStorageHas(int thread_id, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 int cache_id, | 89 int cache_id, |
| 89 const std::vector<CacheStorageBatchOperation>& operations); | 90 const std::vector<CacheStorageBatchOperation>& operations); |
| 90 void OnCacheClosed(int cache_id); | 91 void OnCacheClosed(int cache_id); |
| 91 void OnBlobDataHandled(const std::string& uuid); | 92 void OnBlobDataHandled(const std::string& uuid); |
| 92 | 93 |
| 93 // CacheStorageManager callbacks | 94 // CacheStorageManager callbacks |
| 94 void OnCacheStorageHasCallback(int thread_id, | 95 void OnCacheStorageHasCallback(int thread_id, |
| 95 int request_id, | 96 int request_id, |
| 96 bool has_cache, | 97 bool has_cache, |
| 97 CacheStorageError error); | 98 CacheStorageError error); |
| 98 void OnCacheStorageOpenCallback(int thread_id, | 99 void OnCacheStorageOpenCallback( |
| 99 int request_id, | 100 int thread_id, |
| 100 scoped_refptr<CacheStorageCache> cache, | 101 int request_id, |
| 101 CacheStorageError error); | 102 std::unique_ptr<CacheStorageCacheHandle> cache_handle, |
| 103 CacheStorageError error); |
| 102 void OnCacheStorageDeleteCallback(int thread_id, | 104 void OnCacheStorageDeleteCallback(int thread_id, |
| 103 int request_id, | 105 int request_id, |
| 104 bool deleted, | 106 bool deleted, |
| 105 CacheStorageError error); | 107 CacheStorageError error); |
| 106 void OnCacheStorageKeysCallback(int thread_id, | 108 void OnCacheStorageKeysCallback(int thread_id, |
| 107 int request_id, | 109 int request_id, |
| 108 const std::vector<std::string>& strings, | 110 const std::vector<std::string>& strings, |
| 109 CacheStorageError error); | 111 CacheStorageError error); |
| 110 void OnCacheStorageMatchCallback( | 112 void OnCacheStorageMatchCallback( |
| 111 int thread_id, | 113 int thread_id, |
| 112 int request_id, | 114 int request_id, |
| 113 CacheStorageError error, | 115 CacheStorageError error, |
| 114 std::unique_ptr<ServiceWorkerResponse> response, | 116 std::unique_ptr<ServiceWorkerResponse> response, |
| 115 std::unique_ptr<storage::BlobDataHandle> blob_data_handle); | 117 std::unique_ptr<storage::BlobDataHandle> blob_data_handle); |
| 116 | 118 |
| 117 // Cache callbacks. | 119 // Cache callbacks. |
| 118 void OnCacheMatchCallback( | 120 void OnCacheMatchCallback( |
| 119 int thread_id, | 121 int thread_id, |
| 120 int request_id, | 122 int request_id, |
| 121 scoped_refptr<CacheStorageCache> cache, | 123 std::unique_ptr<CacheStorageCacheHandle> cache_handle, |
| 122 CacheStorageError error, | 124 CacheStorageError error, |
| 123 std::unique_ptr<ServiceWorkerResponse> response, | 125 std::unique_ptr<ServiceWorkerResponse> response, |
| 124 std::unique_ptr<storage::BlobDataHandle> blob_data_handle); | 126 std::unique_ptr<storage::BlobDataHandle> blob_data_handle); |
| 125 void OnCacheMatchAllCallbackAdapter( | 127 void OnCacheMatchAllCallbackAdapter( |
| 126 int thread_id, | 128 int thread_id, |
| 127 int request_id, | 129 int request_id, |
| 128 scoped_refptr<CacheStorageCache> cache, | 130 std::unique_ptr<CacheStorageCacheHandle> cache_handle, |
| 129 CacheStorageError error, | 131 CacheStorageError error, |
| 130 std::unique_ptr<ServiceWorkerResponse> response, | 132 std::unique_ptr<ServiceWorkerResponse> response, |
| 131 std::unique_ptr<storage::BlobDataHandle> blob_data_handle); | 133 std::unique_ptr<storage::BlobDataHandle> blob_data_handle); |
| 132 void OnCacheMatchAllCallback( | 134 void OnCacheMatchAllCallback( |
| 133 int thread_id, | 135 int thread_id, |
| 134 int request_id, | 136 int request_id, |
| 135 scoped_refptr<CacheStorageCache> cache, | 137 std::unique_ptr<CacheStorageCacheHandle> cache_handle, |
| 136 CacheStorageError error, | 138 CacheStorageError error, |
| 137 std::unique_ptr<std::vector<ServiceWorkerResponse>> responses, | 139 std::unique_ptr<std::vector<ServiceWorkerResponse>> responses, |
| 138 std::unique_ptr<CacheStorageCache::BlobDataHandles> blob_data_handles); | 140 std::unique_ptr<CacheStorageCache::BlobDataHandles> blob_data_handles); |
| 139 void OnCacheMatchAll(int thread_id, | 141 void OnCacheMatchAll(int thread_id, |
| 140 int request_id, | 142 int request_id, |
| 141 int cache_id, | 143 int cache_id, |
| 142 const ServiceWorkerFetchRequest& request, | 144 const ServiceWorkerFetchRequest& request, |
| 143 const CacheStorageCacheQueryParams& match_params); | 145 const CacheStorageCacheQueryParams& match_params); |
| 144 void OnCacheKeysCallback( | 146 void OnCacheKeysCallback( |
| 145 int thread_id, | 147 int thread_id, |
| 146 int request_id, | 148 int request_id, |
| 147 scoped_refptr<CacheStorageCache> cache, | 149 std::unique_ptr<CacheStorageCacheHandle> cache_handle, |
| 148 CacheStorageError error, | 150 CacheStorageError error, |
| 149 std::unique_ptr<CacheStorageCache::Requests> requests); | 151 std::unique_ptr<CacheStorageCache::Requests> requests); |
| 150 void OnCacheBatchCallback(int thread_id, | 152 void OnCacheBatchCallback( |
| 151 int request_id, | 153 int thread_id, |
| 152 scoped_refptr<CacheStorageCache> cache, | 154 int request_id, |
| 153 CacheStorageError error); | 155 std::unique_ptr<CacheStorageCacheHandle> cache_handle, |
| 156 CacheStorageError error); |
| 154 | 157 |
| 155 // Hangs onto a scoped_refptr for the cache if it isn't already doing so. | 158 // Hangs onto a cache handle. Returns a unique cache_id. Call |
| 156 // Returns a unique cache_id. Call DropCacheReference when the client is done | 159 // DropCacheReference when the reference is no longer needed. |
| 157 // with this cache. | 160 CacheID StoreCacheReference( |
| 158 CacheID StoreCacheReference(scoped_refptr<CacheStorageCache> cache); | 161 std::unique_ptr<CacheStorageCacheHandle> cache_handle); |
| 159 void DropCacheReference(CacheID cache_id); | 162 void DropCacheReference(CacheID cache_id); |
| 160 | 163 |
| 161 // Stores blob handles while waiting for acknowledgement of receipt from the | 164 // Stores blob handles while waiting for acknowledgement of receipt from the |
| 162 // renderer. | 165 // renderer. |
| 163 void StoreBlobDataHandle(const storage::BlobDataHandle& blob_data_handle); | 166 void StoreBlobDataHandle(const storage::BlobDataHandle& blob_data_handle); |
| 164 void DropBlobDataHandle(const std::string& uuid); | 167 void DropBlobDataHandle(const std::string& uuid); |
| 165 | 168 |
| 166 IDToCacheMap id_to_cache_map_; | 169 IDToCacheMap id_to_cache_map_; |
| 167 CacheID next_cache_id_ = 0; | 170 CacheID next_cache_id_ = 0; |
| 168 | 171 |
| 169 UUIDToBlobDataHandleList blob_handle_store_; | 172 UUIDToBlobDataHandleList blob_handle_store_; |
| 170 | 173 |
| 171 scoped_refptr<CacheStorageContextImpl> context_; | 174 scoped_refptr<CacheStorageContextImpl> context_; |
| 172 | 175 |
| 173 DISALLOW_COPY_AND_ASSIGN(CacheStorageDispatcherHost); | 176 DISALLOW_COPY_AND_ASSIGN(CacheStorageDispatcherHost); |
| 174 }; | 177 }; |
| 175 | 178 |
| 176 } // namespace content | 179 } // namespace content |
| 177 | 180 |
| 178 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_DISPATCHER_HOST_H_ | 181 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_DISPATCHER_HOST_H_ |
| OLD | NEW |