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

Side by Side Diff: content/renderer/service_worker/service_worker_context_client.h

Issue 2352173004: Mojoify FetchEvent of Service Worker. (Closed)
Patch Set: incorporated dcheng's comment Created 4 years, 2 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 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_CONTEXT_CLIENT_H_ 5 #ifndef CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CLIENT_H_
6 #define CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CLIENT_H_ 6 #define CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CLIENT_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <map> 11 #include <map>
12 #include <memory> 12 #include <memory>
13 #include <string> 13 #include <string>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/callback.h" 16 #include "base/callback.h"
17 #include "base/id_map.h" 17 #include "base/id_map.h"
18 #include "base/macros.h" 18 #include "base/macros.h"
19 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
20 #include "base/strings/string16.h" 20 #include "base/strings/string16.h"
21 #include "base/time/time.h" 21 #include "base/time/time.h"
22 #include "content/child/webmessageportchannel_impl.h" 22 #include "content/child/webmessageportchannel_impl.h"
23 #include "content/common/service_worker/service_worker_status_code.h"
23 #include "content/common/service_worker/service_worker_types.h" 24 #include "content/common/service_worker/service_worker_types.h"
24 #include "ipc/ipc_listener.h" 25 #include "ipc/ipc_listener.h"
25 #include "services/shell/public/interfaces/interface_provider.mojom.h" 26 #include "services/shell/public/interfaces/interface_provider.mojom.h"
26 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" 27 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h"
27 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor kerError.h" 28 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor kerError.h"
28 #include "third_party/WebKit/public/platform/modules/serviceworker/service_worke r_event_status.mojom.h" 29 #include "third_party/WebKit/public/platform/modules/serviceworker/service_worke r_event_status.mojom.h"
29 #include "third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerCo ntextClient.h" 30 #include "third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerCo ntextClient.h"
30 #include "third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerCo ntextProxy.h" 31 #include "third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerCo ntextProxy.h"
31 #include "v8/include/v8.h" 32 #include "v8/include/v8.h"
32 33
(...skipping 27 matching lines...) Expand all
60 class WebServiceWorkerRegistrationImpl; 61 class WebServiceWorkerRegistrationImpl;
61 62
62 // This class provides access to/from an ServiceWorker's WorkerGlobalScope. 63 // This class provides access to/from an ServiceWorker's WorkerGlobalScope.
63 // Unless otherwise noted, all methods are called on the worker thread. 64 // Unless otherwise noted, all methods are called on the worker thread.
64 class ServiceWorkerContextClient 65 class ServiceWorkerContextClient
65 : public blink::WebServiceWorkerContextClient { 66 : public blink::WebServiceWorkerContextClient {
66 public: 67 public:
67 using SyncCallback = 68 using SyncCallback =
68 base::Callback<void(blink::mojom::ServiceWorkerEventStatus, 69 base::Callback<void(blink::mojom::ServiceWorkerEventStatus,
69 base::Time /* dispatch_event_time */)>; 70 base::Time /* dispatch_event_time */)>;
71 using FetchCallback =
72 base::Callback<void(ServiceWorkerStatusCode,
73 base::Time /* dispatch_event_time */)>;
70 74
71 // Returns a thread-specific client instance. This does NOT create a 75 // Returns a thread-specific client instance. This does NOT create a
72 // new instance. 76 // new instance.
73 static ServiceWorkerContextClient* ThreadSpecificInstance(); 77 static ServiceWorkerContextClient* ThreadSpecificInstance();
74 78
75 // Called on the main thread. 79 // Called on the main thread.
76 ServiceWorkerContextClient(int embedded_worker_id, 80 ServiceWorkerContextClient(int embedded_worker_id,
77 int64_t service_worker_version_id, 81 int64_t service_worker_version_id,
78 const GURL& service_worker_scope, 82 const GURL& service_worker_scope,
79 const GURL& script_url, 83 const GURL& script_url,
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 const blink::WebVector<blink::WebURL>& sub_scopes, 191 const blink::WebVector<blink::WebURL>& sub_scopes,
188 const blink::WebVector<blink::WebSecurityOrigin>& origins) override; 192 const blink::WebVector<blink::WebSecurityOrigin>& origins) override;
189 193
190 virtual void DispatchSyncEvent( 194 virtual void DispatchSyncEvent(
191 const std::string& tag, 195 const std::string& tag,
192 blink::WebServiceWorkerContextProxy::LastChanceOption last_chance, 196 blink::WebServiceWorkerContextProxy::LastChanceOption last_chance,
193 const SyncCallback& callback); 197 const SyncCallback& callback);
194 198
195 private: 199 private:
196 struct WorkerContextData; 200 struct WorkerContextData;
201 class FetchEventDispatcherImpl;
197 202
198 // Get routing_id for sending message to the ServiceWorkerVersion 203 // Get routing_id for sending message to the ServiceWorkerVersion
199 // in the browser process. 204 // in the browser process.
200 int GetRoutingID() const { return embedded_worker_id_; } 205 int GetRoutingID() const { return embedded_worker_id_; }
201 206
202 void Send(IPC::Message* message); 207 void Send(IPC::Message* message);
203 void SendWorkerStarted(); 208 void SendWorkerStarted();
204 void SetRegistrationInServiceWorkerGlobalScope( 209 void SetRegistrationInServiceWorkerGlobalScope(
205 const ServiceWorkerRegistrationObjectInfo& info, 210 const ServiceWorkerRegistrationObjectInfo& info,
206 const ServiceWorkerVersionAttributes& attrs); 211 const ServiceWorkerVersionAttributes& attrs);
207 212
208 void OnActivateEvent(int request_id); 213 void OnActivateEvent(int request_id);
209 void OnExtendableMessageEvent( 214 void OnExtendableMessageEvent(
210 int request_id, 215 int request_id,
211 const ServiceWorkerMsg_ExtendableMessageEvent_Params& params); 216 const ServiceWorkerMsg_ExtendableMessageEvent_Params& params);
212 void OnInstallEvent(int request_id); 217 void OnInstallEvent(int request_id);
213 void OnFetchEvent(int response_id, 218 void DispatchFetchEvent(int response_id,
214 int event_finish_id, 219 const ServiceWorkerFetchRequest& request,
215 const ServiceWorkerFetchRequest& request); 220 const FetchCallback& callback);
216 void OnNotificationClickEvent( 221 void OnNotificationClickEvent(
217 int request_id, 222 int request_id,
218 const std::string& notification_id, 223 const std::string& notification_id,
219 const PlatformNotificationData& notification_data, 224 const PlatformNotificationData& notification_data,
220 int action_index); 225 int action_index);
221 void OnPushEvent(int request_id, const PushEventPayload& payload); 226 void OnPushEvent(int request_id, const PushEventPayload& payload);
222 void OnNotificationCloseEvent( 227 void OnNotificationCloseEvent(
223 int request_id, 228 int request_id,
224 const std::string& notification_id, 229 const std::string& notification_id,
225 const PlatformNotificationData& notification_data); 230 const PlatformNotificationData& notification_data);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 // Initialized on the worker thread in workerContextStarted and 266 // Initialized on the worker thread in workerContextStarted and
262 // destructed on the worker thread in willDestroyWorkerContext. 267 // destructed on the worker thread in willDestroyWorkerContext.
263 std::unique_ptr<WorkerContextData> context_; 268 std::unique_ptr<WorkerContextData> context_;
264 269
265 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextClient); 270 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextClient);
266 }; 271 };
267 272
268 } // namespace content 273 } // namespace content
269 274
270 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CLIENT_H_ 275 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CLIENT_H_
OLDNEW
« no previous file with comments | « content/common/typemaps.gni ('k') | content/renderer/service_worker/service_worker_context_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698