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

Side by Side Diff: content/child/service_worker/service_worker_dispatcher.h

Issue 182863004: Wire provider_id into scriptable API provider to start listening events (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comments Created 6 years, 9 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 | Annotate | Revision Log
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_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ 5 #ifndef CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_
6 #define CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ 6 #define CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_
7 7
8 #include <map>
9
8 #include "base/id_map.h" 10 #include "base/id_map.h"
9 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
10 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
11 #include "content/child/worker_task_runner.h" 13 #include "content/child/worker_task_runner.h"
12 #include "third_party/WebKit/public/platform/WebServiceWorkerError.h" 14 #include "third_party/WebKit/public/platform/WebServiceWorkerError.h"
13 #include "third_party/WebKit/public/platform/WebServiceWorkerProvider.h" 15 #include "third_party/WebKit/public/platform/WebServiceWorkerProvider.h"
14 16
15 class GURL; 17 class GURL;
16 18
17 namespace blink { 19 namespace blink {
(...skipping 13 matching lines...) Expand all
31 // registration of the service worker, exposed to renderer and worker 33 // registration of the service worker, exposed to renderer and worker
32 // scripts through methods like navigator.registerServiceWorker(). 34 // scripts through methods like navigator.registerServiceWorker().
33 class ServiceWorkerDispatcher : public WorkerTaskRunner::Observer { 35 class ServiceWorkerDispatcher : public WorkerTaskRunner::Observer {
34 public: 36 public:
35 explicit ServiceWorkerDispatcher(ThreadSafeSender* thread_safe_sender); 37 explicit ServiceWorkerDispatcher(ThreadSafeSender* thread_safe_sender);
36 virtual ~ServiceWorkerDispatcher(); 38 virtual ~ServiceWorkerDispatcher();
37 39
38 void OnMessageReceived(const IPC::Message& msg); 40 void OnMessageReceived(const IPC::Message& msg);
39 bool Send(IPC::Message* msg); 41 bool Send(IPC::Message* msg);
40 42
41 // Corresponds to navigator.registerServiceWorker() 43 // Corresponds to navigator.serviceWorker.register()
42 void RegisterServiceWorker( 44 void RegisterServiceWorker(
43 const GURL& pattern, 45 const GURL& pattern,
44 const GURL& script_url, 46 const GURL& script_url,
45 blink::WebServiceWorkerProvider::WebServiceWorkerCallbacks* callbacks); 47 blink::WebServiceWorkerProvider::WebServiceWorkerCallbacks* callbacks);
46 // Corresponds to navigator.unregisterServiceWorker() 48 // Corresponds to navigator.serviceWorker.unregister()
47 void UnregisterServiceWorker( 49 void UnregisterServiceWorker(
48 const GURL& pattern, 50 const GURL& pattern,
49 blink::WebServiceWorkerProvider::WebServiceWorkerCallbacks* callbacks); 51 blink::WebServiceWorkerProvider::WebServiceWorkerCallbacks* callbacks);
50 52
53 // Called when navigator.serviceWorker is instantiated or detached
54 // for a document whose provider can be identified by |provider_id|.
55 void AddScriptClient(int provider_id,
56 blink::WebServiceWorkerProviderClient* client);
57 void RemoveScriptClient(int provider_id);
58
51 // |thread_safe_sender| needs to be passed in because if the call leads to 59 // |thread_safe_sender| needs to be passed in because if the call leads to
52 // construction it will be needed. 60 // construction it will be needed.
53 static ServiceWorkerDispatcher* ThreadSpecificInstance( 61 static ServiceWorkerDispatcher* ThreadSpecificInstance(
54 ThreadSafeSender* thread_safe_sender); 62 ThreadSafeSender* thread_safe_sender);
55 63
56 private: 64 private:
65 typedef std::map<int, blink::WebServiceWorkerProviderClient*> ScriptClientMap;
66
57 // WorkerTaskRunner::Observer implementation. 67 // WorkerTaskRunner::Observer implementation.
58 virtual void OnWorkerRunLoopStopped() OVERRIDE; 68 virtual void OnWorkerRunLoopStopped() OVERRIDE;
59 69
60 // The asynchronous success response to RegisterServiceWorker. 70 // The asynchronous success response to RegisterServiceWorker.
61 void OnRegistered(int32 thread_id, int32 request_id, int64 registration_id); 71 void OnRegistered(int32 thread_id, int32 request_id, int64 registration_id);
62 // The asynchronous success response to UregisterServiceWorker. 72 // The asynchronous success response to UregisterServiceWorker.
63 void OnUnregistered(int32 thread_id, 73 void OnUnregistered(int32 thread_id,
64 int32 request_id); 74 int32 request_id);
65 void OnRegistrationError(int32 thread_id, 75 void OnRegistrationError(int32 thread_id,
66 int32 request_id, 76 int32 request_id,
67 blink::WebServiceWorkerError::ErrorType error_type, 77 blink::WebServiceWorkerError::ErrorType error_type,
68 const base::string16& message); 78 const base::string16& message);
69 79
70 IDMap<blink::WebServiceWorkerProvider::WebServiceWorkerCallbacks, 80 IDMap<blink::WebServiceWorkerProvider::WebServiceWorkerCallbacks,
71 IDMapOwnPointer> pending_callbacks_; 81 IDMapOwnPointer> pending_callbacks_;
82 ScriptClientMap script_clients_;
72 83
73 scoped_refptr<ThreadSafeSender> thread_safe_sender_; 84 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
85 blink::WebServiceWorkerProviderClient* client_;
michaeln 2014/03/07 02:24:09 stale line to be deleted
kinuko 2014/03/07 02:37:13 Done.
74 86
75 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher); 87 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcher);
76 }; 88 };
77 89
78 } // namespace content 90 } // namespace content
79 91
80 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_ 92 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698