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

Side by Side Diff: athena/content/app_activity_registry.cc

Issue 548633005: Adding overview / layer framework to Activities so that unloaded / sleeping activities can be shown… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Created 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "athena/content/app_activity_registry.h" 5 #include "athena/content/app_activity_registry.h"
6 6
7 #include "athena/activity/public/activity_manager.h" 7 #include "athena/activity/public/activity_manager.h"
8 #include "athena/content/app_activity.h" 8 #include "athena/content/app_activity.h"
9 #include "athena/content/app_activity_proxy.h" 9 #include "athena/content/app_activity_proxy.h"
10 #include "athena/content/public/app_registry.h" 10 #include "athena/content/public/app_registry.h"
11 #include "athena/extensions/public/extensions_delegate.h" 11 #include "athena/extensions/public/extensions_delegate.h"
12 #include "athena/resource_manager/public/resource_manager.h" 12 #include "athena/resource_manager/public/resource_manager.h"
13 #include "athena/wm/public/window_list_provider.h" 13 #include "athena/wm/public/window_list_provider.h"
14 #include "athena/wm/public/window_manager.h" 14 #include "athena/wm/public/window_manager.h"
15 #include "base/bind.h"
16 #include "base/location.h"
17 #include "base/sequenced_task_runner.h"
18 #include "base/single_thread_task_runner.h"
19 #include "base/thread_task_runner_handle.h"
15 #include "ui/aura/window.h" 20 #include "ui/aura/window.h"
16 #include "ui/views/view.h" 21 #include "ui/views/view.h"
17 #include "ui/views/widget/widget.h" 22 #include "ui/views/widget/widget.h"
18 23
19 namespace athena { 24 namespace athena {
20 25
21 AppActivityRegistry::AppActivityRegistry( 26 AppActivityRegistry::AppActivityRegistry(
22 const std::string& app_id, 27 const std::string& app_id,
23 content::BrowserContext* browser_context) : 28 content::BrowserContext* browser_context) :
24 app_id_(app_id), 29 app_id_(app_id),
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 if ((*it)->GetCurrentState() != Activity::ACTIVITY_UNLOADED) 77 if ((*it)->GetCurrentState() != Activity::ACTIVITY_UNLOADED)
73 return; 78 return;
74 } 79 }
75 80
76 // Create an activity proxy which can be used to re-activate the app. Insert 81 // Create an activity proxy which can be used to re-activate the app. Insert
77 // the proxy then into the activity stream at the location of the (newest) 82 // the proxy then into the activity stream at the location of the (newest)
78 // current activity. 83 // current activity.
79 unloaded_activity_proxy_ = new AppActivityProxy(GetMruActivity(), this); 84 unloaded_activity_proxy_ = new AppActivityProxy(GetMruActivity(), this);
80 ActivityManager::Get()->AddActivity(unloaded_activity_proxy_); 85 ActivityManager::Get()->AddActivity(unloaded_activity_proxy_);
81 86
82 // Unload the application. This operation will be asynchronous. 87 // Unload the application asynchronously to avoid the activity destruction
83 if (!ExtensionsDelegate::Get(browser_context_)->UnloadApp(app_id_)) { 88 // while we are in an observerloop.
84 while(!activity_list_.empty()) 89 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
85 Activity::Delete(activity_list_.back()); 90 FROM_HERE,
86 } 91 base::Bind(&AppActivityRegistry::DelayedUnload, base::Unretained(this)));
87 } 92 }
88 93
89 void AppActivityRegistry::ProxyDestroyed(AppActivityProxy* proxy) { 94 void AppActivityRegistry::ProxyDestroyed(AppActivityProxy* proxy) {
90 DCHECK_EQ(unloaded_activity_proxy_, proxy); 95 DCHECK_EQ(unloaded_activity_proxy_, proxy);
91 unloaded_activity_proxy_ = NULL; 96 unloaded_activity_proxy_ = NULL;
92 if (activity_list_.empty()) { 97 if (activity_list_.empty()) {
93 AppRegistry::Get()->RemoveAppActivityRegistry(this); 98 AppRegistry::Get()->RemoveAppActivityRegistry(this);
94 // |This| is gone now. 99 // |This| is gone now.
95 } 100 }
96 } 101 }
97 102
98 void AppActivityRegistry::RestartApplication(AppActivityProxy* proxy) { 103 void AppActivityRegistry::RestartApplication(AppActivityProxy* proxy) {
99 DCHECK_EQ(unloaded_activity_proxy_, proxy); 104 DCHECK_EQ(unloaded_activity_proxy_, proxy);
100 // Restart the application. Note that the first created app window will make 105 // Restart the application. Note that the first created app window will make
101 // sure that the proxy gets deleted - after - the new activity got moved 106 // sure that the proxy gets deleted - after - the new activity got moved
102 // to the proxies activity location. 107 // to the proxies activity location.
103 ExtensionsDelegate::Get(browser_context_)->LaunchApp(app_id_); 108 ExtensionsDelegate::Get(browser_context_)->LaunchApp(app_id_);
104 } 109 }
105 110
111 void AppActivityRegistry::DelayedUnload() {
112 if (!ExtensionsDelegate::Get(browser_context_)->UnloadApp(app_id_)) {
113 while(!activity_list_.empty())
114 Activity::Delete(activity_list_.back());
115 }
116 }
117
106 AppActivity* AppActivityRegistry::GetMruActivity() { 118 AppActivity* AppActivityRegistry::GetMruActivity() {
107 DCHECK(activity_list_.size()); 119 DCHECK(activity_list_.size());
108 WindowListProvider* window_list_provider = 120 WindowListProvider* window_list_provider =
109 WindowManager::GetInstance()->GetWindowListProvider(); 121 WindowManager::GetInstance()->GetWindowListProvider();
110 const aura::Window::Windows children = 122 const aura::Window::Windows children =
111 window_list_provider->GetWindowList(); 123 window_list_provider->GetWindowList();
112 // Find the first window in the container which is part of the application. 124 // Find the first window in the container which is part of the application.
113 for (aura::Window::Windows::const_iterator child_iterator = children.begin(); 125 for (aura::Window::Windows::const_iterator child_iterator = children.begin();
114 child_iterator != children.end(); ++child_iterator) { 126 child_iterator != children.end(); ++child_iterator) {
115 for (std::vector<AppActivity*>::iterator app_iterator = 127 for (std::vector<AppActivity*>::iterator app_iterator =
116 activity_list_.begin(); 128 activity_list_.begin();
117 app_iterator != activity_list_.end(); ++app_iterator) { 129 app_iterator != activity_list_.end(); ++app_iterator) {
118 if (*child_iterator == (*app_iterator)->GetWindow()) 130 if (*child_iterator == (*app_iterator)->GetWindow())
119 return *app_iterator; 131 return *app_iterator;
120 } 132 }
121 } 133 }
122 NOTREACHED() << "The application does not get tracked by the mru list"; 134 NOTREACHED() << "The application does not get tracked by the mru list";
123 return NULL; 135 return NULL;
124 } 136 }
125 137
126 } // namespace athena 138 } // namespace athena
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698