| 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_RENDERER_SERVICE_WORKER_WEB_SERVICE_WORKER_CACHE_STORAGE_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_SERVICE_WORKER_WEB_SERVICE_WORKER_CACHE_STORAGE_IMPL_H_ |
| 6 #define CONTENT_RENDERER_SERVICE_WORKER_WEB_SERVICE_WORKER_CACHE_STORAGE_IMPL_H_ | 6 #define CONTENT_RENDERER_SERVICE_WORKER_WEB_SERVICE_WORKER_CACHE_STORAGE_IMPL_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 9 |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "content/child/thread_safe_sender.h" | 11 #include "content/child/thread_safe_sender.h" |
| 10 #include "third_party/WebKit/public/platform/WebString.h" | 12 #include "third_party/WebKit/public/platform/WebString.h" |
| 11 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerCache.h" | 13 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerCache.h" |
| 12 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerCacheError.h" | 14 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerCacheError.h" |
| 13 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerCacheStorage.h" | 15 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerCacheStorage.h" |
| 14 #include "url/origin.h" | 16 #include "url/origin.h" |
| 15 | 17 |
| 16 namespace content { | 18 namespace content { |
| 17 | 19 |
| 18 class CacheStorageDispatcher; | 20 class CacheStorageDispatcher; |
| 19 class ThreadSafeSender; | 21 class ThreadSafeSender; |
| 20 | 22 |
| 21 // This corresponds to an instance of the script-facing CacheStorage object. | 23 // This corresponds to an instance of the script-facing CacheStorage object. |
| 22 // One exists per script execution context (window, worker) and has an origin | 24 // One exists per script execution context (window, worker) and has an origin |
| 23 // which provides a namespace for the caches. Script calls to the CacheStorage | 25 // which provides a namespace for the caches. Script calls to the CacheStorage |
| 24 // object are routed through here to the (per-thread) dispatcher then on to | 26 // object are routed through here to the (per-thread) dispatcher then on to |
| 25 // the browser, with the origin added to the call parameters. Cache instances | 27 // the browser, with the origin added to the call parameters. Cache instances |
| 26 // returned by open() calls are minted by and implemented within the code of | 28 // returned by open() calls are minted by and implemented within the code of |
| 27 // the CacheStorageDispatcher, and include routing information. | 29 // the CacheStorageDispatcher, and include routing information. |
| 28 class WebServiceWorkerCacheStorageImpl | 30 class WebServiceWorkerCacheStorageImpl |
| 29 : public blink::WebServiceWorkerCacheStorage { | 31 : public blink::WebServiceWorkerCacheStorage { |
| 30 public: | 32 public: |
| 31 WebServiceWorkerCacheStorageImpl(ThreadSafeSender* thread_safe_sender, | 33 WebServiceWorkerCacheStorageImpl(ThreadSafeSender* thread_safe_sender, |
| 32 const url::Origin& origin); | 34 const url::Origin& origin); |
| 33 ~WebServiceWorkerCacheStorageImpl() override; | 35 ~WebServiceWorkerCacheStorageImpl() override; |
| 34 | 36 |
| 35 // From WebServiceWorkerCacheStorage: | 37 // From WebServiceWorkerCacheStorage: |
| 36 void dispatchHas(CacheStorageCallbacks* callbacks, | 38 void dispatchHas(std::unique_ptr<CacheStorageCallbacks> callbacks, |
| 37 const blink::WebString& cacheName) override; | 39 const blink::WebString& cacheName) override; |
| 38 void dispatchOpen(CacheStorageWithCacheCallbacks* callbacks, | 40 void dispatchOpen(std::unique_ptr<CacheStorageWithCacheCallbacks> callbacks, |
| 39 const blink::WebString& cacheName) override; | 41 const blink::WebString& cacheName) override; |
| 40 void dispatchDelete(CacheStorageCallbacks* callbacks, | 42 void dispatchDelete(std::unique_ptr<CacheStorageCallbacks> callbacks, |
| 41 const blink::WebString& cacheName) override; | 43 const blink::WebString& cacheName) override; |
| 42 void dispatchKeys(CacheStorageKeysCallbacks* callbacks) override; | 44 void dispatchKeys( |
| 45 std::unique_ptr<CacheStorageKeysCallbacks> callbacks) override; |
| 43 void dispatchMatch( | 46 void dispatchMatch( |
| 44 CacheStorageMatchCallbacks* callbacks, | 47 std::unique_ptr<CacheStorageMatchCallbacks> callbacks, |
| 45 const blink::WebServiceWorkerRequest& request, | 48 const blink::WebServiceWorkerRequest& request, |
| 46 const blink::WebServiceWorkerCache::QueryParams& query_params) override; | 49 const blink::WebServiceWorkerCache::QueryParams& query_params) override; |
| 47 | 50 |
| 48 private: | 51 private: |
| 49 // Helper to return the thread-specific dispatcher. | 52 // Helper to return the thread-specific dispatcher. |
| 50 CacheStorageDispatcher* GetDispatcher() const; | 53 CacheStorageDispatcher* GetDispatcher() const; |
| 51 | 54 |
| 52 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 55 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
| 53 const url::Origin origin_; | 56 const url::Origin origin_; |
| 54 | 57 |
| 55 DISALLOW_COPY_AND_ASSIGN(WebServiceWorkerCacheStorageImpl); | 58 DISALLOW_COPY_AND_ASSIGN(WebServiceWorkerCacheStorageImpl); |
| 56 }; | 59 }; |
| 57 | 60 |
| 58 } // namespace content | 61 } // namespace content |
| 59 | 62 |
| 60 #endif // CONTENT_RENDERER_SERVICE_WORKER_WEB_SERVICE_WORKER_CACHE_STORAGE_IMPL
_H_ | 63 #endif // CONTENT_RENDERER_SERVICE_WORKER_WEB_SERVICE_WORKER_CACHE_STORAGE_IMPL
_H_ |
| OLD | NEW |