| 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/service_provider.mojom.h" | 10 #include "mojo/application/public/interfaces/service_provider.mojom.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 } | 24 } |
| 25 | 25 |
| 26 ResourceLoader::ResourceLoader(mojo::Shell* shell, | 26 ResourceLoader::ResourceLoader(mojo::Shell* shell, |
| 27 const std::set<std::string>& paths) | 27 const std::set<std::string>& paths) |
| 28 : loaded_(false), did_block_(false) { | 28 : loaded_(false), did_block_(false) { |
| 29 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 29 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
| 30 request->url = mojo::String::From("mojo:resource_provider"); | 30 request->url = mojo::String::From("mojo:resource_provider"); |
| 31 mojo::ServiceProviderPtr resource_provider_service_provider; | 31 mojo::ServiceProviderPtr resource_provider_service_provider; |
| 32 shell->ConnectToApplication(request.Pass(), | 32 shell->ConnectToApplication(request.Pass(), |
| 33 GetProxy(&resource_provider_service_provider), | 33 GetProxy(&resource_provider_service_provider), |
| 34 nullptr, |
| 34 nullptr); | 35 nullptr); |
| 35 mojo::ConnectToService(resource_provider_service_provider.get(), | 36 mojo::ConnectToService(resource_provider_service_provider.get(), |
| 36 &resource_provider_); | 37 &resource_provider_); |
| 37 std::vector<std::string> paths_vector(paths.begin(), paths.end()); | 38 std::vector<std::string> paths_vector(paths.begin(), paths.end()); |
| 38 resource_provider_->GetResources( | 39 resource_provider_->GetResources( |
| 39 mojo::Array<mojo::String>::From(paths_vector), | 40 mojo::Array<mojo::String>::From(paths_vector), |
| 40 base::Bind(&ResourceLoader::OnGotResources, base::Unretained(this), | 41 base::Bind(&ResourceLoader::OnGotResources, base::Unretained(this), |
| 41 paths_vector)); | 42 paths_vector)); |
| 42 } | 43 } |
| 43 | 44 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 new base::File(GetFileFromHandle(resources[i].Pass()))); | 80 new base::File(GetFileFromHandle(resources[i].Pass()))); |
| 80 } | 81 } |
| 81 loaded_ = true; | 82 loaded_ = true; |
| 82 } | 83 } |
| 83 | 84 |
| 84 void ResourceLoader::OnGotICU(base::File* file, mojo::ScopedHandle handle) { | 85 void ResourceLoader::OnGotICU(base::File* file, mojo::ScopedHandle handle) { |
| 85 *file = GetFileFromHandle(handle.Pass()); | 86 *file = GetFileFromHandle(handle.Pass()); |
| 86 } | 87 } |
| 87 | 88 |
| 88 } // namespace resource_provider | 89 } // namespace resource_provider |
| OLD | NEW |