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

Side by Side Diff: athena/resource_manager/resource_manager_impl.cc

Issue 596623005: Do not show the activity widget in ActivityManager::AddActivity (Closed) Base URL: https://chromium.googlesource.com/chromium/src@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/resource_manager/public/resource_manager.h" 5 #include "athena/resource_manager/public/resource_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "athena/activity/public/activity.h" 10 #include "athena/activity/public/activity.h"
11 #include "athena/activity/public/activity_manager.h" 11 #include "athena/activity/public/activity_manager.h"
12 #include "athena/activity/public/activity_manager_observer.h" 12 #include "athena/activity/public/activity_manager_observer.h"
13 #include "athena/resource_manager/memory_pressure_notifier.h" 13 #include "athena/resource_manager/memory_pressure_notifier.h"
14 #include "athena/resource_manager/public/resource_manager_delegate.h" 14 #include "athena/resource_manager/public/resource_manager_delegate.h"
15 #include "athena/wm/public/window_list_provider.h" 15 #include "athena/wm/public/window_list_provider.h"
16 #include "athena/wm/public/window_list_provider_observer.h" 16 #include "athena/wm/public/window_list_provider_observer.h"
17 #include "athena/wm/public/window_manager.h" 17 #include "athena/wm/public/window_manager.h"
18 #include "athena/wm/public/window_manager_observer.h" 18 #include "athena/wm/public/window_manager_observer.h"
19 #include "base/logging.h" 19 #include "base/logging.h"
20 #include "base/memory/scoped_ptr.h" 20 #include "base/memory/scoped_ptr.h"
21 #include "base/time/time.h" 21 #include "base/time/time.h"
22 #include "ui/aura/window.h" 22 #include "ui/aura/window.h"
23 23
24 namespace athena { 24 namespace athena {
25 namespace {
25 26
26 class ResourceManagerImpl : public ResourceManager, 27 class ResourceManagerImpl : public ResourceManager,
27 public WindowManagerObserver, 28 public WindowManagerObserver,
28 public ActivityManagerObserver, 29 public ActivityManagerObserver,
29 public MemoryPressureObserver, 30 public MemoryPressureObserver,
30 public WindowListProviderObserver { 31 public WindowListProviderObserver {
31 public: 32 public:
32 ResourceManagerImpl(ResourceManagerDelegate* delegate); 33 ResourceManagerImpl(ResourceManagerDelegate* delegate);
33 virtual ~ResourceManagerImpl(); 34 virtual ~ResourceManagerImpl();
34 35
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 unloadable_activities.size() << ")"; 412 unloadable_activities.size() << ")";
412 } 413 }
413 } 414 }
414 415
415 void ResourceManagerImpl::UpdateActivityOrder() { 416 void ResourceManagerImpl::UpdateActivityOrder() {
416 queued_command_ = true; 417 queued_command_ = true;
417 if (activity_list_.empty()) 418 if (activity_list_.empty())
418 return; 419 return;
419 std::vector<Activity*> new_activity_list; 420 std::vector<Activity*> new_activity_list;
420 const aura::Window::Windows children = 421 const aura::Window::Windows children =
421 activity_list_[0]->GetWindow()->parent()->children(); 422 WindowManager::GetInstance()->GetWindowListProvider()->GetWindowList();
422 // Find the first window in the container which is part of the application. 423 // Find the first window in the container which is part of the application.
423 for (aura::Window::Windows::const_reverse_iterator child_iterator = 424 for (aura::Window::Windows::const_reverse_iterator child_iterator =
424 children.rbegin(); 425 children.rbegin();
425 child_iterator != children.rend(); ++child_iterator) { 426 child_iterator != children.rend(); ++child_iterator) {
426 for (std::vector<Activity*>::iterator activity_iterator = 427 for (std::vector<Activity*>::iterator activity_iterator =
427 activity_list_.begin(); 428 activity_list_.begin();
428 activity_iterator != activity_list_.end(); ++activity_iterator) { 429 activity_iterator != activity_list_.end(); ++activity_iterator) {
429 if (*child_iterator == (*activity_iterator)->GetWindow()) { 430 if (*child_iterator == (*activity_iterator)->GetWindow()) {
430 new_activity_list.push_back(*activity_iterator); 431 new_activity_list.push_back(*activity_iterator);
431 activity_list_.erase(activity_iterator); 432 activity_list_.erase(activity_iterator);
(...skipping 20 matching lines...) Expand all
452 void ResourceManagerImpl::OnMemoryPressureIncreased() { 453 void ResourceManagerImpl::OnMemoryPressureIncreased() {
453 // By setting the timer to Now, the next call will immediately be performed. 454 // By setting the timer to Now, the next call will immediately be performed.
454 next_resource_management_time_ = base::Time::Now(); 455 next_resource_management_time_ = base::Time::Now();
455 } 456 }
456 457
457 bool ResourceManagerImpl::AllowedToUnloadActivity() { 458 bool ResourceManagerImpl::AllowedToUnloadActivity() {
458 return current_memory_pressure_ != MEMORY_PRESSURE_LOW && 459 return current_memory_pressure_ != MEMORY_PRESSURE_LOW &&
459 base::Time::Now() >= next_resource_management_time_; 460 base::Time::Now() >= next_resource_management_time_;
460 } 461 }
461 462
463 } // namespace
464
462 // static 465 // static
463 void ResourceManager::Create() { 466 void ResourceManager::Create() {
464 DCHECK(!instance); 467 DCHECK(!instance);
465 instance = new ResourceManagerImpl( 468 instance = new ResourceManagerImpl(
466 ResourceManagerDelegate::CreateResourceManagerDelegate()); 469 ResourceManagerDelegate::CreateResourceManagerDelegate());
467 } 470 }
468 471
469 // static 472 // static
470 ResourceManager* ResourceManager::Get() { 473 ResourceManager* ResourceManager::Get() {
471 return instance; 474 return instance;
472 } 475 }
473 476
474 // static 477 // static
475 void ResourceManager::Shutdown() { 478 void ResourceManager::Shutdown() {
476 DCHECK(instance); 479 DCHECK(instance);
477 delete instance; 480 delete instance;
478 instance = NULL; 481 instance = NULL;
479 } 482 }
480 483
481 ResourceManager::ResourceManager() {} 484 ResourceManager::ResourceManager() {}
482 485
483 ResourceManager::~ResourceManager() { 486 ResourceManager::~ResourceManager() {
484 DCHECK(instance); 487 DCHECK(instance);
485 instance = NULL; 488 instance = NULL;
486 } 489 }
487 490
488 } // namespace athena 491 } // namespace athena
OLDNEW
« athena/activity/activity_view_manager_impl.cc ('K') | « athena/main/url_search_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698