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/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "mojo/public/cpp/bindings/binding_set.h" | 11 #include "mojo/public/cpp/bindings/binding_set.h" |
12 #include "services/catalog/entry.h" | 12 #include "services/catalog/entry.h" |
13 #include "services/catalog/public/interfaces/catalog.mojom.h" | 13 #include "services/catalog/public/interfaces/catalog.mojom.h" |
14 #include "services/catalog/store.h" | 14 #include "services/catalog/store.h" |
15 #include "services/service_manager/public/cpp/interface_factory.h" | 15 #include "services/service_manager/public/cpp/interface_factory.h" |
16 #include "services/service_manager/public/interfaces/resolver.mojom.h" | 16 #include "services/service_manager/public/interfaces/resolver.mojom.h" |
17 | 17 |
18 namespace catalog { | 18 namespace catalog { |
19 | 19 |
20 class EntryCache; | 20 class EntryCache; |
21 class Reader; | 21 class ManifestProvider; |
22 | 22 |
23 class Instance : public service_manager::mojom::Resolver, | 23 class Instance : public service_manager::mojom::Resolver, |
24 public mojom::Catalog { | 24 public mojom::Catalog { |
25 public: | 25 public: |
26 // |manifest_provider| may be null. | 26 // Neither |system_cache| nor |service_manifest_provider| is owned. |
27 explicit Instance(Reader* system_reader); | 27 // |service_manifest_provider| may be null |
| 28 Instance(EntryCache* system_cache, |
| 29 ManifestProvider* service_manifest_provider); |
28 ~Instance() override; | 30 ~Instance() override; |
29 | 31 |
30 void BindResolver(service_manager::mojom::ResolverRequest request); | 32 void BindResolver(service_manager::mojom::ResolverRequest request); |
31 void BindCatalog(mojom::CatalogRequest request); | 33 void BindCatalog(mojom::CatalogRequest request); |
32 | 34 |
33 // Called when |cache| has been populated by a directory scan. | |
34 void CacheReady(EntryCache* cache); | |
35 | |
36 private: | 35 private: |
37 // service_manager::mojom::Resolver: | 36 // service_manager::mojom::Resolver: |
38 void ResolveServiceName(const std::string& service_name, | 37 void ResolveServiceName(const std::string& service_name, |
39 const ResolveServiceNameCallback& callback) override; | 38 const ResolveServiceNameCallback& callback) override; |
40 | 39 |
41 // mojom::Catalog: | 40 // mojom::Catalog: |
42 void GetEntries(const base::Optional<std::vector<std::string>>& names, | 41 void GetEntries(const base::Optional<std::vector<std::string>>& names, |
43 const GetEntriesCallback& callback) override; | 42 const GetEntriesCallback& callback) override; |
44 void GetEntriesProvidingCapability( | 43 void GetEntriesProvidingCapability( |
45 const std::string& capability, | 44 const std::string& capability, |
46 const GetEntriesProvidingCapabilityCallback& callback) override; | 45 const GetEntriesProvidingCapabilityCallback& callback) override; |
47 void GetEntriesConsumingMIMEType( | 46 void GetEntriesConsumingMIMEType( |
48 const std::string& mime_type, | 47 const std::string& mime_type, |
49 const GetEntriesConsumingMIMETypeCallback& callback) override; | 48 const GetEntriesConsumingMIMETypeCallback& callback) override; |
50 void GetEntriesSupportingScheme( | 49 void GetEntriesSupportingScheme( |
51 const std::string& scheme, | 50 const std::string& scheme, |
52 const GetEntriesSupportingSchemeCallback& callback) override; | 51 const GetEntriesSupportingSchemeCallback& callback) override; |
53 | 52 |
54 mojo::BindingSet<service_manager::mojom::Resolver> resolver_bindings_; | 53 mojo::BindingSet<service_manager::mojom::Resolver> resolver_bindings_; |
55 mojo::BindingSet<mojom::Catalog> catalog_bindings_; | 54 mojo::BindingSet<mojom::Catalog> catalog_bindings_; |
56 | 55 |
57 Reader* system_reader_; | |
58 | |
59 // A map of name -> Entry data structure for system-level packages (i.e. those | 56 // A map of name -> Entry data structure for system-level packages (i.e. those |
60 // that are visible to all users). | 57 // that are visible to all users). |
61 // TODO(beng): eventually add per-user applications. | 58 // TODO(beng): eventually add per-user applications. |
62 EntryCache* system_cache_ = nullptr; | 59 EntryCache* const system_cache_; |
63 | 60 |
64 // We only bind requests for these interfaces once the catalog has been | 61 // A runtime interface the embedder can use to provide dynamic manifest data |
65 // populated. These data structures queue requests until that happens. | 62 // to be queried on-demand if something can't be found in |system_cache_|. |
66 std::vector<service_manager::mojom::ResolverRequest> | 63 ManifestProvider* const service_manifest_provider_; |
67 pending_resolver_requests_; | |
68 std::vector<mojom::CatalogRequest> pending_catalog_requests_; | |
69 | 64 |
70 DISALLOW_COPY_AND_ASSIGN(Instance); | 65 DISALLOW_COPY_AND_ASSIGN(Instance); |
71 }; | 66 }; |
72 | 67 |
73 } // namespace catalog | 68 } // namespace catalog |
74 | 69 |
75 #endif // SERVICES_CATALOG_INSTANCE_H_ | 70 #endif // SERVICES_CATALOG_INSTANCE_H_ |
OLD | NEW |