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

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: Rebase Created 4 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
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 // Called back from StartTask after a reference to the renderer registry is
228 // provided.
229 void OnGotRemoteEmbeddedWorkerInstanceClient(
230 std::unique_ptr<EmbeddedWorkerMsg_StartWorker_Params> params,
231 mojom::EmbeddedWorkerInstanceClientPtr client);
232
233 // Sends StartWorker message via Mojo.
234 void SendMojoStartWorker(
235 std::unique_ptr<EmbeddedWorkerMsg_StartWorker_Params> params);
236
226 // Called back from StartTask after a start worker message is sent. 237 // Called back from StartTask after a start worker message is sent.
227 void OnStartWorkerMessageSent(); 238 void OnStartWorkerMessageSent();
228 239
229 // Called back from Registry when the worker instance has ack'ed that 240 // Called back from Registry when the worker instance has ack'ed that
230 // it is ready for inspection. 241 // it is ready for inspection.
231 void OnReadyForInspection(); 242 void OnReadyForInspection();
232 243
233 // Called back from Registry when the worker instance has ack'ed that 244 // Called back from Registry when the worker instance has ack'ed that
234 // it finished loading the script. 245 // it finished loading the script.
235 void OnScriptLoaded(); 246 void OnScriptLoaded();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 const int embedded_worker_id_; 311 const int embedded_worker_id_;
301 312
302 EmbeddedWorkerStatus status_; 313 EmbeddedWorkerStatus status_;
303 StartingPhase starting_phase_; 314 StartingPhase starting_phase_;
304 315
305 // Current running information. 316 // Current running information.
306 std::unique_ptr<EmbeddedWorkerInstance::WorkerProcessHandle> process_handle_; 317 std::unique_ptr<EmbeddedWorkerInstance::WorkerProcessHandle> process_handle_;
307 int thread_id_; 318 int thread_id_;
308 std::unique_ptr<shell::InterfaceRegistry> interface_registry_; 319 std::unique_ptr<shell::InterfaceRegistry> interface_registry_;
309 std::unique_ptr<shell::InterfaceProvider> remote_interfaces_; 320 std::unique_ptr<shell::InterfaceProvider> remote_interfaces_;
321 mojom::EmbeddedWorkerInstanceClientPtr instance_client_;
310 322
311 // Whether devtools is attached or not. 323 // Whether devtools is attached or not.
312 bool devtools_attached_; 324 bool devtools_attached_;
313 325
314 // True if the script load request accessed the network. If the script was 326 // True if the script load request accessed the network. If the script was
315 // served from HTTPCache or ServiceWorkerDatabase this value is false. 327 // served from HTTPCache or ServiceWorkerDatabase this value is false.
316 bool network_accessed_for_script_; 328 bool network_accessed_for_script_;
317 329
318 ListenerList listener_list_; 330 ListenerList listener_list_;
319 std::unique_ptr<DevToolsProxy> devtools_proxy_; 331 std::unique_ptr<DevToolsProxy> devtools_proxy_;
320 332
321 std::unique_ptr<StartTask> inflight_start_task_; 333 std::unique_ptr<StartTask> inflight_start_task_;
322 334
323 // This is valid only after a process is allocated for the worker. 335 // This is valid only after a process is allocated for the worker.
324 ServiceWorkerMetrics::StartSituation start_situation_ = 336 ServiceWorkerMetrics::StartSituation start_situation_ =
325 ServiceWorkerMetrics::StartSituation::UNKNOWN; 337 ServiceWorkerMetrics::StartSituation::UNKNOWN;
326 338
327 // Used for UMA. The start time of the current start sequence step. 339 // Used for UMA. The start time of the current start sequence step.
328 base::TimeTicks step_time_; 340 base::TimeTicks step_time_;
329 341
330 base::WeakPtrFactory<EmbeddedWorkerInstance> weak_factory_; 342 base::WeakPtrFactory<EmbeddedWorkerInstance> weak_factory_;
331 343
332 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerInstance); 344 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerInstance);
333 }; 345 };
334 346
335 } // namespace content 347 } // namespace content
336 348
337 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_ 349 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698