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

Side by Side Diff: extensions/renderer/dispatcher.h

Issue 1293673002: Create thread-safe RendererExtensionRegistry from ExtensionSet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « extensions/extensions.gypi ('k') | extensions/renderer/dispatcher.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 EXTENSIONS_RENDERER_DISPATCHER_H_ 5 #ifndef EXTENSIONS_RENDERER_DISPATCHER_H_
6 #define EXTENSIONS_RENDERER_DISPATCHER_H_ 6 #define EXTENSIONS_RENDERER_DISPATCHER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/scoped_observer.h" 15 #include "base/scoped_observer.h"
16 #include "base/timer/timer.h" 16 #include "base/timer/timer.h"
17 #include "content/public/renderer/render_process_observer.h" 17 #include "content/public/renderer/render_process_observer.h"
18 #include "extensions/common/event_filter.h" 18 #include "extensions/common/event_filter.h"
19 #include "extensions/common/extension.h" 19 #include "extensions/common/extension.h"
20 #include "extensions/common/extension_set.h"
21 #include "extensions/common/extensions_client.h" 20 #include "extensions/common/extensions_client.h"
22 #include "extensions/common/features/feature.h" 21 #include "extensions/common/features/feature.h"
23 #include "extensions/renderer/resource_bundle_source_map.h" 22 #include "extensions/renderer/resource_bundle_source_map.h"
24 #include "extensions/renderer/script_context.h" 23 #include "extensions/renderer/script_context.h"
25 #include "extensions/renderer/script_context_set.h" 24 #include "extensions/renderer/script_context_set.h"
26 #include "extensions/renderer/user_script_set_manager.h" 25 #include "extensions/renderer/user_script_set_manager.h"
27 #include "extensions/renderer/v8_schema_registry.h" 26 #include "extensions/renderer/v8_schema_registry.h"
28 #include "third_party/WebKit/public/platform/WebString.h" 27 #include "third_party/WebKit/public/platform/WebString.h"
29 #include "third_party/WebKit/public/platform/WebVector.h" 28 #include "third_party/WebKit/public/platform/WebVector.h"
30 #include "v8/include/v8.h" 29 #include "v8/include/v8.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 class Dispatcher : public content::RenderProcessObserver, 66 class Dispatcher : public content::RenderProcessObserver,
68 public UserScriptSetManager::Observer { 67 public UserScriptSetManager::Observer {
69 public: 68 public:
70 explicit Dispatcher(DispatcherDelegate* delegate); 69 explicit Dispatcher(DispatcherDelegate* delegate);
71 ~Dispatcher() override; 70 ~Dispatcher() override;
72 71
73 const std::set<std::string>& function_names() const { 72 const std::set<std::string>& function_names() const {
74 return function_names_; 73 return function_names_;
75 } 74 }
76 75
77 const ExtensionSet* extensions() const { return &extensions_; }
78
79 const ScriptContextSet& script_context_set() const { 76 const ScriptContextSet& script_context_set() const {
80 return *script_context_set_; 77 return *script_context_set_;
81 } 78 }
82 79
83 V8SchemaRegistry* v8_schema_registry() { return v8_schema_registry_.get(); } 80 V8SchemaRegistry* v8_schema_registry() { return v8_schema_registry_.get(); }
84 81
85 ContentWatcher* content_watcher() { return content_watcher_.get(); } 82 ContentWatcher* content_watcher() { return content_watcher_.get(); }
86 83
87 RequestSender* request_sender() { return request_sender_.get(); } 84 RequestSender* request_sender() { return request_sender_.get(); }
88 85
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 static void RegisterNativeHandlers(ModuleSystem* module_system, 128 static void RegisterNativeHandlers(ModuleSystem* module_system,
132 ScriptContext* context, 129 ScriptContext* context,
133 Dispatcher* dispatcher, 130 Dispatcher* dispatcher,
134 RequestSender* request_sender, 131 RequestSender* request_sender,
135 V8SchemaRegistry* v8_schema_registry); 132 V8SchemaRegistry* v8_schema_registry);
136 133
137 bool WasWebRequestUsedBySomeExtensions() const { return webrequest_used_; } 134 bool WasWebRequestUsedBySomeExtensions() const { return webrequest_used_; }
138 135
139 private: 136 private:
140 // The RendererPermissionsPolicyDelegateTest.CannotScriptWebstore test needs 137 // The RendererPermissionsPolicyDelegateTest.CannotScriptWebstore test needs
141 // to call LoadExtensionForTest and the OnActivateExtension IPCs. 138 // to call the OnActivateExtension IPCs.
142 friend class ::ChromeRenderViewTest; 139 friend class ::ChromeRenderViewTest;
143 FRIEND_TEST_ALL_PREFIXES(RendererPermissionsPolicyDelegateTest, 140 FRIEND_TEST_ALL_PREFIXES(RendererPermissionsPolicyDelegateTest,
144 CannotScriptWebstore); 141 CannotScriptWebstore);
145 142
146 // Inserts an Extension into |extensions_|. Normally the only way to do this
147 // would be through the ExtensionMsg_Loaded IPC (OnLoaded) but this can't be
148 // triggered for tests, because in the process of serializing then
149 // deserializing the IPC, Extension IDs manually set for testing are lost.
150 void LoadExtensionForTest(const Extension* extension);
151
152 // RenderProcessObserver implementation: 143 // RenderProcessObserver implementation:
153 bool OnControlMessageReceived(const IPC::Message& message) override; 144 bool OnControlMessageReceived(const IPC::Message& message) override;
154 void WebKitInitialized() override; 145 void WebKitInitialized() override;
155 void IdleNotification() override; 146 void IdleNotification() override;
156 void OnRenderProcessShutdown() override; 147 void OnRenderProcessShutdown() override;
157 148
158 void OnActivateExtension(const std::string& extension_id); 149 void OnActivateExtension(const std::string& extension_id);
159 void OnCancelSuspend(const std::string& extension_id); 150 void OnCancelSuspend(const std::string& extension_id);
160 void OnDeliverMessage(int target_port_id, const Message& message); 151 void OnDeliverMessage(int target_port_id, const Message& message);
161 void OnDispatchOnConnect(int target_port_id, 152 void OnDispatchOnConnect(int target_port_id,
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 // Adds features that are specific to the current channel. 245 // Adds features that are specific to the current channel.
255 void AddChannelSpecificFeatures(); 246 void AddChannelSpecificFeatures();
256 247
257 // The delegate for this dispatcher. Not owned, but must extend beyond the 248 // The delegate for this dispatcher. Not owned, but must extend beyond the
258 // Dispatcher's own lifetime. 249 // Dispatcher's own lifetime.
259 DispatcherDelegate* delegate_; 250 DispatcherDelegate* delegate_;
260 251
261 // True if the IdleNotification timer should be set. 252 // True if the IdleNotification timer should be set.
262 bool set_idle_notifications_; 253 bool set_idle_notifications_;
263 254
264 // Contains all loaded extensions. This is essentially the renderer
265 // counterpart to ExtensionService in the browser. It contains information
266 // about all extensions currently loaded by the browser.
267 ExtensionSet extensions_;
268
269 // The IDs of extensions that failed to load, mapped to the error message 255 // The IDs of extensions that failed to load, mapped to the error message
270 // generated on failure. 256 // generated on failure.
271 std::map<std::string, std::string> extension_load_errors_; 257 std::map<std::string, std::string> extension_load_errors_;
272 258
273 // All the bindings contexts that are currently loaded for this renderer. 259 // All the bindings contexts that are currently loaded for this renderer.
274 // There is zero or one for each v8 context. 260 // There is zero or one for each v8 context.
275 scoped_ptr<ScriptContextSet> script_context_set_; 261 scoped_ptr<ScriptContextSet> script_context_set_;
276 262
277 scoped_ptr<ContentWatcher> content_watcher_; 263 scoped_ptr<ContentWatcher> content_watcher_;
278 264
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 301
316 // Status of webrequest usage. 302 // Status of webrequest usage.
317 bool webrequest_used_; 303 bool webrequest_used_;
318 304
319 DISALLOW_COPY_AND_ASSIGN(Dispatcher); 305 DISALLOW_COPY_AND_ASSIGN(Dispatcher);
320 }; 306 };
321 307
322 } // namespace extensions 308 } // namespace extensions
323 309
324 #endif // EXTENSIONS_RENDERER_DISPATCHER_H_ 310 #endif // EXTENSIONS_RENDERER_DISPATCHER_H_
OLDNEW
« no previous file with comments | « extensions/extensions.gypi ('k') | extensions/renderer/dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698