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

Side by Side Diff: chrome/browser/extensions/extension_service.cc

Issue 162183002: Don't attempt to unload the same extension twice if multiple ExtensionHost instances existed for th… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | « chrome/browser/extensions/extension_service.h ('k') | no next file » | 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/browser/extensions/extension_service.h" 5 #include "chrome/browser/extensions/extension_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <set> 9 #include <set>
10 10
(...skipping 2338 matching lines...) Expand 10 before | Expand all | Expand 10 after
2349 } 2349 }
2350 2350
2351 const Extension* ExtensionService::GetPendingExtensionUpdate( 2351 const Extension* ExtensionService::GetPendingExtensionUpdate(
2352 const std::string& id) const { 2352 const std::string& id) const {
2353 return delayed_installs_.GetByID(id); 2353 return delayed_installs_.GetByID(id);
2354 } 2354 }
2355 2355
2356 void ExtensionService::TrackTerminatedExtension(const Extension* extension) { 2356 void ExtensionService::TrackTerminatedExtension(const Extension* extension) {
2357 // No need to check for duplicates; inserting a duplicate is a no-op. 2357 // No need to check for duplicates; inserting a duplicate is a no-op.
2358 registry_->AddTerminated(make_scoped_refptr(extension)); 2358 registry_->AddTerminated(make_scoped_refptr(extension));
2359 extensions_being_terminated_.erase(extension->id());
2359 UnloadExtension(extension->id(), UnloadedExtensionInfo::REASON_TERMINATE); 2360 UnloadExtension(extension->id(), UnloadedExtensionInfo::REASON_TERMINATE);
2360 } 2361 }
2361 2362
2362 void ExtensionService::UntrackTerminatedExtension(const std::string& id) { 2363 void ExtensionService::UntrackTerminatedExtension(const std::string& id) {
2363 std::string lowercase_id = StringToLowerASCII(id); 2364 std::string lowercase_id = StringToLowerASCII(id);
2364 const Extension* extension = 2365 const Extension* extension =
2365 registry_->terminated_extensions().GetByID(lowercase_id); 2366 registry_->terminated_extensions().GetByID(lowercase_id);
2366 registry_->RemoveTerminated(lowercase_id); 2367 registry_->RemoveTerminated(lowercase_id);
2367 if (extension) { 2368 if (extension) {
2368 content::NotificationService::current()->Notify( 2369 content::NotificationService::current()->Notify(
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
2529 break; 2530 break;
2530 case chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED: { 2531 case chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED: {
2531 if (profile_ != 2532 if (profile_ !=
2532 content::Source<Profile>(source).ptr()->GetOriginalProfile()) { 2533 content::Source<Profile>(source).ptr()->GetOriginalProfile()) {
2533 break; 2534 break;
2534 } 2535 }
2535 2536
2536 extensions::ExtensionHost* host = 2537 extensions::ExtensionHost* host =
2537 content::Details<extensions::ExtensionHost>(details).ptr(); 2538 content::Details<extensions::ExtensionHost>(details).ptr();
2538 2539
2540 // If the extension is already being terminated, there is nothing left to
2541 // do.
2542 if (!extensions_being_terminated_.insert(host->extension_id()).second)
2543 break;
2544
2539 // Mark the extension as terminated and Unload it. We want it to 2545 // Mark the extension as terminated and Unload it. We want it to
2540 // be in a consistent state: either fully working or not loaded 2546 // be in a consistent state: either fully working or not loaded
2541 // at all, but never half-crashed. We do it in a PostTask so 2547 // at all, but never half-crashed. We do it in a PostTask so
2542 // that other handlers of this notification will still have 2548 // that other handlers of this notification will still have
2543 // access to the Extension and ExtensionHost. 2549 // access to the Extension and ExtensionHost.
2544 base::MessageLoop::current()->PostTask( 2550 base::MessageLoop::current()->PostTask(
2545 FROM_HERE, 2551 FROM_HERE,
2546 base::Bind( 2552 base::Bind(
2547 &ExtensionService::TrackTerminatedExtension, 2553 &ExtensionService::TrackTerminatedExtension,
2548 AsWeakPtr(), 2554 AsWeakPtr(),
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
2872 void ExtensionService::UnloadAllExtensionsInternal() { 2878 void ExtensionService::UnloadAllExtensionsInternal() {
2873 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); 2879 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions();
2874 2880
2875 registry_->ClearAll(); 2881 registry_->ClearAll();
2876 system_->runtime_data()->ClearAll(); 2882 system_->runtime_data()->ClearAll();
2877 2883
2878 // TODO(erikkay) should there be a notification for this? We can't use 2884 // TODO(erikkay) should there be a notification for this? We can't use
2879 // EXTENSION_UNLOADED since that implies that the extension has been disabled 2885 // EXTENSION_UNLOADED since that implies that the extension has been disabled
2880 // or uninstalled. 2886 // or uninstalled.
2881 } 2887 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698