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 11 matching lines...) Expand all Loading... |
22 return base::File(platform_handle).Pass(); | 22 return base::File(platform_handle).Pass(); |
23 } | 23 } |
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( |
33 GetProxy(&resource_provider_service_provider), | 33 request.Pass(), GetProxy(&resource_provider_service_provider), nullptr, |
34 nullptr, | 34 nullptr, mojo::Shell::ConnectToApplicationCallback()); |
35 nullptr); | |
36 mojo::ConnectToService(resource_provider_service_provider.get(), | 35 mojo::ConnectToService(resource_provider_service_provider.get(), |
37 &resource_provider_); | 36 &resource_provider_); |
38 std::vector<std::string> paths_vector(paths.begin(), paths.end()); | 37 std::vector<std::string> paths_vector(paths.begin(), paths.end()); |
39 resource_provider_->GetResources( | 38 resource_provider_->GetResources( |
40 mojo::Array<mojo::String>::From(paths_vector), | 39 mojo::Array<mojo::String>::From(paths_vector), |
41 base::Bind(&ResourceLoader::OnGotResources, base::Unretained(this), | 40 base::Bind(&ResourceLoader::OnGotResources, base::Unretained(this), |
42 paths_vector)); | 41 paths_vector)); |
43 } | 42 } |
44 | 43 |
45 ResourceLoader::~ResourceLoader() { | 44 ResourceLoader::~ResourceLoader() { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 new base::File(GetFileFromHandle(resources[i].Pass()))); | 79 new base::File(GetFileFromHandle(resources[i].Pass()))); |
81 } | 80 } |
82 loaded_ = true; | 81 loaded_ = true; |
83 } | 82 } |
84 | 83 |
85 void ResourceLoader::OnGotICU(base::File* file, mojo::ScopedHandle handle) { | 84 void ResourceLoader::OnGotICU(base::File* file, mojo::ScopedHandle handle) { |
86 *file = GetFileFromHandle(handle.Pass()); | 85 *file = GetFileFromHandle(handle.Pass()); |
87 } | 86 } |
88 | 87 |
89 } // namespace resource_provider | 88 } // namespace resource_provider |
OLD | NEW |