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

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

Issue 224733014: Introduce ServiceWorkerHandle for tracking WebServiceWorkerImpl reference (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_
7 7
8 #include "base/id_map.h"
8 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
9 #include "content/browser/service_worker/service_worker_registration_status.h" 10 #include "content/browser/service_worker/service_worker_registration_status.h"
10 #include "content/public/browser/browser_message_filter.h" 11 #include "content/public/browser/browser_message_filter.h"
11 12
12 class GURL; 13 class GURL;
13 14
14 namespace content { 15 namespace content {
15 16
16 class MessagePortMessageFilter; 17 class MessagePortMessageFilter;
17 class ServiceWorkerContextCore; 18 class ServiceWorkerContextCore;
18 class ServiceWorkerContextWrapper; 19 class ServiceWorkerContextWrapper;
20 class ServiceWorkerHandle;
19 class ServiceWorkerProviderHost; 21 class ServiceWorkerProviderHost;
20 class ServiceWorkerRegistration; 22 class ServiceWorkerRegistration;
21 23
22 class CONTENT_EXPORT ServiceWorkerDispatcherHost : public BrowserMessageFilter { 24 class CONTENT_EXPORT ServiceWorkerDispatcherHost : public BrowserMessageFilter {
23 public: 25 public:
24 ServiceWorkerDispatcherHost( 26 ServiceWorkerDispatcherHost(
25 int render_process_id, 27 int render_process_id,
26 MessagePortMessageFilter* message_port_message_filter); 28 MessagePortMessageFilter* message_port_message_filter);
27 29
28 void Init(ServiceWorkerContextWrapper* context_wrapper); 30 void Init(ServiceWorkerContextWrapper* context_wrapper);
29 31
30 // BrowserIOMessageFilter implementation 32 // BrowserIOMessageFilter implementation
31 virtual void OnDestruct() const OVERRIDE; 33 virtual void OnDestruct() const OVERRIDE;
32 virtual bool OnMessageReceived(const IPC::Message& message, 34 virtual bool OnMessageReceived(const IPC::Message& message,
33 bool* message_was_ok) OVERRIDE; 35 bool* message_was_ok) OVERRIDE;
34 36
37 // Returns a new handle id.
38 int RegisterServiceWorkerHandle(scoped_ptr<ServiceWorkerHandle> handle);
39
35 protected: 40 protected:
36 virtual ~ServiceWorkerDispatcherHost(); 41 virtual ~ServiceWorkerDispatcherHost();
37 42
38 private: 43 private:
39 friend class BrowserThread; 44 friend class BrowserThread;
40 friend class base::DeleteHelper<ServiceWorkerDispatcherHost>; 45 friend class base::DeleteHelper<ServiceWorkerDispatcherHost>;
41 friend class TestingServiceWorkerDispatcherHost; 46 friend class TestingServiceWorkerDispatcherHost;
42 47
43 // IPC Message handlers 48 // IPC Message handlers
44 void OnRegisterServiceWorker(int thread_id, 49 void OnRegisterServiceWorker(int thread_id,
(...skipping 12 matching lines...) Expand all
57 void OnSetHostedVersionId(int provider_id, int64 version_id); 62 void OnSetHostedVersionId(int provider_id, int64 version_id);
58 void OnWorkerStarted(int thread_id, 63 void OnWorkerStarted(int thread_id,
59 int embedded_worker_id); 64 int embedded_worker_id);
60 void OnWorkerStopped(int embedded_worker_id); 65 void OnWorkerStopped(int embedded_worker_id);
61 void OnSendMessageToBrowser(int embedded_worker_id, 66 void OnSendMessageToBrowser(int embedded_worker_id,
62 int request_id, 67 int request_id,
63 const IPC::Message& message); 68 const IPC::Message& message);
64 void OnPostMessage(int64 version_id, 69 void OnPostMessage(int64 version_id,
65 const base::string16& message, 70 const base::string16& message,
66 const std::vector<int>& sent_message_port_ids); 71 const std::vector<int>& sent_message_port_ids);
72 void OnServiceWorkerObjectDestroyed(int handle_id);
67 73
68 // Callbacks from ServiceWorkerContextCore 74 // Callbacks from ServiceWorkerContextCore
69 void RegistrationComplete(int thread_id, 75 void RegistrationComplete(int thread_id,
70 int request_id, 76 int request_id,
71 ServiceWorkerStatusCode status, 77 ServiceWorkerStatusCode status,
72 int64 registration_id, 78 int64 registration_id,
73 int64 version_id); 79 int64 version_id);
74 80
75 void UnregistrationComplete(int thread_id, 81 void UnregistrationComplete(int thread_id,
76 int request_id, 82 int request_id,
77 ServiceWorkerStatusCode status); 83 ServiceWorkerStatusCode status);
78 84
79 void SendRegistrationError(int thread_id, 85 void SendRegistrationError(int thread_id,
80 int request_id, 86 int request_id,
81 ServiceWorkerStatusCode status); 87 ServiceWorkerStatusCode status);
82 88
83 int render_process_id_; 89 int render_process_id_;
84 MessagePortMessageFilter* const message_port_message_filter_; 90 MessagePortMessageFilter* const message_port_message_filter_;
91 base::WeakPtr<ServiceWorkerContextCore> context_;
85 92
86 base::WeakPtr<ServiceWorkerContextCore> context_; 93 IDMap<ServiceWorkerHandle, IDMapOwnPointer> handles_;
94
95 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcherHost);
87 }; 96 };
88 97
89 } // namespace content 98 } // namespace content
90 99
91 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_ 100 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698