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

Side by Side Diff: content/renderer/service_worker/embedded_worker_context_client.h

Issue 1011643002: ServiceWorker: Introduce SWMessageSender in order to mock IPC messaging (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add header comment Created 5 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
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_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_CONTEXT_CLIENT_H_ 5 #ifndef CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_CONTEXT_CLIENT_H_
6 #define CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_CONTEXT_CLIENT_H_ 6 #define CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_CONTEXT_CLIENT_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.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"
11 #include "content/common/service_worker/service_worker_types.h" 11 #include "content/common/service_worker/service_worker_types.h"
12 #include "ipc/ipc_listener.h" 12 #include "ipc/ipc_listener.h"
13 #include "third_party/WebKit/public/web/WebServiceWorkerContextClient.h" 13 #include "third_party/WebKit/public/web/WebServiceWorkerContextClient.h"
14 #include "url/gurl.h" 14 #include "url/gurl.h"
15 15
16 namespace base { 16 namespace base {
17 class SingleThreadTaskRunner; 17 class SingleThreadTaskRunner;
18 class TaskRunner; 18 class TaskRunner;
19 } 19 }
20 20
21 namespace blink { 21 namespace blink {
22 class WebDataSource; 22 class WebDataSource;
23 class WebServiceWorkerProvider; 23 class WebServiceWorkerProvider;
24 } 24 }
25 25
26 namespace content { 26 namespace content {
27 27
28 class ServiceWorkerMessageSender;
28 class ServiceWorkerProviderContext; 29 class ServiceWorkerProviderContext;
29 class ServiceWorkerScriptContext; 30 class ServiceWorkerScriptContext;
30 class ThreadSafeSender; 31 class ThreadSafeSender;
31 32
32 // This class provides access to/from an embedded worker's WorkerGlobalScope. 33 // This class provides access to/from an embedded worker's WorkerGlobalScope.
33 // Unless otherwise noted, all methods are called on the worker thread. 34 // Unless otherwise noted, all methods are called on the worker thread.
34 // 35 //
35 // TODO(kinuko): Currently EW/SW separation is made a little hazily. 36 // TODO(kinuko): Currently EW/SW separation is made a little hazily.
36 // This should implement WebEmbeddedWorkerContextClient 37 // This should implement WebEmbeddedWorkerContextClient
37 // or sort of it (which doesn't exist yet) rather than 38 // or sort of it (which doesn't exist yet) rather than
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 virtual void skipWaiting( 128 virtual void skipWaiting(
128 blink::WebServiceWorkerSkipWaitingCallbacks* callbacks); 129 blink::WebServiceWorkerSkipWaitingCallbacks* callbacks);
129 virtual void claim(blink::WebServiceWorkerClientsClaimCallbacks* callbacks); 130 virtual void claim(blink::WebServiceWorkerClientsClaimCallbacks* callbacks);
130 131
131 // TODO: Implement DevTools related method overrides. 132 // TODO: Implement DevTools related method overrides.
132 133
133 int embedded_worker_id() const { return embedded_worker_id_; } 134 int embedded_worker_id() const { return embedded_worker_id_; }
134 base::SingleThreadTaskRunner* main_thread_task_runner() const { 135 base::SingleThreadTaskRunner* main_thread_task_runner() const {
135 return main_thread_task_runner_.get(); 136 return main_thread_task_runner_.get();
136 } 137 }
137 ThreadSafeSender* thread_safe_sender() { return sender_.get(); } 138 ServiceWorkerMessageSender* sender() { return sender_.get(); }
138 139
139 private: 140 private:
140 void OnMessageToWorker(int thread_id, 141 void OnMessageToWorker(int thread_id,
141 int embedded_worker_id, 142 int embedded_worker_id,
142 const IPC::Message& message); 143 const IPC::Message& message);
143 void SendWorkerStarted(); 144 void SendWorkerStarted();
144 void SetRegistrationInServiceWorkerGlobalScope(); 145 void SetRegistrationInServiceWorkerGlobalScope();
145 146
146 const int embedded_worker_id_; 147 const int embedded_worker_id_;
147 const int64 service_worker_version_id_; 148 const int64 service_worker_version_id_;
148 const GURL service_worker_scope_; 149 const GURL service_worker_scope_;
149 const GURL script_url_; 150 const GURL script_url_;
150 const int worker_devtools_agent_route_id_; 151 const int worker_devtools_agent_route_id_;
151 scoped_refptr<ThreadSafeSender> sender_; 152 scoped_refptr<ServiceWorkerMessageSender> sender_;
152 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; 153 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
153 scoped_refptr<base::TaskRunner> worker_task_runner_; 154 scoped_refptr<base::TaskRunner> worker_task_runner_;
154 155
155 scoped_ptr<ServiceWorkerScriptContext> script_context_; 156 scoped_ptr<ServiceWorkerScriptContext> script_context_;
156 scoped_refptr<ServiceWorkerProviderContext> provider_context_; 157 scoped_refptr<ServiceWorkerProviderContext> provider_context_;
157 158
158 base::WeakPtrFactory<EmbeddedWorkerContextClient> weak_factory_; 159 base::WeakPtrFactory<EmbeddedWorkerContextClient> weak_factory_;
159 160
160 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerContextClient); 161 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerContextClient);
161 }; 162 };
162 163
163 } // namespace content 164 } // namespace content
164 165
165 #endif // CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_CONTEXT_CLIENT_H_ 166 #endif // CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_CONTEXT_CLIENT_H_
OLDNEW
« no previous file with comments | « content/content_tests.gypi ('k') | content/renderer/service_worker/embedded_worker_context_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698