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

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

Issue 629393002: Chromium side of geofencing event dispatching. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@geofencing_serviceworker
Patch Set: Created 6 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 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_VERSION_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/gtest_prod_util.h" 14 #include "base/gtest_prod_util.h"
15 #include "base/id_map.h" 15 #include "base/id_map.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "base/observer_list.h" 18 #include "base/observer_list.h"
19 #include "base/timer/timer.h" 19 #include "base/timer/timer.h"
20 #include "content/browser/service_worker/embedded_worker_instance.h" 20 #include "content/browser/service_worker/embedded_worker_instance.h"
21 #include "content/browser/service_worker/service_worker_cache_listener.h" 21 #include "content/browser/service_worker/service_worker_cache_listener.h"
22 #include "content/browser/service_worker/service_worker_script_cache_map.h" 22 #include "content/browser/service_worker/service_worker_script_cache_map.h"
23 #include "content/common/content_export.h" 23 #include "content/common/content_export.h"
24 #include "content/common/service_worker/service_worker_status_code.h" 24 #include "content/common/service_worker/service_worker_status_code.h"
25 #include "content/common/service_worker/service_worker_types.h" 25 #include "content/common/service_worker/service_worker_types.h"
26 #include "third_party/WebKit/public/platform/WebGeofencingEventType.h"
26 #include "third_party/WebKit/public/platform/WebServiceWorkerEventResult.h" 27 #include "third_party/WebKit/public/platform/WebServiceWorkerEventResult.h"
27 28
28 class GURL; 29 class GURL;
29 30
31 namespace blink {
32 struct WebCircularGeofencingRegion;
33 }
34
30 namespace content { 35 namespace content {
31 36
32 class EmbeddedWorkerRegistry; 37 class EmbeddedWorkerRegistry;
33 class ServiceWorkerContextCore; 38 class ServiceWorkerContextCore;
34 class ServiceWorkerProviderHost; 39 class ServiceWorkerProviderHost;
35 class ServiceWorkerRegistration; 40 class ServiceWorkerRegistration;
36 class ServiceWorkerVersionInfo; 41 class ServiceWorkerVersionInfo;
37 42
38 // This class corresponds to a specific version of a ServiceWorker 43 // This class corresponds to a specific version of a ServiceWorker
39 // script for a given pattern. When a script is upgraded, there may be 44 // script for a given pattern. When a script is upgraded, there may be
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 void DispatchSyncEvent(const StatusCallback& callback); 195 void DispatchSyncEvent(const StatusCallback& callback);
191 196
192 // Sends push event to the associated embedded worker and asynchronously calls 197 // Sends push event to the associated embedded worker and asynchronously calls
193 // |callback| when it errors out or it gets response from the worker to notify 198 // |callback| when it errors out or it gets response from the worker to notify
194 // completion. 199 // completion.
195 // 200 //
196 // This must be called when the status() is ACTIVATED. 201 // This must be called when the status() is ACTIVATED.
197 void DispatchPushEvent(const StatusCallback& callback, 202 void DispatchPushEvent(const StatusCallback& callback,
198 const std::string& data); 203 const std::string& data);
199 204
205 // Sends geofencing event to the associated embedded woker and asynchronously
dominicc (has gone to gerrit) 2014/10/07 01:52:05 nit: woker
Marijn Kruisselbrink 2014/10/09 22:56:56 Done.
206 // calls |callback| when it errors out or it gets response from the worker to
dominicc (has gone to gerrit) 2014/10/07 01:52:05 nit: response needs an article--a, the
Marijn Kruisselbrink 2014/10/09 22:56:56 Done. (and also fixed this in all the other places
207 // notify completion.
208 //
209 // This must be called when the status() is ACTIVATED.
210 void DispatchGeofencingEvent(
211 const StatusCallback& callback,
212 blink::WebGeofencingEventType event_type,
213 const std::string& region_id,
214 const blink::WebCircularGeofencingRegion& region);
215
200 // Adds and removes |provider_host| as a controllee of this ServiceWorker. 216 // Adds and removes |provider_host| as a controllee of this ServiceWorker.
201 // A potential controllee is a host having the version as its .installing 217 // A potential controllee is a host having the version as its .installing
202 // or .waiting version. 218 // or .waiting version.
203 void AddControllee(ServiceWorkerProviderHost* provider_host); 219 void AddControllee(ServiceWorkerProviderHost* provider_host);
204 void RemoveControllee(ServiceWorkerProviderHost* provider_host); 220 void RemoveControllee(ServiceWorkerProviderHost* provider_host);
205 221
206 // Returns if it has controllee. 222 // Returns if it has controllee.
207 bool HasControllee() const { return !controllee_map_.empty(); } 223 bool HasControllee() const { return !controllee_map_.empty(); }
208 224
209 // Adds and removes Listeners. 225 // Adds and removes Listeners.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 void OnGetClientDocuments(int request_id); 270 void OnGetClientDocuments(int request_id);
255 void OnActivateEventFinished(int request_id, 271 void OnActivateEventFinished(int request_id,
256 blink::WebServiceWorkerEventResult result); 272 blink::WebServiceWorkerEventResult result);
257 void OnInstallEventFinished(int request_id, 273 void OnInstallEventFinished(int request_id,
258 blink::WebServiceWorkerEventResult result); 274 blink::WebServiceWorkerEventResult result);
259 void OnFetchEventFinished(int request_id, 275 void OnFetchEventFinished(int request_id,
260 ServiceWorkerFetchEventResult result, 276 ServiceWorkerFetchEventResult result,
261 const ServiceWorkerResponse& response); 277 const ServiceWorkerResponse& response);
262 void OnSyncEventFinished(int request_id); 278 void OnSyncEventFinished(int request_id);
263 void OnPushEventFinished(int request_id); 279 void OnPushEventFinished(int request_id);
280 void OnGeofencingEventFinished(int request_id);
264 void OnPostMessageToDocument(int client_id, 281 void OnPostMessageToDocument(int client_id,
265 const base::string16& message, 282 const base::string16& message,
266 const std::vector<int>& sent_message_port_ids); 283 const std::vector<int>& sent_message_port_ids);
267 284
268 void ScheduleStopWorker(); 285 void ScheduleStopWorker();
269 void DoomInternal(); 286 void DoomInternal();
270 287
271 const int64 version_id_; 288 const int64 version_id_;
272 int64 registration_id_; 289 int64 registration_id_;
273 GURL script_url_; 290 GURL script_url_;
274 GURL scope_; 291 GURL scope_;
275 Status status_; 292 Status status_;
276 scoped_ptr<EmbeddedWorkerInstance> embedded_worker_; 293 scoped_ptr<EmbeddedWorkerInstance> embedded_worker_;
277 scoped_ptr<ServiceWorkerCacheListener> cache_listener_; 294 scoped_ptr<ServiceWorkerCacheListener> cache_listener_;
278 std::vector<StatusCallback> start_callbacks_; 295 std::vector<StatusCallback> start_callbacks_;
279 std::vector<StatusCallback> stop_callbacks_; 296 std::vector<StatusCallback> stop_callbacks_;
280 std::vector<base::Closure> status_change_callbacks_; 297 std::vector<base::Closure> status_change_callbacks_;
281 298
282 // Message callbacks. 299 // Message callbacks.
283 IDMap<StatusCallback, IDMapOwnPointer> activate_callbacks_; 300 IDMap<StatusCallback, IDMapOwnPointer> activate_callbacks_;
284 IDMap<StatusCallback, IDMapOwnPointer> install_callbacks_; 301 IDMap<StatusCallback, IDMapOwnPointer> install_callbacks_;
285 IDMap<FetchCallback, IDMapOwnPointer> fetch_callbacks_; 302 IDMap<FetchCallback, IDMapOwnPointer> fetch_callbacks_;
286 IDMap<StatusCallback, IDMapOwnPointer> sync_callbacks_; 303 IDMap<StatusCallback, IDMapOwnPointer> sync_callbacks_;
287 IDMap<StatusCallback, IDMapOwnPointer> push_callbacks_; 304 IDMap<StatusCallback, IDMapOwnPointer> push_callbacks_;
305 IDMap<StatusCallback, IDMapOwnPointer> geofencing_callbacks_;
288 306
289 ControlleeMap controllee_map_; 307 ControlleeMap controllee_map_;
290 ControlleeByIDMap controllee_by_id_; 308 ControlleeByIDMap controllee_by_id_;
291 base::WeakPtr<ServiceWorkerContextCore> context_; 309 base::WeakPtr<ServiceWorkerContextCore> context_;
292 ObserverList<Listener> listeners_; 310 ObserverList<Listener> listeners_;
293 ServiceWorkerScriptCacheMap script_cache_map_; 311 ServiceWorkerScriptCacheMap script_cache_map_;
294 base::OneShotTimer<ServiceWorkerVersion> stop_worker_timer_; 312 base::OneShotTimer<ServiceWorkerVersion> stop_worker_timer_;
295 base::OneShotTimer<ServiceWorkerVersion> update_timer_; 313 base::OneShotTimer<ServiceWorkerVersion> update_timer_;
296 bool is_doomed_; 314 bool is_doomed_;
297 315
298 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; 316 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_;
299 317
300 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); 318 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion);
301 }; 319 };
302 320
303 } // namespace content 321 } // namespace content
304 322
305 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 323 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698