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_SERVICE_WORKER_SERVICE_WORKER_NAVIGATION_HANDLE_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_NAVIGATION_HANDLE_H_ |
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_NAVIGATION_HANDLE_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_NAVIGATION_HANDLE_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 | 10 |
11 namespace content { | 11 namespace content { |
12 | 12 |
| 13 class ResourceMessageFilter; |
13 class ServiceWorkerContextWrapper; | 14 class ServiceWorkerContextWrapper; |
14 class ServiceWorkerNavigationHandleCore; | 15 class ServiceWorkerNavigationHandleCore; |
15 | 16 |
16 // This class is used to manage the lifetime of ServiceWorkerProviderHosts | 17 // This class is used to manage the lifetime of ServiceWorkerProviderHosts |
17 // created during navigation. This is a UI thread class, with a pendant class | 18 // created during navigation. This is a UI thread class, with a pendant class |
18 // on the IO thread, the ServiceWorkerNavigationHandleCore. | 19 // on the IO thread, the ServiceWorkerNavigationHandleCore. |
19 // | 20 // |
20 // The lifetime of the ServiceWorkerNavigationHandle, the | 21 // The lifetime of the ServiceWorkerNavigationHandle, the |
21 // ServiceWorkerNavigationHandleCore and the ServiceWorkerProviderHost are the | 22 // ServiceWorkerNavigationHandleCore and the ServiceWorkerProviderHost are the |
22 // following : | 23 // following : |
(...skipping 22 matching lines...) Expand all Loading... |
45 // ServiceWorkerProviderHost from the ServiceWorkerNavigationHandleCore and | 46 // ServiceWorkerProviderHost from the ServiceWorkerNavigationHandleCore and |
46 // put it in the ServiceWorkerContextCore map of ServiceWorkerProviderHosts. | 47 // put it in the ServiceWorkerContextCore map of ServiceWorkerProviderHosts. |
47 // | 48 // |
48 // 7) When the navigation finishes, the ServiceWorkerNavigationHandle is | 49 // 7) When the navigation finishes, the ServiceWorkerNavigationHandle is |
49 // destroyed. The destructor of the ServiceWorkerNavigationHandle posts a | 50 // destroyed. The destructor of the ServiceWorkerNavigationHandle posts a |
50 // task to destroy the ServiceWorkerNavigationHandleCore on the IO thread. | 51 // task to destroy the ServiceWorkerNavigationHandleCore on the IO thread. |
51 // This in turn leads to the destruction of an unclaimed | 52 // This in turn leads to the destruction of an unclaimed |
52 // ServiceWorkerProviderHost. | 53 // ServiceWorkerProviderHost. |
53 class ServiceWorkerNavigationHandle { | 54 class ServiceWorkerNavigationHandle { |
54 public: | 55 public: |
55 explicit ServiceWorkerNavigationHandle( | 56 ServiceWorkerNavigationHandle(ServiceWorkerContextWrapper* context_wrapper, |
56 ServiceWorkerContextWrapper* context_wrapper); | 57 ResourceMessageFilter* resource_message_filter); |
57 ~ServiceWorkerNavigationHandle(); | 58 ~ServiceWorkerNavigationHandle(); |
58 | 59 |
59 int service_worker_provider_host_id() const { | 60 int service_worker_provider_host_id() const { |
60 return service_worker_provider_host_id_; | 61 return service_worker_provider_host_id_; |
61 } | 62 } |
62 ServiceWorkerNavigationHandleCore* core() const { return core_; } | 63 ServiceWorkerNavigationHandleCore* core() const { return core_; } |
63 | 64 |
64 // Called after a ServiceWorkerProviderHost with id | 65 // Called after a ServiceWorkerProviderHost with id |
65 // |service_worker_provider_host_id| was pre-created for the navigation on the | 66 // |service_worker_provider_host_id| was pre-created for the navigation on the |
66 // IO thread. | 67 // IO thread. |
67 void DidCreateServiceWorkerProviderHost(int service_worker_provider_host_id); | 68 void DidCreateServiceWorkerProviderHost(int service_worker_provider_host_id); |
68 | 69 |
69 private: | 70 private: |
70 int service_worker_provider_host_id_; | 71 int service_worker_provider_host_id_; |
71 ServiceWorkerNavigationHandleCore* core_; | 72 ServiceWorkerNavigationHandleCore* core_; |
72 base::WeakPtrFactory<ServiceWorkerNavigationHandle> weak_factory_; | 73 base::WeakPtrFactory<ServiceWorkerNavigationHandle> weak_factory_; |
73 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerNavigationHandle); | 74 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerNavigationHandle); |
74 }; | 75 }; |
75 | 76 |
76 } // namespace content | 77 } // namespace content |
77 | 78 |
78 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_NAVIGATION_HANDLE_H_ | 79 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_NAVIGATION_HANDLE_H_ |
OLD | NEW |