| 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 #ifndef CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_DISPATCHER_
H_ | 5 #ifndef CONTENT_RENDERER_CACHE_STORAGE_CACHE_STORAGE_DISPATCHER_H_ |
| 6 #define CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_DISPATCHER_
H_ | 6 #define CONTENT_RENDERER_CACHE_STORAGE_CACHE_STORAGE_DISPATCHER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/id_map.h" | 10 #include "base/id_map.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "content/child/worker_task_runner.h" | 15 #include "content/child/worker_task_runner.h" |
| 16 #include "content/public/renderer/render_process_observer.h" | 16 #include "content/public/renderer/render_process_observer.h" |
| 17 #include "third_party/WebKit/public/platform/WebServiceWorkerCache.h" | 17 #include "third_party/WebKit/public/platform/WebServiceWorkerCache.h" |
| 18 #include "third_party/WebKit/public/platform/WebServiceWorkerCacheError.h" | 18 #include "third_party/WebKit/public/platform/WebServiceWorkerCacheError.h" |
| 19 #include "third_party/WebKit/public/platform/WebServiceWorkerCacheStorage.h" | 19 #include "third_party/WebKit/public/platform/WebServiceWorkerCacheStorage.h" |
| 20 | 20 |
| 21 namespace content { | 21 namespace content { |
| 22 | 22 |
| 23 class ServiceWorkerScriptContext; | |
| 24 class ThreadSafeSender; | 23 class ThreadSafeSender; |
| 25 struct ServiceWorkerFetchRequest; | 24 struct ServiceWorkerFetchRequest; |
| 26 struct ServiceWorkerResponse; | 25 struct ServiceWorkerResponse; |
| 27 | 26 |
| 28 // Handle the Cache Storage messaging for this context thread. The | 27 // Handle the Cache Storage messaging for this context thread. The |
| 29 // main thread and each worker thread have their own instances. | 28 // main thread and each worker thread have their own instances. |
| 30 class ServiceWorkerCacheStorageDispatcher : public WorkerTaskRunner::Observer { | 29 class CacheStorageDispatcher : public WorkerTaskRunner::Observer { |
| 31 public: | 30 public: |
| 32 explicit ServiceWorkerCacheStorageDispatcher( | 31 explicit CacheStorageDispatcher(ThreadSafeSender* thread_safe_sender); |
| 33 ThreadSafeSender* thread_safe_sender); | 32 ~CacheStorageDispatcher() override; |
| 34 ~ServiceWorkerCacheStorageDispatcher() override; | |
| 35 | 33 |
| 36 // |thread_safe_sender| needs to be passed in because if the call leads to | 34 // |thread_safe_sender| needs to be passed in because if the call leads to |
| 37 // construction it will be needed. | 35 // construction it will be needed. |
| 38 static ServiceWorkerCacheStorageDispatcher* ThreadSpecificInstance( | 36 static CacheStorageDispatcher* ThreadSpecificInstance( |
| 39 ThreadSafeSender* thread_safe_sender); | 37 ThreadSafeSender* thread_safe_sender); |
| 40 | 38 |
| 41 // WorkerTaskRunner::Observer implementation. | 39 // WorkerTaskRunner::Observer implementation. |
| 42 void OnWorkerRunLoopStopped() override; | 40 void OnWorkerRunLoopStopped() override; |
| 43 | 41 |
| 44 bool Send(IPC::Message* msg); | 42 bool Send(IPC::Message* msg); |
| 45 | 43 |
| 46 // ServiceWorkerScriptContext calls our OnMessageReceived directly. | 44 // ServiceWorkerScriptContext calls our OnMessageReceived directly. |
| 47 bool OnMessageReceived(const IPC::Message& message); | 45 bool OnMessageReceived(const IPC::Message& message); |
| 48 | 46 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 MatchCallbacksMap cache_match_callbacks_; | 205 MatchCallbacksMap cache_match_callbacks_; |
| 208 WithResponsesCallbacksMap cache_match_all_callbacks_; | 206 WithResponsesCallbacksMap cache_match_all_callbacks_; |
| 209 WithRequestsCallbacksMap cache_keys_callbacks_; | 207 WithRequestsCallbacksMap cache_keys_callbacks_; |
| 210 WithResponsesCallbacksMap cache_batch_callbacks_; | 208 WithResponsesCallbacksMap cache_batch_callbacks_; |
| 211 | 209 |
| 212 TimeMap cache_match_times_; | 210 TimeMap cache_match_times_; |
| 213 TimeMap cache_match_all_times_; | 211 TimeMap cache_match_all_times_; |
| 214 TimeMap cache_keys_times_; | 212 TimeMap cache_keys_times_; |
| 215 TimeMap cache_batch_times_; | 213 TimeMap cache_batch_times_; |
| 216 | 214 |
| 217 base::WeakPtrFactory<ServiceWorkerCacheStorageDispatcher> weak_factory_; | 215 base::WeakPtrFactory<CacheStorageDispatcher> weak_factory_; |
| 218 | 216 |
| 219 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCacheStorageDispatcher); | 217 DISALLOW_COPY_AND_ASSIGN(CacheStorageDispatcher); |
| 220 }; | 218 }; |
| 221 | 219 |
| 222 } // namespace content | 220 } // namespace content |
| 223 | 221 |
| 224 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_DISPATCH
ER_H_ | 222 #endif // CONTENT_RENDERER_CACHE_STORAGE_CACHE_STORAGE_DISPATCHER_H_ |
| OLD | NEW |