OLD | NEW |
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 "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
10 #include "content/browser/service_worker/service_worker_registration_status.h" | 11 #include "content/browser/service_worker/service_worker_registration_status.h" |
11 #include "content/public/browser/browser_message_filter.h" | 12 #include "content/public/browser/browser_message_filter.h" |
12 | 13 |
13 class GURL; | 14 class GURL; |
14 | 15 |
15 namespace content { | 16 namespace content { |
16 | 17 |
17 class MessagePortMessageFilter; | 18 class MessagePortMessageFilter; |
18 class ServiceWorkerContextCore; | 19 class ServiceWorkerContextCore; |
19 class ServiceWorkerContextWrapper; | 20 class ServiceWorkerContextWrapper; |
| 21 class ServiceWorkerHandle; |
20 class ServiceWorkerProviderHost; | 22 class ServiceWorkerProviderHost; |
21 class ServiceWorkerRegistration; | 23 class ServiceWorkerRegistration; |
22 | 24 |
23 class CONTENT_EXPORT ServiceWorkerDispatcherHost : public BrowserMessageFilter { | 25 class CONTENT_EXPORT ServiceWorkerDispatcherHost : public BrowserMessageFilter { |
24 public: | 26 public: |
25 ServiceWorkerDispatcherHost( | 27 ServiceWorkerDispatcherHost( |
26 int render_process_id, | 28 int render_process_id, |
27 MessagePortMessageFilter* message_port_message_filter); | 29 MessagePortMessageFilter* message_port_message_filter); |
28 | 30 |
29 void Init(ServiceWorkerContextWrapper* context_wrapper); | 31 void Init(ServiceWorkerContextWrapper* context_wrapper); |
30 | 32 |
31 // BrowserIOMessageFilter implementation | 33 // BrowserIOMessageFilter implementation |
32 virtual void OnDestruct() const OVERRIDE; | 34 virtual void OnDestruct() const OVERRIDE; |
33 virtual bool OnMessageReceived(const IPC::Message& message, | 35 virtual bool OnMessageReceived(const IPC::Message& message, |
34 bool* message_was_ok) OVERRIDE; | 36 bool* message_was_ok) OVERRIDE; |
35 | 37 |
| 38 // Returns a new handle id. |
| 39 int RegisterServiceWorkerHandle(scoped_ptr<ServiceWorkerHandle> handle); |
| 40 |
36 protected: | 41 protected: |
37 virtual ~ServiceWorkerDispatcherHost(); | 42 virtual ~ServiceWorkerDispatcherHost(); |
38 | 43 |
39 private: | 44 private: |
40 friend class BrowserThread; | 45 friend class BrowserThread; |
41 friend class base::DeleteHelper<ServiceWorkerDispatcherHost>; | 46 friend class base::DeleteHelper<ServiceWorkerDispatcherHost>; |
42 friend class TestingServiceWorkerDispatcherHost; | 47 friend class TestingServiceWorkerDispatcherHost; |
43 | 48 |
44 // IPC Message handlers | 49 // IPC Message handlers |
45 void OnRegisterServiceWorker(int32 thread_id, | 50 void OnRegisterServiceWorker(int32 thread_id, |
(...skipping 12 matching lines...) Expand all Loading... |
58 int embedded_worker_id); | 63 int embedded_worker_id); |
59 void OnWorkerStopped(int embedded_worker_id); | 64 void OnWorkerStopped(int embedded_worker_id); |
60 void OnSendMessageToBrowser(int embedded_worker_id, | 65 void OnSendMessageToBrowser(int embedded_worker_id, |
61 int request_id, | 66 int request_id, |
62 const IPC::Message& message); | 67 const IPC::Message& message); |
63 void OnReportException(int embedded_worker_id, | 68 void OnReportException(int embedded_worker_id, |
64 const base::string16& error_message, | 69 const base::string16& error_message, |
65 int line_number, | 70 int line_number, |
66 int column_number, | 71 int column_number, |
67 const GURL& source_url); | 72 const GURL& source_url); |
68 void OnPostMessage(int64 version_id, | 73 void OnPostMessage(int handle_id, |
69 const base::string16& message, | 74 const base::string16& message, |
70 const std::vector<int>& sent_message_port_ids); | 75 const std::vector<int>& sent_message_port_ids); |
| 76 void OnServiceWorkerObjectDestroyed(int handle_id); |
71 | 77 |
72 // Callbacks from ServiceWorkerContextCore | 78 // Callbacks from ServiceWorkerContextCore |
73 void RegistrationComplete(int32 thread_id, | 79 void RegistrationComplete(int32 thread_id, |
74 int32 request_id, | 80 int32 request_id, |
75 ServiceWorkerStatusCode status, | 81 ServiceWorkerStatusCode status, |
76 int64 registration_id, | 82 int64 registration_id, |
77 int64 version_id); | 83 int64 version_id); |
78 | 84 |
79 void UnregistrationComplete(int32 thread_id, | 85 void UnregistrationComplete(int32 thread_id, |
80 int32 request_id, | 86 int32 request_id, |
81 ServiceWorkerStatusCode status); | 87 ServiceWorkerStatusCode status); |
82 | 88 |
83 void SendRegistrationError(int32 thread_id, | 89 void SendRegistrationError(int32 thread_id, |
84 int32 request_id, | 90 int32 request_id, |
85 ServiceWorkerStatusCode status); | 91 ServiceWorkerStatusCode status); |
86 | 92 |
87 int render_process_id_; | 93 int render_process_id_; |
88 MessagePortMessageFilter* const message_port_message_filter_; | 94 MessagePortMessageFilter* const message_port_message_filter_; |
| 95 base::WeakPtr<ServiceWorkerContextCore> context_; |
89 | 96 |
90 base::WeakPtr<ServiceWorkerContextCore> context_; | 97 IDMap<ServiceWorkerHandle, IDMapOwnPointer> handles_; |
| 98 |
| 99 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcherHost); |
91 }; | 100 }; |
92 | 101 |
93 } // namespace content | 102 } // namespace content |
94 | 103 |
95 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_ | 104 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_ |
OLD | NEW |