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

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: 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 "base/bind.h"
14 #include "base/location.h"
15 #include "base/sequenced_task_runner.h"
16 #include "base/single_thread_task_runner.h"
17 #include "base/thread_task_runner_handle.h"
13 #include "ui/aura/window.h" 18 #include "ui/aura/window.h"
14 #include "ui/views/view.h" 19 #include "ui/views/view.h"
15 #include "ui/views/widget/widget.h" 20 #include "ui/views/widget/widget.h"
16 21
17 namespace athena { 22 namespace athena {
18 23
19 AppActivityRegistry::AppActivityRegistry( 24 AppActivityRegistry::AppActivityRegistry(
20 const std::string& app_id, 25 const std::string& app_id,
21 content::BrowserContext* browser_context) : 26 content::BrowserContext* browser_context) :
22 app_id_(app_id), 27 app_id_(app_id),
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 if ((*it)->GetCurrentState() != Activity::ACTIVITY_UNLOADED) 75 if ((*it)->GetCurrentState() != Activity::ACTIVITY_UNLOADED)
71 return; 76 return;
72 } 77 }
73 78
74 // Create an activity proxy which can be used to re-activate the app. Insert 79 // Create an activity proxy which can be used to re-activate the app. Insert
75 // the proxy then into the activity stream at the location of the (newest) 80 // the proxy then into the activity stream at the location of the (newest)
76 // current activity. 81 // current activity.
77 unloaded_activity_proxy_ = new AppActivityProxy(GetMruActivity(), this); 82 unloaded_activity_proxy_ = new AppActivityProxy(GetMruActivity(), this);
78 ActivityManager::Get()->AddActivity(unloaded_activity_proxy_); 83 ActivityManager::Get()->AddActivity(unloaded_activity_proxy_);
79 84
80 // Unload the application. This operation will be asynchronous. 85 // Unload the application asynchronously to avoid the activity destruction
81 if (!ExtensionsDelegate::Get(browser_context_)->UnloadApp(app_id_)) { 86 // while we are in an observerloop.
82 while(!activity_list_.empty()) 87 base::ThreadTaskRunnerHandle::Get()->PostNonNestableTask(
83 Activity::Delete(activity_list_.back()); 88 FROM_HERE,
84 } 89 base::Bind(&AppActivityRegistry::DelayedUnload, base::Unretained(this)));
85 } 90 }
86 91
87 void AppActivityRegistry::ProxyDestroyed(AppActivityProxy* proxy) { 92 void AppActivityRegistry::ProxyDestroyed(AppActivityProxy* proxy) {
88 DCHECK_EQ(unloaded_activity_proxy_, proxy); 93 DCHECK_EQ(unloaded_activity_proxy_, proxy);
89 unloaded_activity_proxy_ = NULL; 94 unloaded_activity_proxy_ = NULL;
90 if (activity_list_.empty()) { 95 if (activity_list_.empty()) {
91 AppRegistry::Get()->RemoveAppActivityRegistry(this); 96 AppRegistry::Get()->RemoveAppActivityRegistry(this);
92 // |This| is gone now. 97 // |This| is gone now.
93 } 98 }
94 } 99 }
95 100
96 void AppActivityRegistry::RestartApplication(AppActivityProxy* proxy) { 101 void AppActivityRegistry::RestartApplication(AppActivityProxy* proxy) {
97 DCHECK_EQ(unloaded_activity_proxy_, proxy); 102 DCHECK_EQ(unloaded_activity_proxy_, proxy);
98 // Restart the application. Note that the first created app window will make 103 // Restart the application. Note that the first created app window will make
99 // sure that the proxy gets deleted - after - the new activity got moved 104 // sure that the proxy gets deleted - after - the new activity got moved
100 // to the proxies activity location. 105 // to the proxies activity location.
101 ExtensionsDelegate::Get(browser_context_)->LaunchApp(app_id_); 106 ExtensionsDelegate::Get(browser_context_)->LaunchApp(app_id_);
102 } 107 }
103 108
109 void AppActivityRegistry::DelayedUnload() {
110 if (!ExtensionsDelegate::Get(browser_context_)->UnloadApp(app_id_)) {
111 while(!activity_list_.empty())
112 Activity::Delete(activity_list_.back());
113 }
114 }
115
104 AppActivity* AppActivityRegistry::GetMruActivity() { 116 AppActivity* AppActivityRegistry::GetMruActivity() {
105 DCHECK(activity_list_.size()); 117 DCHECK(activity_list_.size());
106 // TODO(skuhne): This should be a query into the window manager. 118 // TODO(skuhne): This should be a query into the window manager.
107 const aura::Window::Windows children = 119 const aura::Window::Windows children =
108 activity_list_[0]->GetWindow()->parent()->children(); 120 activity_list_[0]->GetWindow()->parent()->children();
109 // Find the first window in the container which is part of the application. 121 // Find the first window in the container which is part of the application.
110 for (aura::Window::Windows::const_iterator child_iterator = children.begin(); 122 for (aura::Window::Windows::const_iterator child_iterator = children.begin();
111 child_iterator != children.end(); ++child_iterator) { 123 child_iterator != children.end(); ++child_iterator) {
112 for (std::vector<AppActivity*>::iterator app_iterator = 124 for (std::vector<AppActivity*>::iterator app_iterator =
113 activity_list_.begin(); 125 activity_list_.begin();
114 app_iterator != activity_list_.end(); ++app_iterator) { 126 app_iterator != activity_list_.end(); ++app_iterator) {
115 if (*child_iterator == (*app_iterator)->GetWindow()) 127 if (*child_iterator == (*app_iterator)->GetWindow())
116 return *app_iterator; 128 return *app_iterator;
117 } 129 }
118 } 130 }
119 NOTREACHED() << "The application does not get tracked by the mru list"; 131 NOTREACHED() << "The application does not get tracked by the mru list";
120 return NULL; 132 return NULL;
121 } 133 }
122 134
123 } // namespace athena 135 } // namespace athena
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698