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

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

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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) 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 1948 matching lines...) Expand 10 before | Expand all | Expand 10 after
1959 } 1959 }
1960 1960
1961 void ExtensionService::GarbageCollectExtensions() { 1961 void ExtensionService::GarbageCollectExtensions() {
1962 if (extension_prefs_->pref_service()->ReadOnly()) 1962 if (extension_prefs_->pref_service()->ReadOnly())
1963 return; 1963 return;
1964 1964
1965 if (pending_extension_manager()->HasPendingExtensions()) { 1965 if (pending_extension_manager()->HasPendingExtensions()) {
1966 // Don't garbage collect while there are pending installations, which may 1966 // Don't garbage collect while there are pending installations, which may
1967 // be using the temporary installation directory. Try to garbage collect 1967 // be using the temporary installation directory. Try to garbage collect
1968 // again later. 1968 // again later.
1969 MessageLoop::current()->PostDelayedTask( 1969 base::MessageLoop::current()->PostDelayedTask(
1970 FROM_HERE, 1970 FROM_HERE,
1971 base::Bind(&ExtensionService::GarbageCollectExtensions, AsWeakPtr()), 1971 base::Bind(&ExtensionService::GarbageCollectExtensions, AsWeakPtr()),
1972 base::TimeDelta::FromSeconds(kGarbageCollectRetryDelay)); 1972 base::TimeDelta::FromSeconds(kGarbageCollectRetryDelay));
1973 return; 1973 return;
1974 } 1974 }
1975 1975
1976 scoped_ptr<extensions::ExtensionPrefs::ExtensionsInfo> info( 1976 scoped_ptr<extensions::ExtensionPrefs::ExtensionsInfo> info(
1977 extension_prefs_->GetInstalledExtensionsInfo()); 1977 extension_prefs_->GetInstalledExtensionsInfo());
1978 1978
1979 std::multimap<std::string, base::FilePath> extension_paths; 1979 std::multimap<std::string, base::FilePath> extension_paths;
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
2624 } 2624 }
2625 2625
2626 extensions::ExtensionHost* host = 2626 extensions::ExtensionHost* host =
2627 content::Details<extensions::ExtensionHost>(details).ptr(); 2627 content::Details<extensions::ExtensionHost>(details).ptr();
2628 2628
2629 // Mark the extension as terminated and Unload it. We want it to 2629 // Mark the extension as terminated and Unload it. We want it to
2630 // be in a consistent state: either fully working or not loaded 2630 // be in a consistent state: either fully working or not loaded
2631 // at all, but never half-crashed. We do it in a PostTask so 2631 // at all, but never half-crashed. We do it in a PostTask so
2632 // that other handlers of this notification will still have 2632 // that other handlers of this notification will still have
2633 // access to the Extension and ExtensionHost. 2633 // access to the Extension and ExtensionHost.
2634 MessageLoop::current()->PostTask( 2634 base::MessageLoop::current()->PostTask(
2635 FROM_HERE, 2635 FROM_HERE,
2636 base::Bind( 2636 base::Bind(&ExtensionService::TrackTerminatedExtension,
2637 &ExtensionService::TrackTerminatedExtension, 2637 AsWeakPtr(),
2638 AsWeakPtr(), 2638 host->extension()));
2639 host->extension()));
2640 break; 2639 break;
2641 } 2640 }
2642 case content::NOTIFICATION_RENDERER_PROCESS_CREATED: { 2641 case content::NOTIFICATION_RENDERER_PROCESS_CREATED: {
2643 content::RenderProcessHost* process = 2642 content::RenderProcessHost* process =
2644 content::Source<content::RenderProcessHost>(source).ptr(); 2643 content::Source<content::RenderProcessHost>(source).ptr();
2645 Profile* host_profile = 2644 Profile* host_profile =
2646 Profile::FromBrowserContext(process->GetBrowserContext()); 2645 Profile::FromBrowserContext(process->GetBrowserContext());
2647 if (!profile_->IsSameProfile(host_profile->GetOriginalProfile())) 2646 if (!profile_->IsSameProfile(host_profile->GetOriginalProfile()))
2648 break; 2647 break;
2649 2648
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2692 InitAfterImport(); 2691 InitAfterImport();
2693 break; 2692 break;
2694 } 2693 }
2695 case chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED: { 2694 case chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED: {
2696 extensions::ExtensionHost* host = 2695 extensions::ExtensionHost* host =
2697 content::Details<extensions::ExtensionHost>(details).ptr(); 2696 content::Details<extensions::ExtensionHost>(details).ptr();
2698 std::string extension_id = host->extension_id(); 2697 std::string extension_id = host->extension_id();
2699 if (delayed_updates_for_idle_.Contains(extension_id)) { 2698 if (delayed_updates_for_idle_.Contains(extension_id)) {
2700 // We were waiting for this extension to become idle, it now might have, 2699 // We were waiting for this extension to become idle, it now might have,
2701 // so maybe finish installation. 2700 // so maybe finish installation.
2702 MessageLoop::current()->PostDelayedTask( 2701 base::MessageLoop::current()->PostDelayedTask(
2703 FROM_HERE, 2702 FROM_HERE,
2704 base::Bind(&ExtensionService::MaybeFinishDelayedInstallation, 2703 base::Bind(&ExtensionService::MaybeFinishDelayedInstallation,
2705 AsWeakPtr(), extension_id), 2704 AsWeakPtr(),
2705 extension_id),
brettw 2013/04/28 04:26:27 This was fine on the previous line.
2706 base::TimeDelta::FromSeconds(kUpdateIdleDelay)); 2706 base::TimeDelta::FromSeconds(kUpdateIdleDelay));
2707 } 2707 }
2708 break; 2708 break;
2709 } 2709 }
2710 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: { 2710 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: {
2711 // Notify extensions that chrome update is available. 2711 // Notify extensions that chrome update is available.
2712 extensions::RuntimeEventRouter::DispatchOnBrowserUpdateAvailableEvent( 2712 extensions::RuntimeEventRouter::DispatchOnBrowserUpdateAvailableEvent(
2713 profile_); 2713 profile_);
2714 2714
2715 // Notify observers that chrome update is available. 2715 // Notify observers that chrome update is available.
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
3097 } 3097 }
3098 3098
3099 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { 3099 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) {
3100 update_observers_.AddObserver(observer); 3100 update_observers_.AddObserver(observer);
3101 } 3101 }
3102 3102
3103 void ExtensionService::RemoveUpdateObserver( 3103 void ExtensionService::RemoveUpdateObserver(
3104 extensions::UpdateObserver* observer) { 3104 extensions::UpdateObserver* observer) {
3105 update_observers_.RemoveObserver(observer); 3105 update_observers_.RemoveObserver(observer);
3106 } 3106 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698