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

Side by Side Diff: ash/mus/window_manager_application.cc

Issue 2772513003: Makes AshTestHelper shutdown ChromeOS NetworkHandler (Closed)
Patch Set: comments 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
« no previous file with comments | « ash/mus/window_manager_application.h ('k') | ash/shelf/shelf_view_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ash/mus/window_manager_application.h" 5 #include "ash/mus/window_manager_application.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/common/mojo_interface_factory.h" 9 #include "ash/common/mojo_interface_factory.h"
10 #include "ash/common/system/chromeos/power/power_status.h" 10 #include "ash/common/system/chromeos/power/power_status.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 const int kMaxNewShutdownBlockingTasks = 1000; 51 const int kMaxNewShutdownBlockingTasks = 1000;
52 blocking_pool_->Shutdown(kMaxNewShutdownBlockingTasks); 52 blocking_pool_->Shutdown(kMaxNewShutdownBlockingTasks);
53 } 53 }
54 54
55 statistics_provider_.reset(); 55 statistics_provider_.reset();
56 ShutdownComponents(); 56 ShutdownComponents();
57 } 57 }
58 58
59 void WindowManagerApplication::InitWindowManager( 59 void WindowManagerApplication::InitWindowManager(
60 std::unique_ptr<aura::WindowTreeClient> window_tree_client, 60 std::unique_ptr<aura::WindowTreeClient> window_tree_client,
61 const scoped_refptr<base::SequencedWorkerPool>& blocking_pool) { 61 const scoped_refptr<base::SequencedWorkerPool>& blocking_pool,
62 bool init_network_handler) {
62 // Tests may have already set the WindowTreeClient. 63 // Tests may have already set the WindowTreeClient.
63 if (!aura::Env::GetInstance()->HasWindowTreeClient()) 64 if (!aura::Env::GetInstance()->HasWindowTreeClient())
64 aura::Env::GetInstance()->SetWindowTreeClient(window_tree_client.get()); 65 aura::Env::GetInstance()->SetWindowTreeClient(window_tree_client.get());
65 InitializeComponents(); 66 InitializeComponents(init_network_handler);
66 67
67 // TODO(jamescook): Refactor StatisticsProvider so we can get just the data 68 // TODO(jamescook): Refactor StatisticsProvider so we can get just the data
68 // we need in ash. Right now StatisticsProviderImpl launches the crossystem 69 // we need in ash. Right now StatisticsProviderImpl launches the crossystem
69 // binary to get system data, which we don't want to do twice on startup. 70 // binary to get system data, which we don't want to do twice on startup.
70 statistics_provider_.reset( 71 statistics_provider_.reset(
71 new chromeos::system::ScopedFakeStatisticsProvider()); 72 new chromeos::system::ScopedFakeStatisticsProvider());
72 statistics_provider_->SetMachineStatistic("initial_locale", "en-US"); 73 statistics_provider_->SetMachineStatistic("initial_locale", "en-US");
73 statistics_provider_->SetMachineStatistic("keyboard_layout", ""); 74 statistics_provider_->SetMachineStatistic("keyboard_layout", "");
74 75
75 window_manager_->Init(std::move(window_tree_client), blocking_pool); 76 window_manager_->Init(std::move(window_tree_client), blocking_pool);
76 } 77 }
77 78
78 void WindowManagerApplication::InitializeComponents() { 79 void WindowManagerApplication::InitializeComponents(bool init_network_handler) {
79 message_center::MessageCenter::Initialize(); 80 message_center::MessageCenter::Initialize();
80 81
81 // Must occur after mojo::ApplicationRunner has initialized AtExitManager, but 82 // Must occur after mojo::ApplicationRunner has initialized AtExitManager, but
82 // before WindowManager::Init(). 83 // before WindowManager::Init().
83 chromeos::DBusThreadManager::Initialize( 84 chromeos::DBusThreadManager::Initialize(
84 chromeos::DBusThreadManager::PROCESS_ASH); 85 chromeos::DBusThreadManager::PROCESS_ASH);
85 86
86 // See ChromeBrowserMainPartsChromeos for ordering details. 87 // See ChromeBrowserMainPartsChromeos for ordering details.
87 bluez::BluezDBusManager::Initialize( 88 bluez::BluezDBusManager::Initialize(
88 chromeos::DBusThreadManager::Get()->GetSystemBus(), 89 chromeos::DBusThreadManager::Get()->GetSystemBus(),
89 chromeos::DBusThreadManager::Get()->IsUsingFakes()); 90 chromeos::DBusThreadManager::Get()->IsUsingFakes());
90 chromeos::NetworkHandler::Initialize(); 91 if (init_network_handler)
92 chromeos::NetworkHandler::Initialize();
91 network_connect_delegate_.reset(new NetworkConnectDelegateMus()); 93 network_connect_delegate_.reset(new NetworkConnectDelegateMus());
92 chromeos::NetworkConnect::Initialize(network_connect_delegate_.get()); 94 chromeos::NetworkConnect::Initialize(network_connect_delegate_.get());
93 // TODO(jamescook): Initialize real audio handler. 95 // TODO(jamescook): Initialize real audio handler.
94 chromeos::CrasAudioHandler::InitializeForTesting(); 96 chromeos::CrasAudioHandler::InitializeForTesting();
95 } 97 }
96 98
97 void WindowManagerApplication::ShutdownComponents() { 99 void WindowManagerApplication::ShutdownComponents() {
98 // NOTE: PowerStatus is shutdown by Shell. 100 // NOTE: PowerStatus is shutdown by Shell.
99 chromeos::CrasAudioHandler::Shutdown(); 101 chromeos::CrasAudioHandler::Shutdown();
100 chromeos::NetworkConnect::Shutdown(); 102 chromeos::NetworkConnect::Shutdown();
101 network_connect_delegate_.reset(); 103 network_connect_delegate_.reset();
102 chromeos::NetworkHandler::Shutdown(); 104 // We may not have started the NetworkHandler.
105 if (chromeos::NetworkHandler::IsInitialized())
106 chromeos::NetworkHandler::Shutdown();
103 device::BluetoothAdapterFactory::Shutdown(); 107 device::BluetoothAdapterFactory::Shutdown();
104 bluez::BluezDBusManager::Shutdown(); 108 bluez::BluezDBusManager::Shutdown();
105 chromeos::DBusThreadManager::Shutdown(); 109 chromeos::DBusThreadManager::Shutdown();
106 message_center::MessageCenter::Shutdown(); 110 message_center::MessageCenter::Shutdown();
107 } 111 }
108 112
109 void WindowManagerApplication::OnStart() { 113 void WindowManagerApplication::OnStart() {
110 aura_init_ = base::MakeUnique<views::AuraInit>( 114 aura_init_ = base::MakeUnique<views::AuraInit>(
111 context()->connector(), context()->identity(), "ash_mus_resources.pak", 115 context()->connector(), context()->identity(), "ash_mus_resources.pak",
112 "ash_mus_resources_200.pak", nullptr, 116 "ash_mus_resources_200.pak", nullptr,
113 views::AuraInit::Mode::AURA_MUS_WINDOW_MANAGER); 117 views::AuraInit::Mode::AURA_MUS_WINDOW_MANAGER);
114 window_manager_.reset(new WindowManager(context()->connector())); 118 window_manager_.reset(new WindowManager(context()->connector()));
115 119
116 tracing_.Initialize(context()->connector(), context()->identity().name()); 120 tracing_.Initialize(context()->connector(), context()->identity().name());
117 121
118 std::unique_ptr<aura::WindowTreeClient> window_tree_client = 122 std::unique_ptr<aura::WindowTreeClient> window_tree_client =
119 base::MakeUnique<aura::WindowTreeClient>( 123 base::MakeUnique<aura::WindowTreeClient>(
120 context()->connector(), window_manager_.get(), window_manager_.get()); 124 context()->connector(), window_manager_.get(), window_manager_.get());
121 window_tree_client->ConnectAsWindowManager(); 125 window_tree_client->ConnectAsWindowManager();
122 126
123 const size_t kMaxNumberThreads = 3u; // Matches that of content. 127 const size_t kMaxNumberThreads = 3u; // Matches that of content.
124 const char kThreadNamePrefix[] = "MashBlocking"; 128 const char kThreadNamePrefix[] = "MashBlocking";
125 blocking_pool_ = new base::SequencedWorkerPool( 129 blocking_pool_ = new base::SequencedWorkerPool(
126 kMaxNumberThreads, kThreadNamePrefix, base::TaskPriority::USER_VISIBLE); 130 kMaxNumberThreads, kThreadNamePrefix, base::TaskPriority::USER_VISIBLE);
127 InitWindowManager(std::move(window_tree_client), blocking_pool_); 131 const bool init_network_handler = true;
132 InitWindowManager(std::move(window_tree_client), blocking_pool_,
133 init_network_handler);
128 } 134 }
129 135
130 bool WindowManagerApplication::OnConnect( 136 bool WindowManagerApplication::OnConnect(
131 const service_manager::ServiceInfo& remote_info, 137 const service_manager::ServiceInfo& remote_info,
132 service_manager::InterfaceRegistry* registry) { 138 service_manager::InterfaceRegistry* registry) {
133 // Register services used in both classic ash and mash. 139 // Register services used in both classic ash and mash.
134 mojo_interface_factory::RegisterInterfaces( 140 mojo_interface_factory::RegisterInterfaces(
135 registry, base::ThreadTaskRunnerHandle::Get()); 141 registry, base::ThreadTaskRunnerHandle::Get());
136 return true; 142 return true;
137 } 143 }
138 144
139 } // namespace mus 145 } // namespace mus
140 } // namespace ash 146 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/window_manager_application.h ('k') | ash/shelf/shelf_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698