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/resource_provider_impl.h" | 5 #include "components/resource_provider/resource_provider_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> |
8 | 9 |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
11 #include "base/location.h" | 12 #include "base/location.h" |
12 #include "base/logging.h" | 13 #include "base/logging.h" |
13 #include "components/resource_provider/file_utils.h" | 14 #include "components/resource_provider/file_utils.h" |
14 #include "mojo/platform_handle/platform_handle_functions.h" | 15 #include "mojo/platform_handle/platform_handle_functions.h" |
15 #include "url/gurl.h" | 16 #include "url/gurl.h" |
16 | 17 |
17 using mojo::ScopedHandle; | 18 using mojo::ScopedHandle; |
(...skipping 14 matching lines...) Expand all Loading... |
32 | 33 |
33 MojoHandle mojo_handle; | 34 MojoHandle mojo_handle; |
34 MojoResult create_result = | 35 MojoResult create_result = |
35 MojoCreatePlatformHandleWrapper(file.TakePlatformFile(), &mojo_handle); | 36 MojoCreatePlatformHandleWrapper(file.TakePlatformFile(), &mojo_handle); |
36 if (create_result != MOJO_RESULT_OK) { | 37 if (create_result != MOJO_RESULT_OK) { |
37 LOG(WARNING) << "unable to create wrapper, path=" << path.value() | 38 LOG(WARNING) << "unable to create wrapper, path=" << path.value() |
38 << "result=" << create_result; | 39 << "result=" << create_result; |
39 return ScopedHandle(); | 40 return ScopedHandle(); |
40 } | 41 } |
41 | 42 |
42 return ScopedHandle(mojo::Handle(mojo_handle)).Pass(); | 43 return ScopedHandle(mojo::Handle(mojo_handle)); |
43 } | 44 } |
44 | 45 |
45 } // namespace | 46 } // namespace |
46 | 47 |
47 ResourceProviderImpl::ResourceProviderImpl( | 48 ResourceProviderImpl::ResourceProviderImpl( |
48 const base::FilePath& application_path, | 49 const base::FilePath& application_path, |
49 const std::string& resource_provider_app_url) | 50 const std::string& resource_provider_app_url) |
50 : application_path_(application_path), | 51 : application_path_(application_path), |
51 resource_provider_app_url_(resource_provider_app_url) { | 52 resource_provider_app_url_(resource_provider_app_url) { |
52 CHECK(!application_path_.empty()); | 53 CHECK(!application_path_.empty()); |
53 } | 54 } |
54 | 55 |
55 ResourceProviderImpl::~ResourceProviderImpl() { | 56 ResourceProviderImpl::~ResourceProviderImpl() { |
56 } | 57 } |
57 | 58 |
58 void ResourceProviderImpl::GetResources(mojo::Array<mojo::String> paths, | 59 void ResourceProviderImpl::GetResources(mojo::Array<mojo::String> paths, |
59 const GetResourcesCallback& callback) { | 60 const GetResourcesCallback& callback) { |
60 mojo::Array<mojo::ScopedHandle> handles; | 61 mojo::Array<mojo::ScopedHandle> handles; |
61 if (!paths.is_null()) { | 62 if (!paths.is_null()) { |
62 handles.resize(paths.size()); | 63 handles.resize(paths.size()); |
63 for (size_t i = 0; i < paths.size(); ++i) { | 64 for (size_t i = 0; i < paths.size(); ++i) { |
64 handles[i] = GetHandleForPath( | 65 handles[i] = GetHandleForPath( |
65 GetPathForResourceNamed(application_path_, paths[i])); | 66 GetPathForResourceNamed(application_path_, paths[i])); |
66 } | 67 } |
67 } | 68 } |
68 callback.Run(handles.Pass()); | 69 callback.Run(std::move(handles)); |
69 } | 70 } |
70 | 71 |
71 } // namespace resource_provider | 72 } // namespace resource_provider |
OLD | NEW |