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/id_map.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 class ServiceWorkerRegistration; | 24 class ServiceWorkerRegistration; |
25 | 25 |
26 class CONTENT_EXPORT ServiceWorkerDispatcherHost : public BrowserMessageFilter { | 26 class CONTENT_EXPORT ServiceWorkerDispatcherHost : public BrowserMessageFilter { |
27 public: | 27 public: |
28 ServiceWorkerDispatcherHost( | 28 ServiceWorkerDispatcherHost( |
29 int render_process_id, | 29 int render_process_id, |
30 MessagePortMessageFilter* message_port_message_filter); | 30 MessagePortMessageFilter* message_port_message_filter); |
31 | 31 |
32 void Init(ServiceWorkerContextWrapper* context_wrapper); | 32 void Init(ServiceWorkerContextWrapper* context_wrapper); |
33 | 33 |
34 // BrowserIOMessageFilter implementation | 34 // BrowserMessageFilter implementation |
| 35 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE; |
35 virtual void OnDestruct() const OVERRIDE; | 36 virtual void OnDestruct() const OVERRIDE; |
36 virtual bool OnMessageReceived(const IPC::Message& message, | 37 virtual bool OnMessageReceived(const IPC::Message& message, |
37 bool* message_was_ok) OVERRIDE; | 38 bool* message_was_ok) OVERRIDE; |
38 | 39 |
| 40 // IPC::Sender implementation |
| 41 |
| 42 // Send() queues the message until the underlying channel is ready. This |
| 43 // class assumes that Send() can only fail after that when the renderer |
| 44 // process has terminated, at which point the whole instance will eventually |
| 45 // be destroyed. |
| 46 virtual bool Send(IPC::Message* message) OVERRIDE; |
| 47 |
39 void RegisterServiceWorkerHandle(scoped_ptr<ServiceWorkerHandle> handle); | 48 void RegisterServiceWorkerHandle(scoped_ptr<ServiceWorkerHandle> handle); |
40 | 49 |
41 protected: | 50 protected: |
42 virtual ~ServiceWorkerDispatcherHost(); | 51 virtual ~ServiceWorkerDispatcherHost(); |
43 | 52 |
44 private: | 53 private: |
45 friend class BrowserThread; | 54 friend class BrowserThread; |
46 friend class base::DeleteHelper<ServiceWorkerDispatcherHost>; | 55 friend class base::DeleteHelper<ServiceWorkerDispatcherHost>; |
47 friend class TestingServiceWorkerDispatcherHost; | 56 friend class TestingServiceWorkerDispatcherHost; |
48 | 57 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 void SendRegistrationError(int thread_id, | 100 void SendRegistrationError(int thread_id, |
92 int request_id, | 101 int request_id, |
93 ServiceWorkerStatusCode status); | 102 ServiceWorkerStatusCode status); |
94 | 103 |
95 int render_process_id_; | 104 int render_process_id_; |
96 MessagePortMessageFilter* const message_port_message_filter_; | 105 MessagePortMessageFilter* const message_port_message_filter_; |
97 base::WeakPtr<ServiceWorkerContextCore> context_; | 106 base::WeakPtr<ServiceWorkerContextCore> context_; |
98 | 107 |
99 IDMap<ServiceWorkerHandle, IDMapOwnPointer> handles_; | 108 IDMap<ServiceWorkerHandle, IDMapOwnPointer> handles_; |
100 | 109 |
| 110 bool channel_ready_; // True after BrowserMessageFilter::channel_ != NULL. |
| 111 ScopedVector<IPC::Message> pending_messages_; |
| 112 |
101 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcherHost); | 113 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcherHost); |
102 }; | 114 }; |
103 | 115 |
104 } // namespace content | 116 } // namespace content |
105 | 117 |
106 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_ | 118 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_ |
OLD | NEW |