| 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 MOJO_SERVICES_CATALOG_CATALOG_H_ | 5 #ifndef MOJO_SERVICES_CATALOG_CATALOG_H_ |
| 6 #define MOJO_SERVICES_CATALOG_CATALOG_H_ | 6 #define MOJO_SERVICES_CATALOG_CATALOG_H_ |
| 7 | 7 |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "mojo/public/cpp/bindings/binding_set.h" | 12 #include "mojo/public/cpp/bindings/binding_set.h" |
| 13 #include "mojo/services/catalog/entry.h" | 13 #include "mojo/services/catalog/entry.h" |
| 14 #include "mojo/services/catalog/public/interfaces/catalog.mojom.h" | 14 #include "mojo/services/catalog/public/interfaces/catalog.mojom.h" |
| 15 #include "mojo/services/catalog/public/interfaces/resolver.mojom.h" | 15 #include "mojo/services/catalog/public/interfaces/resolver.mojom.h" |
| 16 #include "mojo/services/catalog/store.h" | 16 #include "mojo/services/catalog/store.h" |
| 17 #include "mojo/shell/public/cpp/interface_factory.h" | 17 #include "mojo/shell/public/cpp/interface_factory.h" |
| 18 #include "mojo/shell/public/interfaces/shell_resolver.mojom.h" | 18 #include "mojo/shell/public/interfaces/shell_resolver.mojom.h" |
| 19 | 19 |
| 20 namespace catalog { | 20 namespace catalog { |
| 21 | 21 |
| 22 class ManifestProvider; |
| 22 class Store; | 23 class Store; |
| 23 | 24 |
| 24 struct ReadManifestResult { | 25 struct ReadManifestResult { |
| 25 ReadManifestResult(); | 26 ReadManifestResult(); |
| 26 ~ReadManifestResult(); | 27 ~ReadManifestResult(); |
| 27 scoped_ptr<base::Value> manifest_root; | 28 mojo::shell::mojom::ResolveResultPtr resolve_result; |
| 28 base::FilePath package_dir; | 29 scoped_ptr<Entry> catalog_entry; |
| 29 }; | 30 }; |
| 30 | 31 |
| 31 class Catalog : public mojom::Resolver, | 32 class Catalog : public mojom::Resolver, |
| 32 public mojo::shell::mojom::ShellResolver, | 33 public mojo::shell::mojom::ShellResolver, |
| 33 public mojom::Catalog { | 34 public mojom::Catalog { |
| 34 public: | 35 public: |
| 35 Catalog(scoped_ptr<Store> store, base::TaskRunner* file_task_runner); | 36 // |manifest_provider| may be null. |
| 37 Catalog(scoped_ptr<Store> store, |
| 38 base::TaskRunner* file_task_runner, |
| 39 ManifestProvider* manifest_provider); |
| 36 ~Catalog() override; | 40 ~Catalog() override; |
| 37 | 41 |
| 38 void BindResolver(mojom::ResolverRequest request); | 42 void BindResolver(mojom::ResolverRequest request); |
| 39 void BindShellResolver(mojo::shell::mojom::ShellResolverRequest request); | 43 void BindShellResolver(mojo::shell::mojom::ShellResolverRequest request); |
| 40 void BindCatalog(mojom::CatalogRequest request); | 44 void BindCatalog(mojom::CatalogRequest request); |
| 41 | 45 |
| 42 private: | 46 private: |
| 43 using MojoNameAliasMap = | 47 using MojoNameAliasMap = |
| 44 std::map<std::string, std::pair<std::string, std::string>>; | 48 std::map<std::string, std::pair<std::string, std::string>>; |
| 45 | 49 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 71 // received after the catalog object that issued the request is destroyed. | 75 // received after the catalog object that issued the request is destroyed. |
| 72 static void OnReadManifest(base::WeakPtr<Catalog> catalog, | 76 static void OnReadManifest(base::WeakPtr<Catalog> catalog, |
| 73 const std::string& name, | 77 const std::string& name, |
| 74 const ResolveMojoNameCallback& callback, | 78 const ResolveMojoNameCallback& callback, |
| 75 scoped_ptr<ReadManifestResult> result); | 79 scoped_ptr<ReadManifestResult> result); |
| 76 | 80 |
| 77 // Populate the catalog with data from |entry|, and pass it to the client | 81 // Populate the catalog with data from |entry|, and pass it to the client |
| 78 // via callback. | 82 // via callback. |
| 79 void AddEntryToCatalog(scoped_ptr<Entry> entry); | 83 void AddEntryToCatalog(scoped_ptr<Entry> entry); |
| 80 | 84 |
| 85 ManifestProvider* const manifest_provider_; |
| 86 |
| 81 // Directory that contains packages and executables visible to all users. | 87 // Directory that contains packages and executables visible to all users. |
| 82 base::FilePath system_package_dir_; | 88 base::FilePath system_package_dir_; |
| 83 | 89 |
| 84 // TODO(beng): add user package dir. | 90 // TODO(beng): add user package dir. |
| 85 | 91 |
| 86 // User-specific persistent storage of package manifests and other settings. | 92 // User-specific persistent storage of package manifests and other settings. |
| 87 scoped_ptr<Store> store_; | 93 scoped_ptr<Store> store_; |
| 88 | 94 |
| 89 // Task runner for performing file operations. | 95 // Task runner for performing file operations. |
| 90 base::TaskRunner* file_task_runner_; | 96 base::TaskRunner* const file_task_runner_; |
| 91 | 97 |
| 92 mojo::BindingSet<mojom::Resolver> resolver_bindings_; | 98 mojo::BindingSet<mojom::Resolver> resolver_bindings_; |
| 93 mojo::BindingSet<mojo::shell::mojom::ShellResolver> shell_resolver_bindings_; | 99 mojo::BindingSet<mojo::shell::mojom::ShellResolver> shell_resolver_bindings_; |
| 94 mojo::BindingSet<mojom::Catalog> catalog_bindings_; | 100 mojo::BindingSet<mojom::Catalog> catalog_bindings_; |
| 95 | 101 |
| 96 // Mojo name -> Entry storage, constructed from Store/package manifests. | 102 // Mojo name -> Entry storage, constructed from Store/package manifests. |
| 97 std::map<std::string, scoped_ptr<Entry>> catalog_; | 103 std::map<std::string, scoped_ptr<Entry>> catalog_; |
| 98 | 104 |
| 99 base::WeakPtrFactory<Catalog> weak_factory_; | 105 base::WeakPtrFactory<Catalog> weak_factory_; |
| 100 | 106 |
| 101 DISALLOW_COPY_AND_ASSIGN(Catalog); | 107 DISALLOW_COPY_AND_ASSIGN(Catalog); |
| 102 }; | 108 }; |
| 103 | 109 |
| 104 } // namespace catalog | 110 } // namespace catalog |
| 105 | 111 |
| 106 #endif // MOJO_SERVICES_CATALOG_CATALOG_H_ | 112 #endif // MOJO_SERVICES_CATALOG_CATALOG_H_ |
| OLD | NEW |