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

Unified Diff: chrome/browser/ui/app_list/search/app_search_provider.cc

Issue 800023004: app_list: OnExtensionLoaded calls UpdateResults asynchronously rather than directly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix test Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/app_list/search/app_search_provider.cc
diff --git a/chrome/browser/ui/app_list/search/app_search_provider.cc b/chrome/browser/ui/app_list/search/app_search_provider.cc
index 431493332ea662ac2d5cb1ed0a90081d5a4317eb..a45e4d9c19a4b14ee0e7cad18674d9cfb1e6fdbf 100644
--- a/chrome/browser/ui/app_list/search/app_search_provider.cc
+++ b/chrome/browser/ui/app_list/search/app_search_provider.cc
@@ -6,6 +6,8 @@
#include <string>
+#include "base/bind.h"
+#include "base/message_loop/message_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/clock.h"
#include "chrome/browser/extensions/extension_service.h"
@@ -52,7 +54,8 @@ AppSearchProvider::AppSearchProvider(Profile* profile,
: profile_(profile),
list_controller_(list_controller),
extension_registry_observer_(this),
- clock_(clock.Pass()) {
+ clock_(clock.Pass()),
+ update_results_factory_(this) {
extension_registry_observer_.Add(ExtensionRegistry::Get(profile_));
RefreshApps();
}
@@ -101,6 +104,8 @@ void AppSearchProvider::UpdateResults() {
}
Add(result.Pass());
}
+
+ update_results_factory_.InvalidateWeakPtrs();
tapted 2015/01/07 04:12:30 TBH I haven't used WeakPtrs in Chrome all that muc
xiyuan 2015/01/07 04:51:57 WeakPtrFactory::InvalidateWeakPtrs would mark the
}
void AppSearchProvider::AddApps(const extensions::ExtensionSet& extensions) {
@@ -132,7 +137,12 @@ void AppSearchProvider::OnExtensionLoaded(
content::BrowserContext* browser_context,
const extensions::Extension* extension) {
RefreshApps();
- UpdateResults();
+ if (!update_results_factory_.HasWeakPtrs()) {
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&AppSearchProvider::UpdateResults,
+ update_results_factory_.GetWeakPtr()));
+ }
}
void AppSearchProvider::OnExtensionUninstalled(
@@ -140,7 +150,12 @@ void AppSearchProvider::OnExtensionUninstalled(
const extensions::Extension* extension,
extensions::UninstallReason reason) {
RefreshApps();
- UpdateResults();
+ if (!update_results_factory_.HasWeakPtrs()) {
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&AppSearchProvider::UpdateResults,
+ update_results_factory_.GetWeakPtr()));
+ }
}
} // namespace app_list

Powered by Google App Engine
This is Rietveld 408576698