| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_PROVIDER_HOST_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ |
| 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 // object is tied to the lifetime of its document in the renderer process. | 38 // object is tied to the lifetime of its document in the renderer process. |
| 39 // This class holds service worker state that is scoped to an individual | 39 // This class holds service worker state that is scoped to an individual |
| 40 // document. | 40 // document. |
| 41 // | 41 // |
| 42 // Note this class can also host a running service worker, in which | 42 // Note this class can also host a running service worker, in which |
| 43 // case it will observe resource loads made directly by the service worker. | 43 // case it will observe resource loads made directly by the service worker. |
| 44 class CONTENT_EXPORT ServiceWorkerProviderHost | 44 class CONTENT_EXPORT ServiceWorkerProviderHost |
| 45 : public NON_EXPORTED_BASE(ServiceWorkerRegistration::Listener), | 45 : public NON_EXPORTED_BASE(ServiceWorkerRegistration::Listener), |
| 46 public base::SupportsWeakPtr<ServiceWorkerProviderHost> { | 46 public base::SupportsWeakPtr<ServiceWorkerProviderHost> { |
| 47 public: | 47 public: |
| 48 using FocusCallback = base::Callback<void(bool)>; | |
| 49 using GetClientInfoCallback = | 48 using GetClientInfoCallback = |
| 50 base::Callback<void(const ServiceWorkerClientInfo&)>; | 49 base::Callback<void(const ServiceWorkerClientInfo&)>; |
| 51 | 50 |
| 52 // If |render_frame_id| is MSG_ROUTING_NONE, this provider host works for the | 51 // If |render_frame_id| is MSG_ROUTING_NONE, this provider host works for the |
| 53 // worker context. | 52 // worker context. |
| 54 ServiceWorkerProviderHost(int render_process_id, | 53 ServiceWorkerProviderHost(int render_process_id, |
| 55 int render_frame_id, | 54 int render_frame_id, |
| 56 int provider_id, | 55 int provider_id, |
| 57 base::WeakPtr<ServiceWorkerContextCore> context, | 56 base::WeakPtr<ServiceWorkerContextCore> context, |
| 58 ServiceWorkerDispatcherHost* dispatcher_host); | 57 ServiceWorkerDispatcherHost* dispatcher_host); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 // Returns true if the context referred to by this host (i.e. |context_|) is | 135 // Returns true if the context referred to by this host (i.e. |context_|) is |
| 137 // still alive. | 136 // still alive. |
| 138 bool IsContextAlive(); | 137 bool IsContextAlive(); |
| 139 | 138 |
| 140 // Dispatches message event to the document. | 139 // Dispatches message event to the document. |
| 141 void PostMessage(const base::string16& message, | 140 void PostMessage(const base::string16& message, |
| 142 const std::vector<int>& sent_message_port_ids); | 141 const std::vector<int>& sent_message_port_ids); |
| 143 | 142 |
| 144 // Activates the WebContents associated with | 143 // Activates the WebContents associated with |
| 145 // { render_process_id_, render_frame_id_ }. | 144 // { render_process_id_, render_frame_id_ }. |
| 146 // Runs the |callback| with the result in parameter describing whether the | 145 // Runs the |callback| with the updated ServiceWorkerClientInfo in parameter. |
| 147 // focusing action was successful. | 146 void Focus(const GetClientInfoCallback& callback); |
| 148 void Focus(const FocusCallback& callback); | |
| 149 | 147 |
| 150 // Asks the renderer to send back the document information. | 148 // Asks the renderer to send back the document information. |
| 151 void GetClientInfo(const GetClientInfoCallback& callback) const; | 149 void GetClientInfo(const GetClientInfoCallback& callback) const; |
| 152 | 150 |
| 153 // Adds reference of this host's process to the |pattern|, the reference will | 151 // Adds reference of this host's process to the |pattern|, the reference will |
| 154 // be removed in destructor. | 152 // be removed in destructor. |
| 155 void AddScopedProcessReferenceToPattern(const GURL& pattern); | 153 void AddScopedProcessReferenceToPattern(const GURL& pattern); |
| 156 | 154 |
| 157 // |registration| claims the document to be controlled. | 155 // |registration| claims the document to be controlled. |
| 158 void ClaimedByRegistration(ServiceWorkerRegistration* registration); | 156 void ClaimedByRegistration(ServiceWorkerRegistration* registration); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 bool is_claiming_; | 226 bool is_claiming_; |
| 229 | 227 |
| 230 std::vector<base::Closure> queued_events_; | 228 std::vector<base::Closure> queued_events_; |
| 231 | 229 |
| 232 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHost); | 230 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHost); |
| 233 }; | 231 }; |
| 234 | 232 |
| 235 } // namespace content | 233 } // namespace content |
| 236 | 234 |
| 237 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ | 235 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ |
| OLD | NEW |