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

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

Issue 2106693002: Convert EmbeddedWorker to InterfaceRegistry/Provider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 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
« no previous file with comments | « no previous file | content/browser/service_worker/embedded_worker_instance.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_EMBEDDED_WORKER_INSTANCE_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 20 matching lines...) Expand all
31 #ifdef SendMessage 31 #ifdef SendMessage
32 #undef SendMessage 32 #undef SendMessage
33 #endif 33 #endif
34 34
35 struct EmbeddedWorkerMsg_StartWorker_Params; 35 struct EmbeddedWorkerMsg_StartWorker_Params;
36 36
37 namespace IPC { 37 namespace IPC {
38 class Message; 38 class Message;
39 } 39 }
40 40
41 namespace shell {
42 class InterfaceProvider;
43 class InterfaceRegistry;
44 }
45
41 namespace content { 46 namespace content {
42 47
43 class EmbeddedWorkerRegistry; 48 class EmbeddedWorkerRegistry;
44 class MessagePortMessageFilter; 49 class MessagePortMessageFilter;
45 class ServiceRegistry;
46 class ServiceRegistryImpl;
47 class ServiceWorkerContextCore; 50 class ServiceWorkerContextCore;
48 51
49 // This gives an interface to control one EmbeddedWorker instance, which 52 // This gives an interface to control one EmbeddedWorker instance, which
50 // may be 'in-waiting' or running in one of the child processes added by 53 // may be 'in-waiting' or running in one of the child processes added by
51 // AddProcessReference(). 54 // AddProcessReference().
52 class CONTENT_EXPORT EmbeddedWorkerInstance { 55 class CONTENT_EXPORT EmbeddedWorkerInstance {
53 public: 56 public:
54 typedef base::Callback<void(ServiceWorkerStatusCode)> StatusCallback; 57 typedef base::Callback<void(ServiceWorkerStatusCode)> StatusCallback;
55 58
56 // This enum is used in UMA histograms. Append-only. 59 // This enum is used in UMA histograms. Append-only.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 void StopIfIdle(); 126 void StopIfIdle();
124 127
125 // Sends |message| to the embedded worker running in the child process. 128 // Sends |message| to the embedded worker running in the child process.
126 // It is invalid to call this while the worker is not in STARTING or RUNNING 129 // It is invalid to call this while the worker is not in STARTING or RUNNING
127 // status. 130 // status.
128 ServiceWorkerStatusCode SendMessage(const IPC::Message& message); 131 ServiceWorkerStatusCode SendMessage(const IPC::Message& message);
129 132
130 // Resumes the worker if it paused after download. 133 // Resumes the worker if it paused after download.
131 void ResumeAfterDownload(); 134 void ResumeAfterDownload();
132 135
133 // Returns the ServiceRegistry for this worker. It is invalid to call this 136 // Returns the shell::InterfaceRegistry and shell::InterfaceProvider for this
134 // when the worker is not in STARTING or RUNNING status. 137 // worker. It is invalid to call this when the worker is not in STARTING or
135 ServiceRegistry* GetServiceRegistry(); 138 // RUNNING status.
139 shell::InterfaceRegistry* GetInterfaceRegistry();
140 shell::InterfaceProvider* GetRemoteInterfaces();
136 141
137 int embedded_worker_id() const { return embedded_worker_id_; } 142 int embedded_worker_id() const { return embedded_worker_id_; }
138 EmbeddedWorkerStatus status() const { return status_; } 143 EmbeddedWorkerStatus status() const { return status_; }
139 StartingPhase starting_phase() const { 144 StartingPhase starting_phase() const {
140 DCHECK_EQ(EmbeddedWorkerStatus::STARTING, status()); 145 DCHECK_EQ(EmbeddedWorkerStatus::STARTING, status());
141 return starting_phase_; 146 return starting_phase_;
142 } 147 }
143 int process_id() const; 148 int process_id() const;
144 int thread_id() const { return thread_id_; } 149 int thread_id() const { return thread_id_; }
145 // This should be called only when the worker instance has a valid process, 150 // This should be called only when the worker instance has a valid process,
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 295
291 base::WeakPtr<ServiceWorkerContextCore> context_; 296 base::WeakPtr<ServiceWorkerContextCore> context_;
292 scoped_refptr<EmbeddedWorkerRegistry> registry_; 297 scoped_refptr<EmbeddedWorkerRegistry> registry_;
293 const int embedded_worker_id_; 298 const int embedded_worker_id_;
294 EmbeddedWorkerStatus status_; 299 EmbeddedWorkerStatus status_;
295 StartingPhase starting_phase_; 300 StartingPhase starting_phase_;
296 301
297 // Current running information. 302 // Current running information.
298 std::unique_ptr<EmbeddedWorkerInstance::WorkerProcessHandle> process_handle_; 303 std::unique_ptr<EmbeddedWorkerInstance::WorkerProcessHandle> process_handle_;
299 int thread_id_; 304 int thread_id_;
300 std::unique_ptr<ServiceRegistryImpl> service_registry_; 305 std::unique_ptr<shell::InterfaceRegistry> interface_registry_;
306 std::unique_ptr<shell::InterfaceProvider> remote_interfaces_;
301 307
302 // Whether devtools is attached or not. 308 // Whether devtools is attached or not.
303 bool devtools_attached_; 309 bool devtools_attached_;
304 310
305 // True if the script load request accessed the network. If the script was 311 // True if the script load request accessed the network. If the script was
306 // served from HTTPCache or ServiceWorkerDatabase this value is false. 312 // served from HTTPCache or ServiceWorkerDatabase this value is false.
307 bool network_accessed_for_script_; 313 bool network_accessed_for_script_;
308 314
309 ListenerList listener_list_; 315 ListenerList listener_list_;
310 std::unique_ptr<DevToolsProxy> devtools_proxy_; 316 std::unique_ptr<DevToolsProxy> devtools_proxy_;
311 317
312 std::unique_ptr<StartTask> inflight_start_task_; 318 std::unique_ptr<StartTask> inflight_start_task_;
313 319
314 // This is valid only after a process is allocated for the worker. 320 // This is valid only after a process is allocated for the worker.
315 ServiceWorkerMetrics::StartSituation start_situation_ = 321 ServiceWorkerMetrics::StartSituation start_situation_ =
316 ServiceWorkerMetrics::StartSituation::UNKNOWN; 322 ServiceWorkerMetrics::StartSituation::UNKNOWN;
317 323
318 // Used for UMA. The start time of the current start sequence step. 324 // Used for UMA. The start time of the current start sequence step.
319 base::TimeTicks step_time_; 325 base::TimeTicks step_time_;
320 326
321 base::WeakPtrFactory<EmbeddedWorkerInstance> weak_factory_; 327 base::WeakPtrFactory<EmbeddedWorkerInstance> weak_factory_;
322 328
323 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerInstance); 329 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerInstance);
324 }; 330 };
325 331
326 } // namespace content 332 } // namespace content
327 333
328 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_ 334 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/service_worker/embedded_worker_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698