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

Side by Side Diff: chrome/browser/chromeos/arc/boot_phase_monitor/arc_instance_throttle.cc

Issue 2736753005: Converts WmActivationObserver to aura::client::ActivationChangeObserver (Closed)
Patch Set: cleanup Created 3 years, 9 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "chrome/browser/chromeos/arc/boot_phase_monitor/arc_instance_throttle.h " 5 #include "chrome/browser/chromeos/arc/boot_phase_monitor/arc_instance_throttle.h "
6 6
7 #include "ash/common/wm_shell.h" 7 #include "ash/common/wm_shell.h"
8 #include "ash/common/wm_window.h" 8 #include "ash/common/wm_window.h"
9 #include "ash/shared/app_types.h" 9 #include "ash/shared/app_types.h"
10 #include "ash/shell.h"
10 #include "base/bind.h" 11 #include "base/bind.h"
11 #include "base/logging.h" 12 #include "base/logging.h"
12 #include "chromeos/dbus/dbus_thread_manager.h" 13 #include "chromeos/dbus/dbus_thread_manager.h"
13 #include "chromeos/dbus/session_manager_client.h" 14 #include "chromeos/dbus/session_manager_client.h"
15 #include "ui/wm/public/activation_client.h"
14 16
15 namespace arc { 17 namespace arc {
16 18
17 namespace { 19 namespace {
18 20
19 void OnDBusReply(login_manager::ContainerCpuRestrictionState state, 21 void OnDBusReply(login_manager::ContainerCpuRestrictionState state,
20 bool success) { 22 bool success) {
21 if (success) 23 if (success)
22 return; 24 return;
23 const char* message = 25 const char* message =
(...skipping 19 matching lines...) Expand all
43 (!active || !IsArcAppWindow(active)) 45 (!active || !IsArcAppWindow(active))
44 ? login_manager::CONTAINER_CPU_RESTRICTION_BACKGROUND 46 ? login_manager::CONTAINER_CPU_RESTRICTION_BACKGROUND
45 : login_manager::CONTAINER_CPU_RESTRICTION_FOREGROUND; 47 : login_manager::CONTAINER_CPU_RESTRICTION_FOREGROUND;
46 session_manager_client->SetArcCpuRestriction(state, 48 session_manager_client->SetArcCpuRestriction(state,
47 base::Bind(OnDBusReply, state)); 49 base::Bind(OnDBusReply, state));
48 } 50 }
49 51
50 } // namespace 52 } // namespace
51 53
52 ArcInstanceThrottle::ArcInstanceThrottle() { 54 ArcInstanceThrottle::ArcInstanceThrottle() {
53 ash::WmShell* shell = ash::WmShell::Get(); 55 ash::Shell::GetInstance()->activation_client()->AddObserver(this);
54 DCHECK(shell); 56 ThrottleInstanceIfNeeded(ash::WmShell::Get()->GetActiveWindow());
55 shell->AddActivationObserver(this);
56 ThrottleInstanceIfNeeded(shell->GetActiveWindow());
57 } 57 }
58 58
59 ArcInstanceThrottle::~ArcInstanceThrottle() { 59 ArcInstanceThrottle::~ArcInstanceThrottle() {
60 ash::WmShell* shell = ash::WmShell::Get(); 60 if (ash::Shell::HasInstance())
61 if (shell) 61 ash::Shell::GetInstance()->activation_client()->RemoveObserver(this);
62 shell->RemoveActivationObserver(this);
63 } 62 }
64 63
65 void ArcInstanceThrottle::OnWindowActivated(ash::WmWindow* gained_active, 64 void ArcInstanceThrottle::OnWindowActivated(ActivationReason reason,
66 ash::WmWindow* lost_active) { 65 aura::Window* gained_active,
67 ThrottleInstanceIfNeeded(gained_active); 66 aura::Window* lost_active) {
67 ThrottleInstanceIfNeeded(ash::WmWindow::Get(gained_active));
68 } 68 }
69 69
70 } // namespace arc 70 } // namespace arc
OLDNEW
« ash/shell.cc ('K') | « chrome/browser/chromeos/arc/boot_phase_monitor/arc_instance_throttle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698