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

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

Issue 2375943002: Revert of ServiceWorker: Implement StartWorker by using mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 2 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_DISPATCHER_H_ 5 #ifndef CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_DISPATCHER_H_
6 #define CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_DISPATCHER_H_ 6 #define CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_DISPATCHER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory>
10 9
11 #include "base/id_map.h" 10 #include "base/id_map.h"
12 #include "base/macros.h" 11 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
14 #include "base/time/time.h" 13 #include "base/time/time.h"
15 #include "content/child/scoped_child_process_reference.h"
16 #include "content/public/common/console_message_level.h" 14 #include "content/public/common/console_message_level.h"
17 #include "ipc/ipc_listener.h" 15 #include "ipc/ipc_listener.h"
18 16
17 struct EmbeddedWorkerMsg_StartWorker_Params;
19 class GURL; 18 class GURL;
20 19
21 namespace blink {
22
23 class WebEmbeddedWorker;
24
25 } // namespace blink
26
27 namespace content { 20 namespace content {
28 21
29 class EmbeddedWorkerDevToolsAgent;
30 class ServiceWorkerContextClient;
31 struct EmbeddedWorkerStartParams;
32
33 // A tiny dispatcher which handles embedded worker start/stop messages. 22 // A tiny dispatcher which handles embedded worker start/stop messages.
34 class EmbeddedWorkerDispatcher : public IPC::Listener { 23 class EmbeddedWorkerDispatcher : public IPC::Listener {
35 public: 24 public:
36 EmbeddedWorkerDispatcher(); 25 EmbeddedWorkerDispatcher();
37 ~EmbeddedWorkerDispatcher() override; 26 ~EmbeddedWorkerDispatcher() override;
38 27
39 // IPC::Listener overrides. 28 // IPC::Listener overrides.
40 bool OnMessageReceived(const IPC::Message& message) override; 29 bool OnMessageReceived(const IPC::Message& message) override;
41 30
42 void WorkerContextDestroyed(int embedded_worker_id); 31 void WorkerContextDestroyed(int embedded_worker_id);
43 32
44 private: 33 private:
45 friend class EmbeddedWorkerInstanceClientImpl; 34 class WorkerWrapper;
46 35
47 // A thin wrapper of WebEmbeddedWorker which also adds and releases process 36 void OnStartWorker(const EmbeddedWorkerMsg_StartWorker_Params& params);
48 // references automatically.
49 class WorkerWrapper {
50 public:
51 WorkerWrapper(blink::WebEmbeddedWorker* worker,
52 int devtools_agent_route_id);
53 ~WorkerWrapper();
54
55 blink::WebEmbeddedWorker* worker() { return worker_.get(); }
56
57 private:
58 ScopedChildProcessReference process_ref_;
59 std::unique_ptr<blink::WebEmbeddedWorker> worker_;
60 std::unique_ptr<EmbeddedWorkerDevToolsAgent> dev_tools_agent_;
61 };
62
63 void OnStartWorker(const EmbeddedWorkerStartParams& params);
64 void OnStopWorker(int embedded_worker_id); 37 void OnStopWorker(int embedded_worker_id);
65 void OnResumeAfterDownload(int embedded_worker_id); 38 void OnResumeAfterDownload(int embedded_worker_id);
66 void OnAddMessageToConsole(int embedded_worker_id, 39 void OnAddMessageToConsole(int embedded_worker_id,
67 ConsoleMessageLevel level, 40 ConsoleMessageLevel level,
68 const std::string& message); 41 const std::string& message);
69 42
70 std::unique_ptr<WorkerWrapper> StartWorkerContext(
71 const EmbeddedWorkerStartParams& params,
72 std::unique_ptr<ServiceWorkerContextClient> context_client);
73 void RegisterWorker(int embedded_worker_id,
74 std::unique_ptr<WorkerWrapper> wrapper);
75
76 IDMap<WorkerWrapper, IDMapOwnPointer> workers_; 43 IDMap<WorkerWrapper, IDMapOwnPointer> workers_;
77 std::map<int /* embedded_worker_id */, base::TimeTicks> stop_worker_times_; 44 std::map<int /* embedded_worker_id */, base::TimeTicks> stop_worker_times_;
78 base::WeakPtrFactory<EmbeddedWorkerDispatcher> weak_factory_; 45 base::WeakPtrFactory<EmbeddedWorkerDispatcher> weak_factory_;
79 46
80 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerDispatcher); 47 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerDispatcher);
81 }; 48 };
82 49
83 } // namespace content 50 } // namespace content
84 51
85 #endif // CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_DISPATCHER_H_ 52 #endif // CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_DISPATCHER_H_
OLDNEW
« no previous file with comments | « content/renderer/render_thread_impl.cc ('k') | content/renderer/service_worker/embedded_worker_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698