| OLD | NEW |
| 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 "components/resource_provider/public/cpp/resource_loader.h" | 5 #include "components/resource_provider/public/cpp/resource_loader.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file.h" | 8 #include "base/files/file.h" |
| 9 #include "mojo/application/public/cpp/connect.h" | 9 #include "mojo/application/public/cpp/connect.h" |
| 10 #include "mojo/application/public/interfaces/shell.mojom.h" | 10 #include "mojo/application/public/interfaces/shell.mojom.h" |
| 11 #include "mojo/common/common_type_converters.h" | 11 #include "mojo/common/common_type_converters.h" |
| 12 #include "mojo/platform_handle/platform_handle_functions.h" | 12 #include "mojo/platform_handle/platform_handle_functions.h" |
| 13 | 13 |
| 14 namespace resource_provider { | 14 namespace resource_provider { |
| 15 | 15 |
| 16 ResourceLoader::ResourceLoader(mojo::Shell* shell, | 16 ResourceLoader::ResourceLoader(mojo::Shell* shell, |
| 17 const std::set<std::string>& paths) | 17 const std::set<std::string>& paths) |
| 18 : loaded_(false), did_block_(false) { | 18 : loaded_(false), did_block_(false) { |
| 19 shell->ConnectToApplication("mojo:resource_provider", | 19 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
| 20 request->url = mojo::String::From("mojo:resource_provider"); |
| 21 shell->ConnectToApplication(request.Pass(), |
| 20 GetProxy(&resource_provider_service_provider_), | 22 GetProxy(&resource_provider_service_provider_), |
| 21 nullptr); | 23 nullptr); |
| 22 mojo::ConnectToService(resource_provider_service_provider_.get(), | 24 mojo::ConnectToService(resource_provider_service_provider_.get(), |
| 23 &resource_provider_); | 25 &resource_provider_); |
| 24 std::vector<std::string> paths_vector(paths.begin(), paths.end()); | 26 std::vector<std::string> paths_vector(paths.begin(), paths.end()); |
| 25 resource_provider_->GetResources( | 27 resource_provider_->GetResources( |
| 26 mojo::Array<mojo::String>::From(paths_vector), | 28 mojo::Array<mojo::String>::From(paths_vector), |
| 27 base::Bind(&ResourceLoader::OnGotResources, base::Unretained(this), | 29 base::Bind(&ResourceLoader::OnGotResources, base::Unretained(this), |
| 28 paths_vector)); | 30 paths_vector)); |
| 29 } | 31 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 59 CHECK(resources[i].is_valid()); | 61 CHECK(resources[i].is_valid()); |
| 60 MojoPlatformHandle platform_handle; | 62 MojoPlatformHandle platform_handle; |
| 61 CHECK(MojoExtractPlatformHandle(resources[i].release().value(), | 63 CHECK(MojoExtractPlatformHandle(resources[i].release().value(), |
| 62 &platform_handle) == MOJO_RESULT_OK); | 64 &platform_handle) == MOJO_RESULT_OK); |
| 63 resource_map_[paths[i]].reset(new base::File(platform_handle)); | 65 resource_map_[paths[i]].reset(new base::File(platform_handle)); |
| 64 } | 66 } |
| 65 loaded_ = true; | 67 loaded_ = true; |
| 66 } | 68 } |
| 67 | 69 |
| 68 } // namespace resource_provider | 70 } // namespace resource_provider |
| OLD | NEW |