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 #ifndef COMPONENTS_RESOURCE_PROVIDER_PUBLIC_CPP_RESOURCE_LOADER_H_ | 5 #ifndef COMPONENTS_RESOURCE_PROVIDER_PUBLIC_CPP_RESOURCE_LOADER_H_ |
6 #define COMPONENTS_RESOURCE_PROVIDER_PUBLIC_CPP_RESOURCE_LOADER_H_ | 6 #define COMPONENTS_RESOURCE_PROVIDER_PUBLIC_CPP_RESOURCE_LOADER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
| 9 #include <memory> |
9 #include <set> | 10 #include <set> |
10 #include <string> | 11 #include <string> |
11 #include <vector> | 12 #include <vector> |
12 | 13 |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/memory/scoped_ptr.h" | |
15 #include "components/resource_provider/public/interfaces/resource_provider.mojom
.h" | 15 #include "components/resource_provider/public/interfaces/resource_provider.mojom
.h" |
16 #include "mojo/platform_handle/platform_handle.h" | 16 #include "mojo/platform_handle/platform_handle.h" |
17 #include "mojo/public/cpp/bindings/array.h" | 17 #include "mojo/public/cpp/bindings/array.h" |
18 #include "mojo/public/cpp/system/handle.h" | 18 #include "mojo/public/cpp/system/handle.h" |
19 | 19 |
20 namespace base { | 20 namespace base { |
21 class File; | 21 class File; |
22 } | 22 } |
23 | 23 |
24 namespace shell { | 24 namespace shell { |
(...skipping 17 matching lines...) Expand all Loading... |
42 // error. This immediately returns if the resources have already been | 42 // error. This immediately returns if the resources have already been |
43 // obtained. | 43 // obtained. |
44 bool BlockUntilLoaded(); | 44 bool BlockUntilLoaded(); |
45 | 45 |
46 // Releases and returns the file wrapping the handle. | 46 // Releases and returns the file wrapping the handle. |
47 base::File ReleaseFile(const std::string& path); | 47 base::File ReleaseFile(const std::string& path); |
48 | 48 |
49 bool loaded() const { return loaded_; } | 49 bool loaded() const { return loaded_; } |
50 | 50 |
51 private: | 51 private: |
52 using ResourceMap = std::map<std::string, scoped_ptr<base::File>>; | 52 using ResourceMap = std::map<std::string, std::unique_ptr<base::File>>; |
53 | 53 |
54 // Callback when resources have loaded. | 54 // Callback when resources have loaded. |
55 void OnGotResources(const std::vector<std::string>& paths, | 55 void OnGotResources(const std::vector<std::string>& paths, |
56 mojo::Array<mojo::ScopedHandle> resources); | 56 mojo::Array<mojo::ScopedHandle> resources); |
57 | 57 |
58 ResourceProviderPtr resource_provider_; | 58 ResourceProviderPtr resource_provider_; |
59 | 59 |
60 ResourceMap resource_map_; | 60 ResourceMap resource_map_; |
61 | 61 |
62 bool loaded_; | 62 bool loaded_; |
63 bool did_block_; | 63 bool did_block_; |
64 | 64 |
65 DISALLOW_COPY_AND_ASSIGN(ResourceLoader); | 65 DISALLOW_COPY_AND_ASSIGN(ResourceLoader); |
66 }; | 66 }; |
67 | 67 |
68 } // namespace resource_provider | 68 } // namespace resource_provider |
69 | 69 |
70 #endif // COMPONENTS_RESOURCE_PROVIDER_PUBLIC_CPP_RESOURCE_LOADER_H_ | 70 #endif // COMPONENTS_RESOURCE_PROVIDER_PUBLIC_CPP_RESOURCE_LOADER_H_ |
OLD | NEW |