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

Side by Side Diff: webkit/plugins/ppapi/plugin_module.cc

Issue 8344025: Add a new globals object for PPAPI tracking information. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
« no previous file with comments | « webkit/plugins/ppapi/npobject_var.cc ('k') | webkit/plugins/ppapi/plugin_object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Deleted: svn:mergeinfo
Reverse-merged /branches/chrome_webkit_merge_branch/src/webkit/plugins/ppapi/plugin_module.cc:r3734-4217,4606-5108,5177-5263
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "webkit/plugins/ppapi/plugin_module.h" 5 #include "webkit/plugins/ppapi/plugin_module.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 #include "ppapi/c/trusted/ppb_graphics_3d_trusted.h" 83 #include "ppapi/c/trusted/ppb_graphics_3d_trusted.h"
84 #include "ppapi/c/trusted/ppb_image_data_trusted.h" 84 #include "ppapi/c/trusted/ppb_image_data_trusted.h"
85 #include "ppapi/c/trusted/ppb_url_loader_trusted.h" 85 #include "ppapi/c/trusted/ppb_url_loader_trusted.h"
86 #include "ppapi/shared_impl/input_event_impl.h" 86 #include "ppapi/shared_impl/input_event_impl.h"
87 #include "ppapi/shared_impl/time_conversion.h" 87 #include "ppapi/shared_impl/time_conversion.h"
88 #include "ppapi/thunk/enter.h" 88 #include "ppapi/thunk/enter.h"
89 #include "ppapi/thunk/thunk.h" 89 #include "ppapi/thunk/thunk.h"
90 #include "webkit/plugins/plugin_switches.h" 90 #include "webkit/plugins/plugin_switches.h"
91 #include "webkit/plugins/ppapi/callbacks.h" 91 #include "webkit/plugins/ppapi/callbacks.h"
92 #include "webkit/plugins/ppapi/common.h" 92 #include "webkit/plugins/ppapi/common.h"
93 #include "webkit/plugins/ppapi/host_globals.h"
93 #include "webkit/plugins/ppapi/ppapi_interface_factory.h" 94 #include "webkit/plugins/ppapi/ppapi_interface_factory.h"
94 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 95 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
95 #include "webkit/plugins/ppapi/ppb_directory_reader_impl.h" 96 #include "webkit/plugins/ppapi/ppb_directory_reader_impl.h"
96 #include "webkit/plugins/ppapi/ppb_flash_clipboard_impl.h" 97 #include "webkit/plugins/ppapi/ppb_flash_clipboard_impl.h"
97 #include "webkit/plugins/ppapi/ppb_flash_file_impl.h" 98 #include "webkit/plugins/ppapi/ppb_flash_file_impl.h"
98 #include "webkit/plugins/ppapi/ppb_flash_impl.h" 99 #include "webkit/plugins/ppapi/ppb_flash_impl.h"
99 #include "webkit/plugins/ppapi/ppb_flash_menu_impl.h" 100 #include "webkit/plugins/ppapi/ppb_flash_menu_impl.h"
100 #include "webkit/plugins/ppapi/ppb_flash_net_connector_impl.h" 101 #include "webkit/plugins/ppapi/ppb_flash_net_connector_impl.h"
101 #include "webkit/plugins/ppapi/ppb_font_impl.h" 102 #include "webkit/plugins/ppapi/ppb_font_impl.h"
102 #include "webkit/plugins/ppapi/ppb_gpu_blacklist_private_impl.h" 103 #include "webkit/plugins/ppapi/ppb_gpu_blacklist_private_impl.h"
103 #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h" 104 #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h"
104 #include "webkit/plugins/ppapi/ppb_image_data_impl.h" 105 #include "webkit/plugins/ppapi/ppb_image_data_impl.h"
105 #include "webkit/plugins/ppapi/ppb_layer_compositor_impl.h" 106 #include "webkit/plugins/ppapi/ppb_layer_compositor_impl.h"
106 #include "webkit/plugins/ppapi/ppb_opengles_impl.h" 107 #include "webkit/plugins/ppapi/ppb_opengles_impl.h"
107 #include "webkit/plugins/ppapi/ppb_proxy_impl.h" 108 #include "webkit/plugins/ppapi/ppb_proxy_impl.h"
108 #include "webkit/plugins/ppapi/ppb_scrollbar_impl.h" 109 #include "webkit/plugins/ppapi/ppb_scrollbar_impl.h"
109 #include "webkit/plugins/ppapi/ppb_uma_private_impl.h" 110 #include "webkit/plugins/ppapi/ppb_uma_private_impl.h"
110 #include "webkit/plugins/ppapi/ppb_var_impl.h" 111 #include "webkit/plugins/ppapi/ppb_var_impl.h"
111 #include "webkit/plugins/ppapi/ppb_video_capture_impl.h" 112 #include "webkit/plugins/ppapi/ppb_video_capture_impl.h"
112 #include "webkit/plugins/ppapi/ppb_video_decoder_impl.h" 113 #include "webkit/plugins/ppapi/ppb_video_decoder_impl.h"
113 #include "webkit/plugins/ppapi/ppb_video_layer_impl.h" 114 #include "webkit/plugins/ppapi/ppb_video_layer_impl.h"
114 #include "webkit/plugins/ppapi/resource_tracker.h" 115 #include "webkit/plugins/ppapi/resource_tracker.h"
115 #include "webkit/plugins/ppapi/webkit_forwarding_impl.h" 116 #include "webkit/plugins/ppapi/webkit_forwarding_impl.h"
116 117
118 using ppapi::PpapiGlobals;
117 using ppapi::TimeTicksToPPTimeTicks; 119 using ppapi::TimeTicksToPPTimeTicks;
118 using ppapi::TimeToPPTime; 120 using ppapi::TimeToPPTime;
119 using ppapi::thunk::EnterResource; 121 using ppapi::thunk::EnterResource;
120 using ppapi::thunk::PPB_Graphics2D_API; 122 using ppapi::thunk::PPB_Graphics2D_API;
121 123
122 namespace webkit { 124 namespace webkit {
123 namespace ppapi { 125 namespace ppapi {
124 126
125 namespace { 127 namespace {
126 128
129 // Global tracking info for PPAPI plugins. This is lazily created before the
130 // first plugin is allocated, and leaked on shutdown.
131 //
132 // Note that we don't want a Singleton here since destroying this object will
133 // try to free some stuff that requires WebKit, and Singletons are destroyed
134 // after WebKit.
135 webkit::ppapi::HostGlobals* host_globals = NULL;
136
127 // Maintains all currently loaded plugin libs for validating PP_Module 137 // Maintains all currently loaded plugin libs for validating PP_Module
128 // identifiers. 138 // identifiers.
129 typedef std::set<PluginModule*> PluginModuleSet; 139 typedef std::set<PluginModule*> PluginModuleSet;
130 140
131 PluginModuleSet* GetLivePluginSet() { 141 PluginModuleSet* GetLivePluginSet() {
132 static PluginModuleSet live_plugin_libs; 142 static PluginModuleSet live_plugin_libs;
133 return &live_plugin_libs; 143 return &live_plugin_libs;
134 } 144 }
135 145
136 base::MessageLoopProxy* GetMainThreadMessageLoop() { 146 base::MessageLoopProxy* GetMainThreadMessageLoop() {
137 static scoped_refptr<base::MessageLoopProxy> proxy( 147 static scoped_refptr<base::MessageLoopProxy> proxy(
138 base::MessageLoopProxy::current()); 148 base::MessageLoopProxy::current());
139 return proxy.get(); 149 return proxy.get();
140 } 150 }
141 151
142 // PPB_Core -------------------------------------------------------------------- 152 // PPB_Core --------------------------------------------------------------------
143 153
144 void AddRefResource(PP_Resource resource) { 154 void AddRefResource(PP_Resource resource) {
145 ResourceTracker::Get()->AddRefResource(resource); 155 PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(resource);
146 } 156 }
147 157
148 void ReleaseResource(PP_Resource resource) { 158 void ReleaseResource(PP_Resource resource) {
149 ResourceTracker::Get()->ReleaseResource(resource); 159 PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(resource);
150 } 160 }
151 161
152 PP_Time GetTime() { 162 PP_Time GetTime() {
153 return TimeToPPTime(base::Time::Now()); 163 return TimeToPPTime(base::Time::Now());
154 } 164 }
155 165
156 PP_TimeTicks GetTickTime() { 166 PP_TimeTicks GetTickTime() {
157 return TimeTicksToPPTimeTicks(base::TimeTicks::Now()); 167 return TimeTicksToPPTimeTicks(base::TimeTicks::Now());
158 } 168 }
159 169
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 MessageLoop::current()->SetNestableTasksAllowed(true); 208 MessageLoop::current()->SetNestableTasksAllowed(true);
199 MessageLoop::current()->Run(); 209 MessageLoop::current()->Run();
200 MessageLoop::current()->SetNestableTasksAllowed(old_state); 210 MessageLoop::current()->SetNestableTasksAllowed(old_state);
201 } 211 }
202 212
203 void QuitMessageLoop(PP_Instance instance) { 213 void QuitMessageLoop(PP_Instance instance) {
204 MessageLoop::current()->QuitNow(); 214 MessageLoop::current()->QuitNow();
205 } 215 }
206 216
207 uint32_t GetLiveObjectsForInstance(PP_Instance instance_id) { 217 uint32_t GetLiveObjectsForInstance(PP_Instance instance_id) {
208 return ResourceTracker::Get()->GetLiveObjectsForInstance(instance_id); 218 return HostGlobals::Get()->host_resource_tracker()->GetLiveObjectsForInstance(
219 instance_id);
209 } 220 }
210 221
211 PP_Bool IsOutOfProcess() { 222 PP_Bool IsOutOfProcess() {
212 return PP_FALSE; 223 return PP_FALSE;
213 } 224 }
214 225
215 const PPB_Testing_Dev testing_interface = { 226 const PPB_Testing_Dev testing_interface = {
216 &ReadImageData, 227 &ReadImageData,
217 &RunMessageLoop, 228 &RunMessageLoop,
218 &QuitMessageLoop, 229 &QuitMessageLoop,
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 PluginDelegate::ModuleLifetime* lifetime_delegate) 375 PluginDelegate::ModuleLifetime* lifetime_delegate)
365 : lifetime_delegate_(lifetime_delegate), 376 : lifetime_delegate_(lifetime_delegate),
366 callback_tracker_(new CallbackTracker), 377 callback_tracker_(new CallbackTracker),
367 is_in_destructor_(false), 378 is_in_destructor_(false),
368 is_crashed_(false), 379 is_crashed_(false),
369 broker_(NULL), 380 broker_(NULL),
370 library_(NULL), 381 library_(NULL),
371 name_(name), 382 name_(name),
372 path_(path), 383 path_(path),
373 reserve_instance_id_(NULL) { 384 reserve_instance_id_(NULL) {
385 // Ensure the globals object is created.
386 if (!host_globals)
387 host_globals = new HostGlobals;
388
374 memset(&entry_points_, 0, sizeof(entry_points_)); 389 memset(&entry_points_, 0, sizeof(entry_points_));
375 pp_module_ = ResourceTracker::Get()->AddModule(this); 390 pp_module_ = HostGlobals::Get()->host_resource_tracker()->AddModule(this);
376 GetMainThreadMessageLoop(); // Initialize the main thread message loop. 391 GetMainThreadMessageLoop(); // Initialize the main thread message loop.
377 GetLivePluginSet()->insert(this); 392 GetLivePluginSet()->insert(this);
378 } 393 }
379 394
380 PluginModule::~PluginModule() { 395 PluginModule::~PluginModule() {
381 // In the past there have been crashes reentering the plugin module 396 // In the past there have been crashes reentering the plugin module
382 // destructor. Catch if that happens again earlier. 397 // destructor. Catch if that happens again earlier.
383 CHECK(!is_in_destructor_); 398 CHECK(!is_in_destructor_);
384 is_in_destructor_ = true; 399 is_in_destructor_ = true;
385 400
386 // When the module is being deleted, there should be no more instances still 401 // When the module is being deleted, there should be no more instances still
387 // holding a reference to us. 402 // holding a reference to us.
388 DCHECK(instances_.empty()); 403 DCHECK(instances_.empty());
389 404
390 GetLivePluginSet()->erase(this); 405 GetLivePluginSet()->erase(this);
391 406
392 callback_tracker_->AbortAll(); 407 callback_tracker_->AbortAll();
393 408
394 if (entry_points_.shutdown_module) 409 if (entry_points_.shutdown_module)
395 entry_points_.shutdown_module(); 410 entry_points_.shutdown_module();
396 411
397 if (library_) 412 if (library_)
398 base::UnloadNativeLibrary(library_); 413 base::UnloadNativeLibrary(library_);
399 414
400 // Notifications that we've been deleted should be last. 415 // Notifications that we've been deleted should be last.
401 ResourceTracker::Get()->ModuleDeleted(pp_module_); 416 HostGlobals::Get()->host_resource_tracker()->ModuleDeleted(pp_module_);
402 if (!is_crashed_) { 417 if (!is_crashed_) {
403 // When the plugin crashes, we immediately tell the lifetime delegate that 418 // When the plugin crashes, we immediately tell the lifetime delegate that
404 // we're gone, so we don't want to tell it again. 419 // we're gone, so we don't want to tell it again.
405 lifetime_delegate_->PluginModuleDead(this); 420 lifetime_delegate_->PluginModuleDead(this);
406 } 421 }
407 422
408 // Don't add stuff here, the two notifications that the module object has 423 // Don't add stuff here, the two notifications that the module object has
409 // been deleted should be last. This allows, for example, 424 // been deleted should be last. This allows, for example,
410 // PPB_Proxy.IsInModuleDestructor to map PP_Module to this class during the 425 // PPB_Proxy.IsInModuleDestructor to map PP_Module to this class during the
411 // previous parts of the destructor. 426 // previous parts of the destructor.
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 int retval = entry_points.initialize_module(pp_module(), &GetInterface); 557 int retval = entry_points.initialize_module(pp_module(), &GetInterface);
543 if (retval != 0) { 558 if (retval != 0) {
544 LOG(WARNING) << "PPP_InitializeModule returned failure " << retval; 559 LOG(WARNING) << "PPP_InitializeModule returned failure " << retval;
545 return false; 560 return false;
546 } 561 }
547 return true; 562 return true;
548 } 563 }
549 564
550 } // namespace ppapi 565 } // namespace ppapi
551 } // namespace webkit 566 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/npobject_var.cc ('k') | webkit/plugins/ppapi/plugin_object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698