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

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

Issue 252633003: Introduce worker_devtools_agent_route_id for EmbeddedWorker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit tests failure Created 6 years, 7 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_REGISTRY_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_REGISTRY_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_REGISTRY_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_REGISTRY_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/callback.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
15 #include "base/strings/string16.h" 16 #include "base/strings/string16.h"
16 #include "content/common/content_export.h" 17 #include "content/common/content_export.h"
17 #include "content/common/service_worker/service_worker_status_code.h" 18 #include "content/common/service_worker/service_worker_status_code.h"
18 19
19 class GURL; 20 class GURL;
20 21
21 namespace IPC { 22 namespace IPC {
(...skipping 21 matching lines...) Expand all
43 44
44 // Creates and removes a new worker instance entry for bookkeeping. 45 // Creates and removes a new worker instance entry for bookkeeping.
45 // This doesn't actually start or stop the worker. 46 // This doesn't actually start or stop the worker.
46 scoped_ptr<EmbeddedWorkerInstance> CreateWorker(); 47 scoped_ptr<EmbeddedWorkerInstance> CreateWorker();
47 48
48 // Called from EmbeddedWorkerInstance, relayed to the child process. 49 // Called from EmbeddedWorkerInstance, relayed to the child process.
49 ServiceWorkerStatusCode StartWorker(int process_id, 50 ServiceWorkerStatusCode StartWorker(int process_id,
50 int embedded_worker_id, 51 int embedded_worker_id,
51 int64 service_worker_version_id, 52 int64 service_worker_version_id,
52 const GURL& scope, 53 const GURL& scope,
53 const GURL& script_url); 54 const GURL& script_url,
55 int* worker_devtools_agent_route_id);
54 ServiceWorkerStatusCode StopWorker(int process_id, 56 ServiceWorkerStatusCode StopWorker(int process_id,
55 int embedded_worker_id); 57 int embedded_worker_id);
56 58
57 // Called back from EmbeddedWorker in the child process, relayed via 59 // Called back from EmbeddedWorker in the child process, relayed via
58 // ServiceWorkerDispatcherHost. 60 // ServiceWorkerDispatcherHost.
59 void OnWorkerStarted(int process_id, int thread_id, int embedded_worker_id); 61 void OnWorkerStarted(int process_id, int thread_id, int embedded_worker_id);
60 void OnWorkerStopped(int process_id, int embedded_worker_id); 62 void OnWorkerStopped(int process_id, int embedded_worker_id);
61 void OnReportException(int embedded_worker_id, 63 void OnReportException(int embedded_worker_id,
62 const base::string16& error_message, 64 const base::string16& error_message,
63 int line_number, 65 int line_number,
64 int column_number, 66 int column_number,
65 const GURL& source_url); 67 const GURL& source_url);
66 void OnReportConsoleMessage(int embedded_worker_id, 68 void OnReportConsoleMessage(int embedded_worker_id,
67 int source_identifier, 69 int source_identifier,
68 int message_level, 70 int message_level,
69 const base::string16& message, 71 const base::string16& message,
70 int line_number, 72 int line_number,
71 const GURL& source_url); 73 const GURL& source_url);
72 74
73 // Keeps a map from process_id to sender information. 75 // Keeps a map from process_id to sender information.
74 void AddChildProcessSender(int process_id, IPC::Sender* sender); 76 void AddChildProcessSender(int process_id, IPC::Sender* sender);
75 void RemoveChildProcessSender(int process_id); 77 void RemoveChildProcessSender(int process_id);
76 78
79 void AddChildProcessNextRoutingIDCallback(
80 int process_id,
81 const base::Callback<int(void)>& callback);
82 void RemoveChildProcessNextRoutingIDCallback(int process_id);
83
77 // Returns an embedded worker instance for given |embedded_worker_id|. 84 // Returns an embedded worker instance for given |embedded_worker_id|.
78 EmbeddedWorkerInstance* GetWorker(int embedded_worker_id); 85 EmbeddedWorkerInstance* GetWorker(int embedded_worker_id);
79 86
80 private: 87 private:
81 friend class base::RefCounted<EmbeddedWorkerRegistry>; 88 friend class base::RefCounted<EmbeddedWorkerRegistry>;
82 friend class EmbeddedWorkerInstance; 89 friend class EmbeddedWorkerInstance;
83 90
84 typedef std::map<int, EmbeddedWorkerInstance*> WorkerInstanceMap; 91 typedef std::map<int, EmbeddedWorkerInstance*> WorkerInstanceMap;
85 typedef std::map<int, IPC::Sender*> ProcessToSenderMap; 92 typedef std::map<int, IPC::Sender*> ProcessToSenderMap;
93 typedef std::map<int, const base::Callback<int(void)> >
94 ProcessToNextRoutingIDCallbackMap;
86 95
87 ~EmbeddedWorkerRegistry(); 96 ~EmbeddedWorkerRegistry();
88 ServiceWorkerStatusCode Send(int process_id, IPC::Message* message); 97 ServiceWorkerStatusCode Send(int process_id, IPC::Message* message);
89 98
90 // RemoveWorker is called when EmbeddedWorkerInstance is destructed. 99 // RemoveWorker is called when EmbeddedWorkerInstance is destructed.
91 // |process_id| could be invalid (i.e. -1) if it's not running. 100 // |process_id| could be invalid (i.e. -1) if it's not running.
92 void RemoveWorker(int process_id, int embedded_worker_id); 101 void RemoveWorker(int process_id, int embedded_worker_id);
93 102
94 base::WeakPtr<ServiceWorkerContextCore> context_; 103 base::WeakPtr<ServiceWorkerContextCore> context_;
95 104
96 WorkerInstanceMap worker_map_; 105 WorkerInstanceMap worker_map_;
97 ProcessToSenderMap process_sender_map_; 106 ProcessToSenderMap process_sender_map_;
107 ProcessToNextRoutingIDCallbackMap process_next_id_callback_map_;
98 108
99 // Map from process_id to embedded_worker_id. 109 // Map from process_id to embedded_worker_id.
100 // This map only contains running workers. 110 // This map only contains running workers.
101 std::map<int, std::set<int> > worker_process_map_; 111 std::map<int, std::set<int> > worker_process_map_;
102 112
103 int next_embedded_worker_id_; 113 int next_embedded_worker_id_;
104 114
105 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerRegistry); 115 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerRegistry);
106 }; 116 };
107 117
108 } // namespace content 118 } // namespace content
109 119
110 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_REGISTRY_H_ 120 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698