OLD | NEW |
| (Empty) |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef MOJO_SERVICES_CATALOG_READER_H_ | |
6 #define MOJO_SERVICES_CATALOG_READER_H_ | |
7 | |
8 #include "base/callback.h" | |
9 #include "base/files/file_path.h" | |
10 #include "base/macros.h" | |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/memory/weak_ptr.h" | |
13 #include "base/values.h" | |
14 | |
15 namespace base { | |
16 class TaskRunner; | |
17 } | |
18 | |
19 namespace catalog { | |
20 | |
21 class Entry; | |
22 | |
23 // Encapsulates manifest reading. | |
24 class Reader { | |
25 public: | |
26 using ReadManifestCallback = | |
27 base::Callback<void(scoped_ptr<Entry> entry)>; | |
28 | |
29 // Loads manifests relative to |package_path|. Performs file operations on | |
30 // |file_task_runner|. | |
31 Reader(const base::FilePath& package_path, | |
32 base::TaskRunner* file_task_runner); | |
33 ~Reader(); | |
34 | |
35 // Attempts to load a manifest for |name|, and returns an Entry built from the | |
36 // metadata it contains via |callback|. | |
37 void Read(const std::string& name, | |
38 const ReadManifestCallback& callback); | |
39 | |
40 private: | |
41 // Construct a manifest path for the application named |name| within | |
42 // |package_path_|. | |
43 base::FilePath GetManifestPath(const std::string& name) const; | |
44 | |
45 base::FilePath package_path_; | |
46 base::TaskRunner* file_task_runner_; | |
47 base::WeakPtrFactory<Reader> weak_factory_; | |
48 | |
49 DISALLOW_COPY_AND_ASSIGN(Reader); | |
50 }; | |
51 | |
52 } // namespace catalog | |
53 | |
54 #endif // MOJO_SERVICES_CATALOG_READER_H_ | |
OLD | NEW |