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

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

Issue 2227593002: ServiceWorker: Implement StartWorker by using mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added argument check and updated comment and BUILD.gn Created 4 years, 3 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_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>
11 #include <string> 11 #include <string>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/callback_forward.h" 14 #include "base/callback_forward.h"
15 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
19 #include "base/memory/weak_ptr.h" 19 #include "base/memory/weak_ptr.h"
20 #include "base/observer_list.h" 20 #include "base/observer_list.h"
21 #include "base/strings/string16.h" 21 #include "base/strings/string16.h"
22 #include "base/time/time.h" 22 #include "base/time/time.h"
23 #include "content/browser/service_worker/embedded_worker_status.h" 23 #include "content/browser/service_worker/embedded_worker_status.h"
24 #include "content/browser/service_worker/service_worker_metrics.h" 24 #include "content/browser/service_worker/service_worker_metrics.h"
25 #include "content/common/content_export.h" 25 #include "content/common/content_export.h"
26 #include "content/common/service_worker/embedded_worker.mojom.h"
26 #include "content/common/service_worker/service_worker_status_code.h" 27 #include "content/common/service_worker/service_worker_status_code.h"
27 #include "content/public/common/console_message_level.h" 28 #include "content/public/common/console_message_level.h"
28 #include "url/gurl.h" 29 #include "url/gurl.h"
29 30
30 // Windows headers will redefine SendMessage. 31 // Windows headers will redefine SendMessage.
31 #ifdef SendMessage 32 #ifdef SendMessage
32 #undef SendMessage 33 #undef SendMessage
33 #endif 34 #endif
34 35
35 struct EmbeddedWorkerMsg_StartWorker_Params; 36 struct EmbeddedWorkerMsg_StartWorker_Params;
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 // Called back from StartTask after a process is allocated on the UI thread. 217 // Called back from StartTask after a process is allocated on the UI thread.
217 void OnProcessAllocated(std::unique_ptr<WorkerProcessHandle> handle, 218 void OnProcessAllocated(std::unique_ptr<WorkerProcessHandle> handle,
218 ServiceWorkerMetrics::StartSituation start_situation); 219 ServiceWorkerMetrics::StartSituation start_situation);
219 220
220 // Called back from StartTask after the worker is registered to 221 // Called back from StartTask after the worker is registered to
221 // WorkerDevToolsManager. 222 // WorkerDevToolsManager.
222 void OnRegisteredToDevToolsManager(bool is_new_process, 223 void OnRegisteredToDevToolsManager(bool is_new_process,
223 int worker_devtools_agent_route_id, 224 int worker_devtools_agent_route_id,
224 bool wait_for_debugger); 225 bool wait_for_debugger);
225 226
227 // Sends StartWorker message via Mojo.
228 void SendMojoStartWorker(
229 std::unique_ptr<EmbeddedWorkerMsg_StartWorker_Params> params);
230
226 // Called back from StartTask after a start worker message is sent. 231 // Called back from StartTask after a start worker message is sent.
227 void OnStartWorkerMessageSent(); 232 void OnStartWorkerMessageSent();
228 233
229 // Called back from Registry when the worker instance has ack'ed that 234 // Called back from Registry when the worker instance has ack'ed that
230 // it is ready for inspection. 235 // it is ready for inspection.
231 void OnReadyForInspection(); 236 void OnReadyForInspection();
232 237
233 // Called back from Registry when the worker instance has ack'ed that 238 // Called back from Registry when the worker instance has ack'ed that
234 // it finished loading the script. 239 // it finished loading the script.
235 void OnScriptLoaded(); 240 void OnScriptLoaded();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 300
296 base::WeakPtr<ServiceWorkerContextCore> context_; 301 base::WeakPtr<ServiceWorkerContextCore> context_;
297 scoped_refptr<EmbeddedWorkerRegistry> registry_; 302 scoped_refptr<EmbeddedWorkerRegistry> registry_;
298 303
299 // Unique within an EmbeddedWorkerRegistry. 304 // Unique within an EmbeddedWorkerRegistry.
300 const int embedded_worker_id_; 305 const int embedded_worker_id_;
301 306
302 EmbeddedWorkerStatus status_; 307 EmbeddedWorkerStatus status_;
303 StartingPhase starting_phase_; 308 StartingPhase starting_phase_;
304 309
305 // Current running information. 310 // Current running information.
falken 2016/09/07 05:01:42 This comment doesn't seem to fit the members on li
shimazu 2016/09/12 06:28:19 Done.
306 std::unique_ptr<EmbeddedWorkerInstance::WorkerProcessHandle> process_handle_; 311 std::unique_ptr<EmbeddedWorkerInstance::WorkerProcessHandle> process_handle_;
307 int thread_id_; 312 int thread_id_;
308 std::unique_ptr<shell::InterfaceRegistry> interface_registry_; 313 std::unique_ptr<shell::InterfaceRegistry> interface_registry_;
309 std::unique_ptr<shell::InterfaceProvider> remote_interfaces_; 314 std::unique_ptr<shell::InterfaceProvider> remote_interfaces_;
315 mojom::EmbeddedWorkerInstanceClientPtr instance_client_;
falken 2016/09/07 05:01:41 nit: Since this is a member of EmbeddedWorkerInsta
shimazu 2016/09/12 06:28:19 Done.
310 316
311 // Whether devtools is attached or not. 317 // Whether devtools is attached or not.
312 bool devtools_attached_; 318 bool devtools_attached_;
313 319
314 // True if the script load request accessed the network. If the script was 320 // True if the script load request accessed the network. If the script was
315 // served from HTTPCache or ServiceWorkerDatabase this value is false. 321 // served from HTTPCache or ServiceWorkerDatabase this value is false.
316 bool network_accessed_for_script_; 322 bool network_accessed_for_script_;
317 323
318 ListenerList listener_list_; 324 ListenerList listener_list_;
319 std::unique_ptr<DevToolsProxy> devtools_proxy_; 325 std::unique_ptr<DevToolsProxy> devtools_proxy_;
320 326
321 std::unique_ptr<StartTask> inflight_start_task_; 327 std::unique_ptr<StartTask> inflight_start_task_;
322 328
323 // This is valid only after a process is allocated for the worker. 329 // This is valid only after a process is allocated for the worker.
324 ServiceWorkerMetrics::StartSituation start_situation_ = 330 ServiceWorkerMetrics::StartSituation start_situation_ =
325 ServiceWorkerMetrics::StartSituation::UNKNOWN; 331 ServiceWorkerMetrics::StartSituation::UNKNOWN;
326 332
327 // Used for UMA. The start time of the current start sequence step. 333 // Used for UMA. The start time of the current start sequence step.
328 base::TimeTicks step_time_; 334 base::TimeTicks step_time_;
329 335
330 base::WeakPtrFactory<EmbeddedWorkerInstance> weak_factory_; 336 base::WeakPtrFactory<EmbeddedWorkerInstance> weak_factory_;
331 337
332 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerInstance); 338 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerInstance);
333 }; 339 };
334 340
335 } // namespace content 341 } // namespace content
336 342
337 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_ 343 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698