Chromium Code Reviews| Index: ui/views/mus/aura_init.cc |
| diff --git a/ui/views/mus/aura_init.cc b/ui/views/mus/aura_init.cc |
| index 7f73dc190f410c7ca759ac28be41f692f7b3c29e..babdd38c8c6762f5210d4d51e82ea44b0a31e625 100644 |
| --- a/ui/views/mus/aura_init.cc |
| +++ b/ui/views/mus/aura_init.cc |
| @@ -70,7 +70,8 @@ AuraInit::AuraInit(service_manager::Connector* connector, |
| base::WrapUnique(new MusClient(connector, identity, io_task_runner)); |
| } |
| ui::MaterialDesignController::Initialize(); |
| - InitializeResources(connector); |
| + if (!InitializeResources(connector)) |
|
sky
2017/06/22 15:28:58
What do you think of moving everything here into a
jonross
2017/06/22 17:49:30
I had considered that and have no objections. I ha
|
| + return; |
| // Initialize the skia font code to go ask fontconfig underneath. |
| #if defined(OS_LINUX) |
| @@ -83,6 +84,7 @@ AuraInit::AuraInit(service_manager::Connector* connector, |
| gfx::Font(); |
| ui::InitializeInputMethodForTesting(); |
| + initialized_ = true; |
| } |
| AuraInit::~AuraInit() { |
| @@ -97,11 +99,11 @@ AuraInit::~AuraInit() { |
| #endif |
| } |
| -void AuraInit::InitializeResources(service_manager::Connector* connector) { |
| +bool AuraInit::InitializeResources(service_manager::Connector* connector) { |
| // Resources may have already been initialized (e.g. when 'chrome --mash' is |
| // used to launch the current app). |
| if (ui::ResourceBundle::HasSharedInstance()) |
| - return; |
| + return false; |
| std::set<std::string> resource_paths({resource_file_}); |
| if (!resource_file_200_.empty()) |
| @@ -110,7 +112,11 @@ void AuraInit::InitializeResources(service_manager::Connector* connector) { |
| catalog::ResourceLoader loader; |
| filesystem::mojom::DirectoryPtr directory; |
| connector->BindInterface(catalog::mojom::kServiceName, &directory); |
| - CHECK(loader.OpenFiles(std::move(directory), resource_paths)); |
| + // One cause of failure is that the peer has closed, but we have not been |
| + // notified yet. It is not possible to complete initialization, so exit now. |
| + // Calling services will shutdown ServiceContext as appropriate. |
| + if (!loader.OpenFiles(std::move(directory), resource_paths)) |
| + return false; |
| ui::RegisterPathProvider(); |
| base::File pak_file = loader.TakeFile(resource_file_); |
| base::File pak_file_2 = pak_file.Duplicate(); |
| @@ -121,6 +127,7 @@ void AuraInit::InitializeResources(service_manager::Connector* connector) { |
| if (!resource_file_200_.empty()) |
| ui::ResourceBundle::GetSharedInstance().AddDataPackFromFile( |
| loader.TakeFile(resource_file_200_), ui::SCALE_FACTOR_200P); |
| + return true; |
| } |
| } // namespace views |