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

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

Issue 8222021: Prevent reentrant destructors in the PluginModule. (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/plugin_module.h ('k') | webkit/plugins/ppapi/ppb_proxy_impl.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 (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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 shutdown_module(NULL) { 360 shutdown_module(NULL) {
361 } 361 }
362 362
363 // PluginModule ---------------------------------------------------------------- 363 // PluginModule ----------------------------------------------------------------
364 364
365 PluginModule::PluginModule(const std::string& name, 365 PluginModule::PluginModule(const std::string& name,
366 const FilePath& path, 366 const FilePath& path,
367 PluginDelegate::ModuleLifetime* lifetime_delegate) 367 PluginDelegate::ModuleLifetime* lifetime_delegate)
368 : lifetime_delegate_(lifetime_delegate), 368 : lifetime_delegate_(lifetime_delegate),
369 callback_tracker_(new CallbackTracker), 369 callback_tracker_(new CallbackTracker),
370 is_in_destructor_(false),
370 is_crashed_(false), 371 is_crashed_(false),
371 broker_(NULL), 372 broker_(NULL),
372 library_(NULL), 373 library_(NULL),
373 name_(name), 374 name_(name),
374 path_(path), 375 path_(path),
375 reserve_instance_id_(NULL) { 376 reserve_instance_id_(NULL) {
376 memset(&entry_points_, 0, sizeof(entry_points_)); 377 memset(&entry_points_, 0, sizeof(entry_points_));
377 pp_module_ = ResourceTracker::Get()->AddModule(this); 378 pp_module_ = ResourceTracker::Get()->AddModule(this);
378 GetMainThreadMessageLoop(); // Initialize the main thread message loop. 379 GetMainThreadMessageLoop(); // Initialize the main thread message loop.
379 GetLivePluginSet()->insert(this); 380 GetLivePluginSet()->insert(this);
380 } 381 }
381 382
382 PluginModule::~PluginModule() { 383 PluginModule::~PluginModule() {
384 // In the past there have been crashes reentering the plugin module
385 // destructor. Catch if that happens again earlier.
386 CHECK(!is_in_destructor_);
387 is_in_destructor_ = true;
388
383 // When the module is being deleted, there should be no more instances still 389 // When the module is being deleted, there should be no more instances still
384 // holding a reference to us. 390 // holding a reference to us.
385 DCHECK(instances_.empty()); 391 DCHECK(instances_.empty());
386 392
387 GetLivePluginSet()->erase(this); 393 GetLivePluginSet()->erase(this);
388 394
389 callback_tracker_->AbortAll(); 395 callback_tracker_->AbortAll();
390 396
391 if (entry_points_.shutdown_module) 397 if (entry_points_.shutdown_module)
392 entry_points_.shutdown_module(); 398 entry_points_.shutdown_module();
393 399
394 if (library_) 400 if (library_)
395 base::UnloadNativeLibrary(library_); 401 base::UnloadNativeLibrary(library_);
396 402
403 // Notifications that we've been deleted should be last.
397 ResourceTracker::Get()->ModuleDeleted(pp_module_); 404 ResourceTracker::Get()->ModuleDeleted(pp_module_);
405 if (!is_crashed_) {
406 // When the plugin crashes, we immediately tell the lifetime delegate that
407 // we're gone, so we don't want to tell it again.
408 lifetime_delegate_->PluginModuleDead(this);
409 }
398 410
399 // When the plugin crashes, we immediately tell the lifetime delegate that 411 // Don't add stuff here, the two notifications that the module object has
400 // we're gone, so we don't want to tell it again. 412 // been deleted should be last. This allows, for example,
401 if (!is_crashed_) 413 // PPB_Proxy.IsInModuleDestructor to map PP_Module to this class during the
402 lifetime_delegate_->PluginModuleDead(this); 414 // previous parts of the destructor.
403 } 415 }
404 416
405 bool PluginModule::InitAsInternalPlugin(const EntryPoints& entry_points) { 417 bool PluginModule::InitAsInternalPlugin(const EntryPoints& entry_points) {
406 if (InitializeModule(entry_points)) { 418 if (InitializeModule(entry_points)) {
407 entry_points_ = entry_points; 419 entry_points_ = entry_points;
408 return true; 420 return true;
409 } 421 }
410 return false; 422 return false;
411 } 423 }
412 424
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 int retval = entry_points.initialize_module(pp_module(), &GetInterface); 550 int retval = entry_points.initialize_module(pp_module(), &GetInterface);
539 if (retval != 0) { 551 if (retval != 0) {
540 LOG(WARNING) << "PPP_InitializeModule returned failure " << retval; 552 LOG(WARNING) << "PPP_InitializeModule returned failure " << retval;
541 return false; 553 return false;
542 } 554 }
543 return true; 555 return true;
544 } 556 }
545 557
546 } // namespace ppapi 558 } // namespace ppapi
547 } // namespace webkit 559 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/plugin_module.h ('k') | webkit/plugins/ppapi/ppb_proxy_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698