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

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

Issue 463013002: ServiceWorker: Implement updatefound event and version attributes (Chromium) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address for comments Created 6 years, 4 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 <vector> 8 #include <vector>
9 9
10 #include "base/id_map.h" 10 #include "base/id_map.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
13 #include "content/browser/service_worker/service_worker_registration_status.h" 13 #include "content/browser/service_worker/service_worker_registration_status.h"
14 #include "content/public/browser/browser_message_filter.h" 14 #include "content/public/browser/browser_message_filter.h"
15 15
16 class GURL; 16 class GURL;
17 struct EmbeddedWorkerHostMsg_ReportConsoleMessage_Params; 17 struct EmbeddedWorkerHostMsg_ReportConsoleMessage_Params;
18 18
19 namespace content { 19 namespace content {
20 20
21 class MessagePortMessageFilter; 21 class MessagePortMessageFilter;
22 class ServiceWorkerContextCore; 22 class ServiceWorkerContextCore;
23 class ServiceWorkerContextWrapper; 23 class ServiceWorkerContextWrapper;
24 class ServiceWorkerHandle; 24 class ServiceWorkerHandle;
25 class ServiceWorkerProviderHost; 25 class ServiceWorkerProviderHost;
26 class ServiceWorkerRegistration; 26 class ServiceWorkerRegistration;
27 class ServiceWorkerRegistrationHandle;
27 28
28 class CONTENT_EXPORT ServiceWorkerDispatcherHost : public BrowserMessageFilter { 29 class CONTENT_EXPORT ServiceWorkerDispatcherHost : public BrowserMessageFilter {
29 public: 30 public:
30 ServiceWorkerDispatcherHost( 31 ServiceWorkerDispatcherHost(
31 int render_process_id, 32 int render_process_id,
32 MessagePortMessageFilter* message_port_message_filter); 33 MessagePortMessageFilter* message_port_message_filter);
33 34
34 void Init(ServiceWorkerContextWrapper* context_wrapper); 35 void Init(ServiceWorkerContextWrapper* context_wrapper);
35 36
36 // BrowserMessageFilter implementation 37 // BrowserMessageFilter implementation
37 virtual void OnFilterAdded(IPC::Sender* sender) OVERRIDE; 38 virtual void OnFilterAdded(IPC::Sender* sender) OVERRIDE;
38 virtual void OnDestruct() const OVERRIDE; 39 virtual void OnDestruct() const OVERRIDE;
39 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 40 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
40 41
41 // IPC::Sender implementation 42 // IPC::Sender implementation
42 43
43 // Send() queues the message until the underlying sender is ready. This 44 // Send() queues the message until the underlying sender is ready. This
44 // class assumes that Send() can only fail after that when the renderer 45 // class assumes that Send() can only fail after that when the renderer
45 // process has terminated, at which point the whole instance will eventually 46 // process has terminated, at which point the whole instance will eventually
46 // be destroyed. 47 // be destroyed.
47 virtual bool Send(IPC::Message* message) OVERRIDE; 48 virtual bool Send(IPC::Message* message) OVERRIDE;
48 49
49 void RegisterServiceWorkerHandle(scoped_ptr<ServiceWorkerHandle> handle); 50 void RegisterServiceWorkerHandle(scoped_ptr<ServiceWorkerHandle> handle);
51 void RegisterServiceWorkerRegistrationHandle(
52 scoped_ptr<ServiceWorkerRegistrationHandle> handle);
50 53
51 MessagePortMessageFilter* message_port_message_filter() { 54 MessagePortMessageFilter* message_port_message_filter() {
52 return message_port_message_filter_; 55 return message_port_message_filter_;
53 } 56 }
54 57
55 protected: 58 protected:
56 virtual ~ServiceWorkerDispatcherHost(); 59 virtual ~ServiceWorkerDispatcherHost();
57 60
58 private: 61 private:
59 friend class BrowserThread; 62 friend class BrowserThread;
(...skipping 25 matching lines...) Expand all
85 int column_number, 88 int column_number,
86 const GURL& source_url); 89 const GURL& source_url);
87 void OnReportConsoleMessage( 90 void OnReportConsoleMessage(
88 int embedded_worker_id, 91 int embedded_worker_id,
89 const EmbeddedWorkerHostMsg_ReportConsoleMessage_Params& params); 92 const EmbeddedWorkerHostMsg_ReportConsoleMessage_Params& params);
90 void OnPostMessage(int handle_id, 93 void OnPostMessage(int handle_id,
91 const base::string16& message, 94 const base::string16& message,
92 const std::vector<int>& sent_message_port_ids); 95 const std::vector<int>& sent_message_port_ids);
93 void OnIncrementServiceWorkerRefCount(int handle_id); 96 void OnIncrementServiceWorkerRefCount(int handle_id);
94 void OnDecrementServiceWorkerRefCount(int handle_id); 97 void OnDecrementServiceWorkerRefCount(int handle_id);
98 void OnIncrementRegistrationRefCount(int registration_handle_id);
99 void OnDecrementRegistrationRefCount(int registration_handle_id);
95 void OnPostMessageToWorker(int handle_id, 100 void OnPostMessageToWorker(int handle_id,
96 const base::string16& message, 101 const base::string16& message,
97 const std::vector<int>& sent_message_port_ids); 102 const std::vector<int>& sent_message_port_ids);
98 void OnServiceWorkerObjectDestroyed(int handle_id); 103 void OnServiceWorkerObjectDestroyed(int handle_id);
99 104
100 ServiceWorkerHandle* FindHandle(int provider_id, int64 version_id); 105 ServiceWorkerHandle* FindHandle(
106 int provider_id,
107 int64 version_id);
108 ServiceWorkerRegistrationHandle* FindRegistrationHandle(
109 int provider_id,
110 int64 registration_id);
101 111
102 // Callbacks from ServiceWorkerContextCore 112 // Callbacks from ServiceWorkerContextCore
103 void RegistrationComplete(int thread_id, 113 void RegistrationComplete(int thread_id,
104 int provider_id, 114 int provider_id,
105 int request_id, 115 int request_id,
106 ServiceWorkerStatusCode status, 116 ServiceWorkerStatusCode status,
107 int64 registration_id, 117 int64 registration_id,
108 int64 version_id); 118 int64 version_id);
109 119
110 void UnregistrationComplete(int thread_id, 120 void UnregistrationComplete(int thread_id,
111 int request_id, 121 int request_id,
112 ServiceWorkerStatusCode status); 122 ServiceWorkerStatusCode status);
113 123
114 void SendRegistrationError(int thread_id, 124 void SendRegistrationError(int thread_id,
115 int request_id, 125 int request_id,
116 ServiceWorkerStatusCode status); 126 ServiceWorkerStatusCode status);
117 127
118 ServiceWorkerContextCore* GetContext(); 128 ServiceWorkerContextCore* GetContext();
119 129
120 int render_process_id_; 130 int render_process_id_;
121 MessagePortMessageFilter* const message_port_message_filter_; 131 MessagePortMessageFilter* const message_port_message_filter_;
122 scoped_refptr<ServiceWorkerContextWrapper> context_wrapper_; 132 scoped_refptr<ServiceWorkerContextWrapper> context_wrapper_;
123 133
124 IDMap<ServiceWorkerHandle, IDMapOwnPointer> handles_; 134 IDMap<ServiceWorkerHandle, IDMapOwnPointer> handles_;
135 IDMap<ServiceWorkerRegistrationHandle, IDMapOwnPointer> registration_handles_;
125 136
126 bool channel_ready_; // True after BrowserMessageFilter::sender_ != NULL. 137 bool channel_ready_; // True after BrowserMessageFilter::sender_ != NULL.
127 ScopedVector<IPC::Message> pending_messages_; 138 ScopedVector<IPC::Message> pending_messages_;
128 139
129 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcherHost); 140 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcherHost);
130 }; 141 };
131 142
132 } // namespace content 143 } // namespace content
133 144
134 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_ 145 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698