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

Side by Side Diff: services/ui/service.cc

Issue 2858103002: Have mash_browser_tests recreate BackgroundServiceManager per test (Closed)
Patch Set: Revert AuraInit Quitting Created 3 years, 7 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 "services/ui/service.h" 5 #include "services/ui/service.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 // Destroy |window_server_| first, since it depends on |event_source_|. 93 // Destroy |window_server_| first, since it depends on |event_source_|.
94 // WindowServer (or more correctly its Displays) may have state that needs to 94 // WindowServer (or more correctly its Displays) may have state that needs to
95 // be destroyed before GpuState as well. 95 // be destroyed before GpuState as well.
96 window_server_.reset(); 96 window_server_.reset();
97 97
98 #if defined(USE_OZONE) 98 #if defined(USE_OZONE)
99 OzonePlatform::Shutdown(); 99 OzonePlatform::Shutdown();
100 #endif 100 #endif
101 } 101 }
102 102
103 void Service::InitializeResources(service_manager::Connector* connector) { 103 bool Service::InitializeResources(service_manager::Connector* connector) {
104 if (ui::ResourceBundle::HasSharedInstance()) 104 if (ui::ResourceBundle::HasSharedInstance())
105 return; 105 return true;
106 106
107 std::set<std::string> resource_paths; 107 std::set<std::string> resource_paths;
108 resource_paths.insert(kResourceFileStrings); 108 resource_paths.insert(kResourceFileStrings);
109 resource_paths.insert(kResourceFile100); 109 resource_paths.insert(kResourceFile100);
110 resource_paths.insert(kResourceFile200); 110 resource_paths.insert(kResourceFile200);
111 111
112 catalog::ResourceLoader loader; 112 catalog::ResourceLoader loader;
113 filesystem::mojom::DirectoryPtr directory; 113 filesystem::mojom::DirectoryPtr directory;
114 connector->BindInterface(catalog::mojom::kServiceName, &directory); 114 connector->BindInterface(catalog::mojom::kServiceName, &directory);
115 CHECK(loader.OpenFiles(std::move(directory), resource_paths)); 115 if (!loader.OpenFiles(std::move(directory), resource_paths)) {
116 LOG(ERROR) << "Service failed to open resource files.\n";
sky 2017/05/18 20:30:27 no need for the \n here.
jonross 2017/05/18 20:40:24 Done.
117 return false;
118 }
116 119
117 ui::RegisterPathProvider(); 120 ui::RegisterPathProvider();
118 121
119 // Initialize resource bundle with 1x and 2x cursor bitmaps. 122 // Initialize resource bundle with 1x and 2x cursor bitmaps.
120 ui::ResourceBundle::InitSharedInstanceWithPakFileRegion( 123 ui::ResourceBundle::InitSharedInstanceWithPakFileRegion(
121 loader.TakeFile(kResourceFileStrings), 124 loader.TakeFile(kResourceFileStrings),
122 base::MemoryMappedFile::Region::kWholeFile); 125 base::MemoryMappedFile::Region::kWholeFile);
123 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 126 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
124 rb.AddDataPackFromFile(loader.TakeFile(kResourceFile100), 127 rb.AddDataPackFromFile(loader.TakeFile(kResourceFile100),
125 ui::SCALE_FACTOR_100P); 128 ui::SCALE_FACTOR_100P);
126 rb.AddDataPackFromFile(loader.TakeFile(kResourceFile200), 129 rb.AddDataPackFromFile(loader.TakeFile(kResourceFile200),
127 ui::SCALE_FACTOR_200P); 130 ui::SCALE_FACTOR_200P);
131 return true;
128 } 132 }
129 133
130 Service::UserState* Service::GetUserState( 134 Service::UserState* Service::GetUserState(
131 const service_manager::Identity& remote_identity) { 135 const service_manager::Identity& remote_identity) {
132 const ws::UserId& user_id = remote_identity.user_id(); 136 const ws::UserId& user_id = remote_identity.user_id();
133 auto it = user_id_to_user_state_.find(user_id); 137 auto it = user_id_to_user_state_.find(user_id);
134 if (it != user_id_to_user_state_.end()) 138 if (it != user_id_to_user_state_.end())
135 return it->second.get(); 139 return it->second.get();
136 user_id_to_user_state_[user_id] = base::WrapUnique(new UserState); 140 user_id_to_user_state_[user_id] = base::WrapUnique(new UserState);
137 return user_id_to_user_state_[user_id].get(); 141 return user_id_to_user_state_[user_id].get();
(...skipping 11 matching lines...) Expand all
149 test_config_ = base::CommandLine::ForCurrentProcess()->HasSwitch( 153 test_config_ = base::CommandLine::ForCurrentProcess()->HasSwitch(
150 switches::kUseTestConfig); 154 switches::kUseTestConfig);
151 #if defined(USE_X11) 155 #if defined(USE_X11)
152 XInitThreads(); 156 XInitThreads();
153 ui::SetDefaultX11ErrorHandlers(); 157 ui::SetDefaultX11ErrorHandlers();
154 #endif 158 #endif
155 159
156 if (test_config_) 160 if (test_config_)
157 ui::test::EnableTestConfigForPlatformWindows(); 161 ui::test::EnableTestConfigForPlatformWindows();
158 162
159 InitializeResources(context()->connector()); 163 // If resources are unavailable do not complete start-up.
164 if (!InitializeResources(context()->connector())) {
165 context()->QuitNow();
166 return;
167 }
160 168
161 #if defined(USE_OZONE) 169 #if defined(USE_OZONE)
162 // The ozone platform can provide its own event source. So initialize the 170 // The ozone platform can provide its own event source. So initialize the
163 // platform before creating the default event source. 171 // platform before creating the default event source.
164 // Because GL libraries need to be initialized before entering the sandbox, 172 // Because GL libraries need to be initialized before entering the sandbox,
165 // in MUS, |InitializeForUI| will load the GL libraries. 173 // in MUS, |InitializeForUI| will load the GL libraries.
166 ui::OzonePlatform::InitParams params; 174 ui::OzonePlatform::InitParams params;
167 params.connector = context()->connector(); 175 params.connector = context()->connector();
168 params.single_process = false; 176 params.single_process = false;
169 ui::OzonePlatform::InitializeForUI(params); 177 ui::OzonePlatform::InitializeForUI(params);
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 mojom::WindowServerTestRequest request) { 430 mojom::WindowServerTestRequest request) {
423 if (!test_config_) 431 if (!test_config_)
424 return; 432 return;
425 mojo::MakeStrongBinding( 433 mojo::MakeStrongBinding(
426 base::MakeUnique<ws::WindowServerTestImpl>(window_server_.get()), 434 base::MakeUnique<ws::WindowServerTestImpl>(window_server_.get()),
427 std::move(request)); 435 std::move(request));
428 } 436 }
429 437
430 438
431 } // namespace ui 439 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698