| 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_INSTANCE_H_ | 5 #ifndef SERVICES_CATALOG_INSTANCE_H_ |
| 6 #define SERVICES_CATALOG_INSTANCE_H_ | 6 #define SERVICES_CATALOG_INSTANCE_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 "services/catalog/entry.h" | 13 #include "services/catalog/entry.h" |
| 14 #include "services/catalog/public/interfaces/catalog.mojom.h" | 14 #include "services/catalog/public/interfaces/catalog.mojom.h" |
| 15 #include "services/catalog/store.h" | 15 #include "services/catalog/store.h" |
| 16 #include "services/catalog/types.h" | 16 #include "services/catalog/types.h" |
| 17 #include "services/shell/public/cpp/interface_factory.h" | 17 #include "services/shell/public/cpp/interface_factory.h" |
| 18 #include "services/shell/public/interfaces/shell_resolver.mojom.h" | 18 #include "services/shell/public/interfaces/shell_resolver.mojom.h" |
| 19 | 19 |
| 20 namespace catalog { | 20 namespace catalog { |
| 21 | 21 |
| 22 class Reader; | 22 class Reader; |
| 23 class Store; | 23 class Store; |
| 24 | 24 |
| 25 class Instance : public shell::mojom::ShellResolver, | 25 class Instance : public shell::mojom::ShellResolver, |
| 26 public mojom::Catalog { | 26 public mojom::Catalog { |
| 27 public: | 27 public: |
| 28 // |manifest_provider| may be null. | 28 // |manifest_provider| may be null. |
| 29 Instance(scoped_ptr<Store> store, Reader* system_reader); | 29 Instance(std::unique_ptr<Store> store, Reader* system_reader); |
| 30 ~Instance() override; | 30 ~Instance() override; |
| 31 | 31 |
| 32 void BindShellResolver(shell::mojom::ShellResolverRequest request); | 32 void BindShellResolver(shell::mojom::ShellResolverRequest request); |
| 33 void BindCatalog(mojom::CatalogRequest request); | 33 void BindCatalog(mojom::CatalogRequest request); |
| 34 | 34 |
| 35 // Called when |cache| has been populated by a directory scan. | 35 // Called when |cache| has been populated by a directory scan. |
| 36 void CacheReady(EntryCache* cache); | 36 void CacheReady(EntryCache* cache); |
| 37 | 37 |
| 38 private: | 38 private: |
| 39 using MojoNameAliasMap = | 39 using MojoNameAliasMap = |
| (...skipping 21 matching lines...) Expand all Loading... |
| 61 void SerializeCatalog(); | 61 void SerializeCatalog(); |
| 62 | 62 |
| 63 // Receives the result of manifest parsing, may be received after the | 63 // Receives the result of manifest parsing, may be received after the |
| 64 // catalog object that issued the request is destroyed. | 64 // catalog object that issued the request is destroyed. |
| 65 static void OnReadManifest(base::WeakPtr<Instance> instance, | 65 static void OnReadManifest(base::WeakPtr<Instance> instance, |
| 66 const std::string& mojo_name, | 66 const std::string& mojo_name, |
| 67 const ResolveMojoNameCallback& callback, | 67 const ResolveMojoNameCallback& callback, |
| 68 shell::mojom::ResolveResultPtr result); | 68 shell::mojom::ResolveResultPtr result); |
| 69 | 69 |
| 70 // User-specific persistent storage of package manifests and other settings. | 70 // User-specific persistent storage of package manifests and other settings. |
| 71 scoped_ptr<Store> store_; | 71 std::unique_ptr<Store> store_; |
| 72 | 72 |
| 73 mojo::BindingSet<shell::mojom::ShellResolver> shell_resolver_bindings_; | 73 mojo::BindingSet<shell::mojom::ShellResolver> shell_resolver_bindings_; |
| 74 mojo::BindingSet<mojom::Catalog> catalog_bindings_; | 74 mojo::BindingSet<mojom::Catalog> catalog_bindings_; |
| 75 | 75 |
| 76 Reader* system_reader_; | 76 Reader* system_reader_; |
| 77 | 77 |
| 78 // A map of name -> Entry data structure for system-level packages (i.e. those | 78 // A map of name -> Entry data structure for system-level packages (i.e. those |
| 79 // that are visible to all users). | 79 // that are visible to all users). |
| 80 // TODO(beng): eventually add per-user applications. | 80 // TODO(beng): eventually add per-user applications. |
| 81 EntryCache* system_cache_ = nullptr; | 81 EntryCache* system_cache_ = nullptr; |
| 82 | 82 |
| 83 // We only bind requests for these interfaces once the catalog has been | 83 // We only bind requests for these interfaces once the catalog has been |
| 84 // populated. These data structures queue requests until that happens. | 84 // populated. These data structures queue requests until that happens. |
| 85 std::vector<shell::mojom::ShellResolverRequest> | 85 std::vector<shell::mojom::ShellResolverRequest> |
| 86 pending_shell_resolver_requests_; | 86 pending_shell_resolver_requests_; |
| 87 std::vector<mojom::CatalogRequest> pending_catalog_requests_; | 87 std::vector<mojom::CatalogRequest> pending_catalog_requests_; |
| 88 | 88 |
| 89 base::WeakPtrFactory<Instance> weak_factory_; | 89 base::WeakPtrFactory<Instance> weak_factory_; |
| 90 | 90 |
| 91 DISALLOW_COPY_AND_ASSIGN(Instance); | 91 DISALLOW_COPY_AND_ASSIGN(Instance); |
| 92 }; | 92 }; |
| 93 | 93 |
| 94 } // namespace catalog | 94 } // namespace catalog |
| 95 | 95 |
| 96 #endif // SERVICES_CATALOG_INSTANCE_H_ | 96 #endif // SERVICES_CATALOG_INSTANCE_H_ |
| OLD | NEW |