| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 SERVICES_CATALOG_READER_H_ | 5 #ifndef SERVICES_CATALOG_READER_H_ |
| 6 #define SERVICES_CATALOG_READER_H_ | 6 #define SERVICES_CATALOG_READER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "services/catalog/types.h" | 16 #include "services/catalog/types.h" |
| 17 #include "services/service_manager/public/interfaces/resolver.mojom.h" | 17 #include "services/service_manager/public/interfaces/resolver.mojom.h" |
| 18 | 18 |
| 19 namespace base { | 19 namespace base { |
| 20 class SequencedWorkerPool; | 20 class SequencedWorkerPool; |
| 21 class SingleThreadTaskRunner; | 21 class SingleThreadTaskRunner; |
| 22 class Value; |
| 22 } | 23 } |
| 23 | 24 |
| 24 namespace catalog { | 25 namespace catalog { |
| 25 | 26 |
| 26 class Entry; | 27 class Entry; |
| 27 class ManifestProvider; | 28 class ManifestProvider; |
| 28 | 29 |
| 29 // Responsible for loading manifests & building the Entry data structures. | 30 // Responsible for loading manifests & building the Entry data structures. |
| 30 class Reader { | 31 class Reader { |
| 31 public: | 32 public: |
| 32 using ReadManifestCallback = base::Callback<void(std::unique_ptr<Entry>)>; | 33 using ReadManifestCallback = base::Callback<void(std::unique_ptr<Entry>)>; |
| 33 using CreateEntryForNameCallback = | 34 using CreateEntryForNameCallback = |
| 34 base::Callback<void(service_manager::mojom::ResolveResultPtr)>; | 35 base::Callback<void(service_manager::mojom::ResolveResultPtr)>; |
| 35 | 36 |
| 37 // Construct a Reader over a static manifest. This Reader never performs |
| 38 // file I/O. |
| 39 Reader(std::unique_ptr<base::Value> static_manifest, EntryCache* cache); |
| 40 |
| 36 Reader(base::SequencedWorkerPool* worker_pool, | 41 Reader(base::SequencedWorkerPool* worker_pool, |
| 37 ManifestProvider* manifest_provider); | 42 ManifestProvider* manifest_provider); |
| 38 Reader(base::SingleThreadTaskRunner* task_runner, | 43 Reader(base::SingleThreadTaskRunner* task_runner, |
| 39 ManifestProvider* manifest_provider); | 44 ManifestProvider* manifest_provider); |
| 40 ~Reader(); | 45 ~Reader(); |
| 41 | 46 |
| 42 // Scans the contents of |package_dir|, reading all application manifests and | 47 // Scans the contents of |package_dir|, reading all application manifests and |
| 43 // populating |cache|. Runs |read_complete_closure| when done. | 48 // populating |cache|. Runs |read_complete_closure| when done. |
| 44 void Read(const base::FilePath& package_dir, | 49 void Read(const base::FilePath& package_dir, |
| 45 EntryCache* cache, | 50 EntryCache* cache, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 60 void OverrideManifestPath(const std::string& service_name, | 65 void OverrideManifestPath(const std::string& service_name, |
| 61 const base::FilePath& path); | 66 const base::FilePath& path); |
| 62 | 67 |
| 63 private: | 68 private: |
| 64 explicit Reader(ManifestProvider* manifest_provider); | 69 explicit Reader(ManifestProvider* manifest_provider); |
| 65 | 70 |
| 66 void OnReadManifest(EntryCache* cache, | 71 void OnReadManifest(EntryCache* cache, |
| 67 const CreateEntryForNameCallback& entry_created_callback, | 72 const CreateEntryForNameCallback& entry_created_callback, |
| 68 std::unique_ptr<Entry> entry); | 73 std::unique_ptr<Entry> entry); |
| 69 | 74 |
| 75 const bool using_static_catalog_ = false; |
| 70 base::FilePath system_package_dir_; | 76 base::FilePath system_package_dir_; |
| 71 scoped_refptr<base::TaskRunner> file_task_runner_; | 77 scoped_refptr<base::TaskRunner> file_task_runner_; |
| 72 ManifestProvider* const manifest_provider_; | 78 ManifestProvider* const manifest_provider_; |
| 73 std::map<std::string, std::string> package_name_overrides_; | 79 std::map<std::string, std::string> package_name_overrides_; |
| 74 std::map<std::string, base::FilePath> manifest_path_overrides_; | 80 std::map<std::string, base::FilePath> manifest_path_overrides_; |
| 75 base::WeakPtrFactory<Reader> weak_factory_; | 81 base::WeakPtrFactory<Reader> weak_factory_; |
| 76 | 82 |
| 77 DISALLOW_COPY_AND_ASSIGN(Reader); | 83 DISALLOW_COPY_AND_ASSIGN(Reader); |
| 78 }; | 84 }; |
| 79 | 85 |
| 80 } // namespace catalog | 86 } // namespace catalog |
| 81 | 87 |
| 82 #endif // SERVICES_CATALOG_READER_H_ | 88 #endif // SERVICES_CATALOG_READER_H_ |
| OLD | NEW |