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

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
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 static void RegisterNativeHandlers(ModuleSystem* module_system, 123 static void RegisterNativeHandlers(ModuleSystem* module_system,
127 ScriptContext* context, 124 ScriptContext* context,
128 Dispatcher* dispatcher, 125 Dispatcher* dispatcher,
129 RequestSender* request_sender, 126 RequestSender* request_sender,
130 V8SchemaRegistry* v8_schema_registry); 127 V8SchemaRegistry* v8_schema_registry);
131 128
132 bool WasWebRequestUsedBySomeExtensions() const { return webrequest_used_; } 129 bool WasWebRequestUsedBySomeExtensions() const { return webrequest_used_; }
133 130
134 private: 131 private:
135 // The RendererPermissionsPolicyDelegateTest.CannotScriptWebstore test needs 132 // The RendererPermissionsPolicyDelegateTest.CannotScriptWebstore test needs
136 // to call LoadExtensionForTest and the OnActivateExtension IPCs. 133 // to call the OnActivateExtension IPCs.
137 friend class ::ChromeRenderViewTest; 134 friend class ::ChromeRenderViewTest;
138 FRIEND_TEST_ALL_PREFIXES(RendererPermissionsPolicyDelegateTest, 135 FRIEND_TEST_ALL_PREFIXES(RendererPermissionsPolicyDelegateTest,
139 CannotScriptWebstore); 136 CannotScriptWebstore);
140 137
141 // Inserts an Extension into |extensions_|. Normally the only way to do this
142 // would be through the ExtensionMsg_Loaded IPC (OnLoaded) but this can't be
143 // triggered for tests, because in the process of serializing then
144 // deserializing the IPC, Extension IDs manually set for testing are lost.
145 void LoadExtensionForTest(const Extension* extension);
146
147 // RenderProcessObserver implementation: 138 // RenderProcessObserver implementation:
148 bool OnControlMessageReceived(const IPC::Message& message) override; 139 bool OnControlMessageReceived(const IPC::Message& message) override;
149 void WebKitInitialized() override; 140 void WebKitInitialized() override;
150 void IdleNotification() override; 141 void IdleNotification() override;
151 void OnRenderProcessShutdown() override; 142 void OnRenderProcessShutdown() override;
152 143
153 void OnActivateExtension(const std::string& extension_id); 144 void OnActivateExtension(const std::string& extension_id);
154 void OnCancelSuspend(const std::string& extension_id); 145 void OnCancelSuspend(const std::string& extension_id);
155 void OnDeliverMessage(int target_port_id, const Message& message); 146 void OnDeliverMessage(int target_port_id, const Message& message);
156 void OnDispatchOnConnect(int target_port_id, 147 void OnDispatchOnConnect(int target_port_id,
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 // Adds features that are specific to the current channel. 240 // Adds features that are specific to the current channel.
250 void AddChannelSpecificFeatures(); 241 void AddChannelSpecificFeatures();
251 242
252 // The delegate for this dispatcher. Not owned, but must extend beyond the 243 // The delegate for this dispatcher. Not owned, but must extend beyond the
253 // Dispatcher's own lifetime. 244 // Dispatcher's own lifetime.
254 DispatcherDelegate* delegate_; 245 DispatcherDelegate* delegate_;
255 246
256 // True if the IdleNotification timer should be set. 247 // True if the IdleNotification timer should be set.
257 bool set_idle_notifications_; 248 bool set_idle_notifications_;
258 249
259 // Contains all loaded extensions. This is essentially the renderer
260 // counterpart to ExtensionService in the browser. It contains information
261 // about all extensions currently loaded by the browser.
262 ExtensionSet extensions_;
263
264 // The IDs of extensions that failed to load, mapped to the error message 250 // The IDs of extensions that failed to load, mapped to the error message
265 // generated on failure. 251 // generated on failure.
266 std::map<std::string, std::string> extension_load_errors_; 252 std::map<std::string, std::string> extension_load_errors_;
267 253
268 // All the bindings contexts that are currently loaded for this renderer. 254 // All the bindings contexts that are currently loaded for this renderer.
269 // There is zero or one for each v8 context. 255 // There is zero or one for each v8 context.
270 scoped_ptr<ScriptContextSet> script_context_set_; 256 scoped_ptr<ScriptContextSet> script_context_set_;
271 257
272 scoped_ptr<ContentWatcher> content_watcher_; 258 scoped_ptr<ContentWatcher> content_watcher_;
273 259
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 296
311 // Status of webrequest usage. 297 // Status of webrequest usage.
312 bool webrequest_used_; 298 bool webrequest_used_;
313 299
314 DISALLOW_COPY_AND_ASSIGN(Dispatcher); 300 DISALLOW_COPY_AND_ASSIGN(Dispatcher);
315 }; 301 };
316 302
317 } // namespace extensions 303 } // namespace extensions
318 304
319 #endif // EXTENSIONS_RENDERER_DISPATCHER_H_ 305 #endif // EXTENSIONS_RENDERER_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698