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

Side by Side Diff: chrome/common/chrome_plugin_lib.cc

Issue 164305: Ensure we don't load plugins on the IO thread (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #include "chrome/common/chrome_plugin_lib.h" 5 #include "chrome/common/chrome_plugin_lib.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/hash_tables.h" 8 #include "base/hash_tables.h"
9 #include "base/histogram.h" 9 #include "base/histogram.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 24 matching lines...) Expand all
35 PluginMap; 35 PluginMap;
36 36
37 // A map of all the instantiated plugins. 37 // A map of all the instantiated plugins.
38 static PluginMap* g_loaded_libs; 38 static PluginMap* g_loaded_libs;
39 39
40 // The thread plugins are loaded and used in, lazily initialized upon 40 // The thread plugins are loaded and used in, lazily initialized upon
41 // the first creation call. 41 // the first creation call.
42 static PlatformThreadId g_plugin_thread_id = 0; 42 static PlatformThreadId g_plugin_thread_id = 0;
43 static MessageLoop* g_plugin_thread_loop = NULL; 43 static MessageLoop* g_plugin_thread_loop = NULL;
44 44
45 #ifdef GEARS_STATIC_LIB
46 // defined in gears/base/chrome/module_cr.cc
47 CPError STDCALL Gears_CP_Initialize(CPID id, const CPBrowserFuncs *bfuncs,
48 CPPluginFuncs *pfuncs);
49 #endif
50
51 static bool IsSingleProcessMode() { 45 static bool IsSingleProcessMode() {
52 // We don't support ChromePlugins in single-process mode. 46 // We don't support ChromePlugins in single-process mode.
53 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess); 47 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess);
54 } 48 }
55 49
56 // static 50 // static
57 bool ChromePluginLib::IsInitialized() { 51 bool ChromePluginLib::IsInitialized() {
58 return (g_loaded_libs != NULL); 52 return (g_loaded_libs != NULL);
59 } 53 }
60 54
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 107
114 // static 108 // static
115 void ChromePluginLib::RegisterPluginsWithNPAPI() { 109 void ChromePluginLib::RegisterPluginsWithNPAPI() {
116 // We don't support ChromePlugins in single-process mode. 110 // We don't support ChromePlugins in single-process mode.
117 if (IsSingleProcessMode()) 111 if (IsSingleProcessMode())
118 return; 112 return;
119 113
120 FilePath path; 114 FilePath path;
121 if (!PathService::Get(chrome::FILE_GEARS_PLUGIN, &path)) 115 if (!PathService::Get(chrome::FILE_GEARS_PLUGIN, &path))
122 return; 116 return;
123 // Note: we can only access the NPAPI list because the PluginService has done 117 NPAPI::PluginList::Singleton()->AddExtraPluginPath(path);
124 // the locking for us. We should not touch it anywhere else.
125 NPAPI::PluginList::AddExtraPluginPath(path);
126 } 118 }
127 119
128 static void LogPluginLoadTime(const TimeDelta &time) { 120 static void LogPluginLoadTime(const TimeDelta &time) {
129 UMA_HISTOGRAM_TIMES("Gears.LoadTime", time); 121 UMA_HISTOGRAM_TIMES("Gears.LoadTime", time);
130 } 122 }
131 123
132 // static 124 // static
133 void ChromePluginLib::LoadChromePlugins(const CPBrowserFuncs* bfuncs) { 125 void ChromePluginLib::LoadChromePlugins(const CPBrowserFuncs* bfuncs) {
134 static bool loaded = false; 126 static bool loaded = false;
135 if (loaded) 127 if (loaded)
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 return -1; 238 return -1;
247 return CP_Test_(param); 239 return CP_Test_(param);
248 } 240 }
249 241
250 bool ChromePluginLib::Load() { 242 bool ChromePluginLib::Load() {
251 #if !defined(OS_WIN) 243 #if !defined(OS_WIN)
252 // Mac and Linux won't implement Gears. 244 // Mac and Linux won't implement Gears.
253 return false; 245 return false;
254 #else 246 #else
255 DCHECK(module_ == 0); 247 DCHECK(module_ == 0);
256 #ifdef GEARS_STATIC_LIB
257 FilePath path;
258 if (filename_.BaseName().value().find(FILE_PATH_LITERAL("gears")) == 0) {
259 CP_Initialize_ = &Gears_CP_Initialize;
260 return true;
261 }
262 #endif
263 248
264 module_ = LoadLibrary(filename_.value().c_str()); 249 module_ = LoadLibrary(filename_.value().c_str());
265 if (module_ == 0) 250 if (module_ == 0)
266 return false; 251 return false;
267 252
268 // required initialization function 253 // required initialization function
269 CP_Initialize_ = reinterpret_cast<CP_InitializeFunc> 254 CP_Initialize_ = reinterpret_cast<CP_InitializeFunc>
270 (GetProcAddress(module_, "CP_Initialize")); 255 (GetProcAddress(module_, "CP_Initialize"));
271 256
272 if (!CP_Initialize_) { 257 if (!CP_Initialize_) {
(...skipping 23 matching lines...) Expand all
296 if (initialized_) 281 if (initialized_)
297 CP_Shutdown(); 282 CP_Shutdown();
298 283
299 #if defined(OS_WIN) 284 #if defined(OS_WIN)
300 if (module_) { 285 if (module_) {
301 FreeLibrary(module_); 286 FreeLibrary(module_);
302 module_ = 0; 287 module_ = 0;
303 } 288 }
304 #endif 289 #endif
305 } 290 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/resource_message_filter.cc ('k') | chrome/common/render_messages_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698