Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Side by Side Diff: content/browser/service_worker/service_worker_client_utils.h

Issue 1439333002: Service Worker: Add Clients.get(id) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use HTTP origins instead of HTTPS origins for layout tests Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/common/service_worker/service_worker_status_code.h" 13 #include "content/common/service_worker/service_worker_status_code.h"
14 14
15 class GURL; 15 class GURL;
16 16
17 namespace content { 17 namespace content {
18 18
19 class ServiceWorkerContextCore; 19 class ServiceWorkerContextCore;
20 class ServiceWorkerVersion; 20 class ServiceWorkerVersion;
21 struct ServiceWorkerClientInfo; 21 struct ServiceWorkerClientInfo;
22 struct ServiceWorkerClientQueryOptions; 22 struct ServiceWorkerClientQueryOptions;
23 23
24 namespace service_worker_client_utils { 24 namespace service_worker_client_utils {
25 25
26 using NavigationCallback = 26 using NavigationCallback =
27 base::Callback<void(ServiceWorkerStatusCode status, 27 base::Callback<void(ServiceWorkerStatusCode status,
28 const std::string& client_uuid, 28 const std::string& client_uuid,
29 const ServiceWorkerClientInfo& client_info)>; 29 const ServiceWorkerClientInfo& client_info)>;
30 using ClientCallback = base::Callback<void(const ServiceWorkerClientInfo&)>;
30 using ServiceWorkerClients = std::vector<ServiceWorkerClientInfo>; 31 using ServiceWorkerClients = std::vector<ServiceWorkerClientInfo>;
31 using ClientsCallback = base::Callback<void(ServiceWorkerClients* clients)>; 32 using ClientsCallback = base::Callback<void(ServiceWorkerClients* clients)>;
32 33
33 // Opens a new window and navigates it to |url|. |callback| is called with the 34 // Opens a new window and navigates it to |url|. |callback| is called with the
34 // window's client information on completion. 35 // window's client information on completion.
35 void OpenWindow(const GURL& url, 36 void OpenWindow(const GURL& url,
36 const GURL& script_url, 37 const GURL& script_url,
37 int worker_process_id, 38 int worker_process_id,
38 const base::WeakPtr<ServiceWorkerContextCore>& context, 39 const base::WeakPtr<ServiceWorkerContextCore>& context,
39 const NavigationCallback& callback); 40 const NavigationCallback& callback);
40 41
41 // Navigates the client specified by |process_id| and |frame_id| to |url|. 42 // Navigates the client specified by |process_id| and |frame_id| to |url|.
42 // |callback| is called with the client information on completion. 43 // |callback| is called with the client information on completion.
43 void NavigateClient(const GURL& url, 44 void NavigateClient(const GURL& url,
44 const GURL& script_url, 45 const GURL& script_url,
45 int process_id, 46 int process_id,
46 int frame_id, 47 int frame_id,
47 const base::WeakPtr<ServiceWorkerContextCore>& context, 48 const base::WeakPtr<ServiceWorkerContextCore>& context,
48 const NavigationCallback& callback); 49 const NavigationCallback& callback);
49 50
51 // Gets a client matched by |id|. |callback| is called with the client
52 // information on completion.
53 void GetClient(const base::WeakPtr<ServiceWorkerVersion>& controller,
54 const std::string& id,
nhiroki 2016/02/03 09:39:59 I'd prefer "client_uuid" to "id" because this clas
jungkees 2016/02/03 14:15:07 Agreed. Addressed.
55 const base::WeakPtr<ServiceWorkerContextCore>& context,
56 const ClientCallback& 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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698