Chromium Code Reviews| Index: athena/content/app_activity_registry.cc |
| diff --git a/athena/content/app_activity_registry.cc b/athena/content/app_activity_registry.cc |
| index 24505df40992550e3e2922d23ecc7de1512ee8a9..e6c22490227ae22aab26374d5dc97490be316fd0 100644 |
| --- a/athena/content/app_activity_registry.cc |
| +++ b/athena/content/app_activity_registry.cc |
| @@ -12,6 +12,11 @@ |
| #include "athena/resource_manager/public/resource_manager.h" |
| #include "athena/wm/public/window_list_provider.h" |
| #include "athena/wm/public/window_manager.h" |
| +#include "base/bind.h" |
| +#include "base/location.h" |
| +#include "base/sequenced_task_runner.h" |
| +#include "base/single_thread_task_runner.h" |
| +#include "base/thread_task_runner_handle.h" |
| #include "ui/aura/window.h" |
| #include "ui/views/view.h" |
| #include "ui/views/widget/widget.h" |
| @@ -79,11 +84,11 @@ void AppActivityRegistry::Unload() { |
| unloaded_activity_proxy_ = new AppActivityProxy(GetMruActivity(), this); |
| ActivityManager::Get()->AddActivity(unloaded_activity_proxy_); |
| - // Unload the application. This operation will be asynchronous. |
| - if (!ExtensionsDelegate::Get(browser_context_)->UnloadApp(app_id_)) { |
| - while(!activity_list_.empty()) |
| - Activity::Delete(activity_list_.back()); |
| - } |
| + // Unload the application asynchronously to avoid the activity destruction |
| + // while we are in an observerloop. |
| + base::ThreadTaskRunnerHandle::Get()->PostNonNestableTask( |
|
sadrul
2014/09/11 19:37:54
Why non-nestable?
Mr4D (OOO till 08-26)
2014/09/11 21:52:42
Mainly because it got suggested to me. Reading thr
|
| + FROM_HERE, |
| + base::Bind(&AppActivityRegistry::DelayedUnload, base::Unretained(this))); |
| } |
| void AppActivityRegistry::ProxyDestroyed(AppActivityProxy* proxy) { |
| @@ -103,6 +108,13 @@ void AppActivityRegistry::RestartApplication(AppActivityProxy* proxy) { |
| ExtensionsDelegate::Get(browser_context_)->LaunchApp(app_id_); |
| } |
| +void AppActivityRegistry::DelayedUnload() { |
| + if (!ExtensionsDelegate::Get(browser_context_)->UnloadApp(app_id_)) { |
| + while(!activity_list_.empty()) |
| + Activity::Delete(activity_list_.back()); |
| + } |
| +} |
| + |
| AppActivity* AppActivityRegistry::GetMruActivity() { |
| DCHECK(activity_list_.size()); |
| WindowListProvider* window_list_provider = |