| 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 <memory> |
| 9 |
| 8 #include "base/callback.h" | 10 #include "base/callback.h" |
| 9 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 10 #include "base/macros.h" | 12 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 13 #include "services/catalog/types.h" | 14 #include "services/catalog/types.h" |
| 14 #include "services/shell/public/interfaces/shell_resolver.mojom.h" | 15 #include "services/shell/public/interfaces/shell_resolver.mojom.h" |
| 15 | 16 |
| 16 namespace base { | 17 namespace base { |
| 17 class TaskRunner; | 18 class TaskRunner; |
| 18 } | 19 } |
| 19 | 20 |
| 20 namespace catalog { | 21 namespace catalog { |
| 21 | 22 |
| 22 class Entry; | 23 class Entry; |
| 23 class ManifestProvider; | 24 class ManifestProvider; |
| 24 | 25 |
| 25 // Responsible for loading manifests & building the Entry data structures. | 26 // Responsible for loading manifests & building the Entry data structures. |
| 26 class Reader { | 27 class Reader { |
| 27 public: | 28 public: |
| 28 using ReadManifestCallback = | 29 using ReadManifestCallback = base::Callback<void(std::unique_ptr<Entry>)>; |
| 29 base::Callback<void(scoped_ptr<Entry>)>; | 30 using CreateEntryForNameCallback = |
| 30 using CreateEntryForNameCallback = | |
| 31 base::Callback<void(shell::mojom::ResolveResultPtr)>; | 31 base::Callback<void(shell::mojom::ResolveResultPtr)>; |
| 32 | 32 |
| 33 Reader(base::TaskRunner* file_task_runner, | 33 Reader(base::TaskRunner* file_task_runner, |
| 34 ManifestProvider* manifest_provider); | 34 ManifestProvider* manifest_provider); |
| 35 ~Reader(); | 35 ~Reader(); |
| 36 | 36 |
| 37 // Scans the contents of |package_dir|, reading all application manifests and | 37 // Scans the contents of |package_dir|, reading all application manifests and |
| 38 // populating |cache|. Runs |read_complete_closure| when done. | 38 // populating |cache|. Runs |read_complete_closure| when done. |
| 39 void Read(const base::FilePath& package_dir, | 39 void Read(const base::FilePath& package_dir, |
| 40 EntryCache* cache, | 40 EntryCache* cache, |
| 41 const base::Closure& read_complete_closure); | 41 const base::Closure& read_complete_closure); |
| 42 | 42 |
| 43 // Returns an Entry for |mojo_name| via |callback|, assuming a manifest file | 43 // Returns an Entry for |mojo_name| via |callback|, assuming a manifest file |
| 44 // in the canonical location | 44 // in the canonical location |
| 45 void CreateEntryForName( | 45 void CreateEntryForName( |
| 46 const std::string& mojo_name, | 46 const std::string& mojo_name, |
| 47 EntryCache* cache, | 47 EntryCache* cache, |
| 48 const CreateEntryForNameCallback& entry_created_callback); | 48 const CreateEntryForNameCallback& entry_created_callback); |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 void OnReadManifest(EntryCache* cache, | 51 void OnReadManifest(EntryCache* cache, |
| 52 const CreateEntryForNameCallback& entry_created_callback, | 52 const CreateEntryForNameCallback& entry_created_callback, |
| 53 scoped_ptr<Entry> entry); | 53 std::unique_ptr<Entry> entry); |
| 54 | 54 |
| 55 base::FilePath system_package_dir_; | 55 base::FilePath system_package_dir_; |
| 56 base::TaskRunner* file_task_runner_; | 56 base::TaskRunner* file_task_runner_; |
| 57 ManifestProvider* const manifest_provider_; | 57 ManifestProvider* const manifest_provider_; |
| 58 base::WeakPtrFactory<Reader> weak_factory_; | 58 base::WeakPtrFactory<Reader> weak_factory_; |
| 59 | 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(Reader); | 60 DISALLOW_COPY_AND_ASSIGN(Reader); |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 } // namespace catalog | 63 } // namespace catalog |
| 64 | 64 |
| 65 #endif // SERVICES_CATALOG_READER_H_ | 65 #endif // SERVICES_CATALOG_READER_H_ |
| OLD | NEW |