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_CLIENT_UTILS_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CLIENT_UTILS_H_ |
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CLIENT_UTILS_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CLIENT_UTILS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "content/browser/service_worker/service_worker_provider_host.h" |
13 #include "content/common/service_worker/service_worker_status_code.h" | 14 #include "content/common/service_worker/service_worker_status_code.h" |
14 | 15 |
15 class GURL; | 16 class GURL; |
16 | 17 |
17 namespace content { | 18 namespace content { |
18 | 19 |
19 class ServiceWorkerContextCore; | 20 class ServiceWorkerContextCore; |
20 class ServiceWorkerVersion; | 21 class ServiceWorkerVersion; |
21 struct ServiceWorkerClientInfo; | 22 struct ServiceWorkerClientInfo; |
22 struct ServiceWorkerClientQueryOptions; | 23 struct ServiceWorkerClientQueryOptions; |
23 | 24 |
24 namespace service_worker_client_utils { | 25 namespace service_worker_client_utils { |
25 | 26 |
26 using NavigationCallback = | 27 using NavigationCallback = |
27 base::Callback<void(ServiceWorkerStatusCode status, | 28 base::Callback<void(ServiceWorkerStatusCode status, |
28 const std::string& client_uuid, | |
29 const ServiceWorkerClientInfo& client_info)>; | 29 const ServiceWorkerClientInfo& client_info)>; |
30 using ServiceWorkerClients = std::vector<ServiceWorkerClientInfo>; | 30 using ServiceWorkerClients = std::vector<ServiceWorkerClientInfo>; |
31 using ClientsCallback = base::Callback<void(ServiceWorkerClients* clients)>; | 31 using ClientsCallback = base::Callback<void(ServiceWorkerClients* clients)>; |
32 | 32 |
33 // Opens a new window and navigates it to |url|. |callback| is called with the | 33 // Opens a new window and navigates it to |url|. |callback| is called with the |
34 // window's client information on completion. | 34 // window's client information on completion. |
35 void OpenWindow(const GURL& url, | 35 void OpenWindow(const GURL& url, |
36 const GURL& script_url, | 36 const GURL& script_url, |
37 int worker_process_id, | 37 int worker_process_id, |
38 const base::WeakPtr<ServiceWorkerContextCore>& context, | 38 const base::WeakPtr<ServiceWorkerContextCore>& context, |
39 const NavigationCallback& callback); | 39 const NavigationCallback& callback); |
40 | 40 |
41 // Navigates the client specified by |process_id| and |frame_id| to |url|. | 41 // Navigates the client specified by |process_id| and |frame_id| to |url|. |
42 // |callback| is called with the client information on completion. | 42 // |callback| is called with the client information on completion. |
43 void NavigateClient(const GURL& url, | 43 void NavigateClient(const GURL& url, |
44 const GURL& script_url, | 44 const GURL& script_url, |
45 int process_id, | 45 int process_id, |
46 int frame_id, | 46 int frame_id, |
47 const base::WeakPtr<ServiceWorkerContextCore>& context, | 47 const base::WeakPtr<ServiceWorkerContextCore>& context, |
48 const NavigationCallback& callback); | 48 const NavigationCallback& callback); |
49 | 49 |
| 50 // Gets a client matched by |client_uuid|. |callback| is called with the client |
| 51 // information on completion. |
| 52 void GetClient( |
| 53 const base::WeakPtr<ServiceWorkerVersion>& controller, |
| 54 const std::string& client_uuid, |
| 55 const base::WeakPtr<ServiceWorkerContextCore>& context, |
| 56 const ServiceWorkerProviderHost::GetClientInfoCallback& callback); |
| 57 |
50 // Collects clients matched with |options|. |callback| is called with the client | 58 // Collects clients matched with |options|. |callback| is called with the client |
51 // information sorted in MRU order (most recently focused order) on completion. | 59 // information sorted in MRU order (most recently focused order) on completion. |
52 void GetClients(const base::WeakPtr<ServiceWorkerVersion>& controller, | 60 void GetClients(const base::WeakPtr<ServiceWorkerVersion>& controller, |
53 const ServiceWorkerClientQueryOptions& options, | 61 const ServiceWorkerClientQueryOptions& options, |
54 const ClientsCallback& callback); | 62 const ClientsCallback& callback); |
55 | 63 |
56 } // namespace service_worker_client_utils | 64 } // namespace service_worker_client_utils |
57 | 65 |
58 } // namespace content | 66 } // namespace content |
59 | 67 |
60 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CLIENT_UTILS_H_ | 68 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CLIENT_UTILS_H_ |
OLD | NEW |