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

Unified Diff: chrome/browser/ui/views/app_list/win/app_list_shower.cc

Issue 24707002: Add unit tests for AppListServiceImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: un-const an iterator Created 7 years, 3 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/views/app_list/win/app_list_shower.cc
diff --git a/chrome/browser/ui/views/app_list/win/app_list_shower.cc b/chrome/browser/ui/views/app_list/win/app_list_shower.cc
index 6c7381cf066ce537cbfbd686463c789f442ff331..31f23dce5fd86657803a26fe1fe3da0a9dbe4420 100644
--- a/chrome/browser/ui/views/app_list/win/app_list_shower.cc
+++ b/chrome/browser/ui/views/app_list/win/app_list_shower.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/bind.h"
+#include "base/message_loop/message_loop.h"
#include "chrome/browser/ui/views/app_list/win/app_list_shower.h"
AppListShower::AppListShower(scoped_ptr<AppListViewFactory> factory,
@@ -75,6 +76,22 @@ void AppListShower::DismissAppList() {
void AppListShower::CloseAppList() {
view_.reset();
profile_ = NULL;
+
+ // We may end up here as the result of the OS deleting the AppList's
+ // widget (WidgetObserver::OnWidgetDestroyed). If this happens and there
+ // are no browsers around then deleting the keep alive will result in
+ // deleting the Widget again (by way of CloseAllSecondaryWidgets). When
+ // the stack unravels we end up back in the Widget that was deleted and
+ // crash. By delaying deletion of the keep alive we ensure the Widget has
+ // correctly been destroyed before ending the keep alive so that
+ // CloseAllSecondaryWidgets() won't attempt to delete the AppList's Widget
+ // again.
+ if (base::MessageLoop::current()) { // NULL in tests.
+ base::MessageLoop::current()->PostTask(FROM_HERE,
+ base::Bind(&KeepAliveService::FreeKeepAlive,
+ base::Unretained(keep_alive_service_.get())));
+ return;
+ }
keep_alive_service_->FreeKeepAlive();
}

Powered by Google App Engine
This is Rietveld 408576698