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