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 <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/files/file.h" | 11 #include "base/files/file.h" |
12 #include "mojo/common/common_type_converters.h" | 12 #include "mojo/common/common_type_converters.h" |
13 #include "mojo/platform_handle/platform_handle_functions.h" | 13 #include "mojo/platform_handle/platform_handle_functions.h" |
14 #include "mojo/shell/public/cpp/connector.h" | 14 #include "services/shell/public/cpp/connector.h" |
15 #include "mojo/shell/public/interfaces/connector.mojom.h" | 15 #include "services/shell/public/interfaces/connector.mojom.h" |
16 #include "mojo/shell/public/interfaces/interface_provider.mojom.h" | 16 #include "services/shell/public/interfaces/interface_provider.mojom.h" |
17 | 17 |
18 namespace resource_provider { | 18 namespace resource_provider { |
19 namespace { | 19 namespace { |
20 base::File GetFileFromHandle(mojo::ScopedHandle handle) { | 20 base::File GetFileFromHandle(mojo::ScopedHandle handle) { |
21 CHECK(handle.is_valid()); | 21 CHECK(handle.is_valid()); |
22 MojoPlatformHandle platform_handle; | 22 MojoPlatformHandle platform_handle; |
23 CHECK(MojoExtractPlatformHandle(handle.release().value(), | 23 CHECK(MojoExtractPlatformHandle(handle.release().value(), |
24 &platform_handle) == MOJO_RESULT_OK); | 24 &platform_handle) == MOJO_RESULT_OK); |
25 return base::File(platform_handle); | 25 return base::File(platform_handle); |
26 } | 26 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 CHECK(!resources.is_null()); | 62 CHECK(!resources.is_null()); |
63 CHECK_EQ(resources.size(), paths.size()); | 63 CHECK_EQ(resources.size(), paths.size()); |
64 for (size_t i = 0; i < resources.size(); ++i) { | 64 for (size_t i = 0; i < resources.size(); ++i) { |
65 resource_map_[paths[i]].reset( | 65 resource_map_[paths[i]].reset( |
66 new base::File(GetFileFromHandle(std::move(resources[i])))); | 66 new base::File(GetFileFromHandle(std::move(resources[i])))); |
67 } | 67 } |
68 loaded_ = true; | 68 loaded_ = true; |
69 } | 69 } |
70 | 70 |
71 } // namespace resource_provider | 71 } // namespace resource_provider |
OLD | NEW |