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_CATALOG_H_ | 5 #ifndef SERVICES_CATALOG_CATALOG_H_ |
6 #define SERVICES_CATALOG_CATALOG_H_ | 6 #define 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 "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/public/interfaces/resolver.mojom.h" | 15 #include "services/catalog/public/interfaces/resolver.mojom.h" |
16 #include "services/catalog/store.h" | 16 #include "services/catalog/store.h" |
17 #include "services/catalog/types.h" | 17 #include "services/catalog/types.h" |
18 #include "services/shell/public/cpp/interface_factory.h" | 18 #include "services/shell/public/cpp/interface_factory.h" |
19 #include "services/shell/public/interfaces/shell_resolver.mojom.h" | 19 #include "services/shell/public/interfaces/shell_resolver.mojom.h" |
20 | 20 |
21 namespace catalog { | 21 namespace catalog { |
22 | 22 |
23 class ManifestProvider; | 23 class ManifestProvider; |
24 class Store; | 24 class Store; |
25 | 25 |
26 struct ReadManifestResult { | 26 struct ReadManifestResult { |
27 ReadManifestResult(); | 27 ReadManifestResult(); |
28 ~ReadManifestResult(); | 28 ~ReadManifestResult(); |
29 mojo::shell::mojom::ResolveResultPtr resolve_result; | 29 shell::mojom::ResolveResultPtr resolve_result; |
30 scoped_ptr<Entry> catalog_entry; | 30 scoped_ptr<Entry> catalog_entry; |
31 base::FilePath package_dir; | 31 base::FilePath package_dir; |
32 }; | 32 }; |
33 | 33 |
34 class Catalog : public mojom::Resolver, | 34 class Catalog : public mojom::Resolver, |
35 public mojo::shell::mojom::ShellResolver, | 35 public shell::mojom::ShellResolver, |
36 public mojom::Catalog { | 36 public mojom::Catalog { |
37 public: | 37 public: |
38 // |manifest_provider| may be null. | 38 // |manifest_provider| may be null. |
39 Catalog(scoped_ptr<Store> store, | 39 Catalog(scoped_ptr<Store> store, |
40 base::TaskRunner* file_task_runner, | 40 base::TaskRunner* file_task_runner, |
41 EntryCache* system_catalog, | 41 EntryCache* system_catalog, |
42 ManifestProvider* manifest_provider); | 42 ManifestProvider* manifest_provider); |
43 ~Catalog() override; | 43 ~Catalog() override; |
44 | 44 |
45 void BindResolver(mojom::ResolverRequest request); | 45 void BindResolver(mojom::ResolverRequest request); |
46 void BindShellResolver(mojo::shell::mojom::ShellResolverRequest request); | 46 void BindShellResolver(shell::mojom::ShellResolverRequest request); |
47 void BindCatalog(mojom::CatalogRequest request); | 47 void BindCatalog(mojom::CatalogRequest request); |
48 | 48 |
49 private: | 49 private: |
50 using MojoNameAliasMap = | 50 using MojoNameAliasMap = |
51 std::map<std::string, std::pair<std::string, std::string>>; | 51 std::map<std::string, std::pair<std::string, std::string>>; |
52 | 52 |
53 // mojom::Resolver: | 53 // mojom::Resolver: |
54 void ResolveInterfaces(mojo::Array<mojo::String> interfaces, | 54 void ResolveInterfaces(mojo::Array<mojo::String> interfaces, |
55 const ResolveInterfacesCallback& callback) override; | 55 const ResolveInterfacesCallback& callback) override; |
56 void ResolveMIMEType(const mojo::String& mime_type, | 56 void ResolveMIMEType(const mojo::String& mime_type, |
57 const ResolveMIMETypeCallback& callback) override; | 57 const ResolveMIMETypeCallback& callback) override; |
58 void ResolveProtocolScheme( | 58 void ResolveProtocolScheme( |
59 const mojo::String& scheme, | 59 const mojo::String& scheme, |
60 const ResolveProtocolSchemeCallback& callback) override; | 60 const ResolveProtocolSchemeCallback& callback) override; |
61 | 61 |
62 // mojo::shell::mojom::ShellResolver: | 62 // shell::mojom::ShellResolver: |
63 void ResolveMojoName(const mojo::String& mojo_name, | 63 void ResolveMojoName(const mojo::String& mojo_name, |
64 const ResolveMojoNameCallback& callback) override; | 64 const ResolveMojoNameCallback& callback) override; |
65 | 65 |
66 // mojom::Catalog: | 66 // mojom::Catalog: |
67 void GetEntries(mojo::Array<mojo::String> names, | 67 void GetEntries(mojo::Array<mojo::String> names, |
68 const GetEntriesCallback& callback) override; | 68 const GetEntriesCallback& callback) override; |
69 | 69 |
70 // Populate/serialize the catalog from/to the supplied store. | 70 // Populate/serialize the catalog from/to the supplied store. |
71 void DeserializeCatalog(); | 71 void DeserializeCatalog(); |
72 void SerializeCatalog(); | 72 void SerializeCatalog(); |
(...skipping 16 matching lines...) Expand all Loading... |
89 // Directory that contains packages visible to this Catalog instance's user. | 89 // Directory that contains packages visible to this Catalog instance's user. |
90 base::FilePath user_package_dir_; | 90 base::FilePath user_package_dir_; |
91 | 91 |
92 // User-specific persistent storage of package manifests and other settings. | 92 // User-specific persistent storage of package manifests and other settings. |
93 scoped_ptr<Store> store_; | 93 scoped_ptr<Store> store_; |
94 | 94 |
95 // Task runner for performing file operations. | 95 // Task runner for performing file operations. |
96 base::TaskRunner* const file_task_runner_; | 96 base::TaskRunner* const file_task_runner_; |
97 | 97 |
98 mojo::BindingSet<mojom::Resolver> resolver_bindings_; | 98 mojo::BindingSet<mojom::Resolver> resolver_bindings_; |
99 mojo::BindingSet<mojo::shell::mojom::ShellResolver> shell_resolver_bindings_; | 99 mojo::BindingSet<shell::mojom::ShellResolver> shell_resolver_bindings_; |
100 mojo::BindingSet<mojom::Catalog> catalog_bindings_; | 100 mojo::BindingSet<mojom::Catalog> catalog_bindings_; |
101 | 101 |
102 // The current user's packages, constructed from Store/package manifests. | 102 // The current user's packages, constructed from Store/package manifests. |
103 EntryCache user_catalog_; | 103 EntryCache user_catalog_; |
104 // Same as above, but for system-level (visible to all-users) packages and | 104 // Same as above, but for system-level (visible to all-users) packages and |
105 // executables. | 105 // executables. |
106 EntryCache* system_catalog_; | 106 EntryCache* system_catalog_; |
107 | 107 |
108 base::WeakPtrFactory<Catalog> weak_factory_; | 108 base::WeakPtrFactory<Catalog> weak_factory_; |
109 | 109 |
110 DISALLOW_COPY_AND_ASSIGN(Catalog); | 110 DISALLOW_COPY_AND_ASSIGN(Catalog); |
111 }; | 111 }; |
112 | 112 |
113 } // namespace catalog | 113 } // namespace catalog |
114 | 114 |
115 #endif // SERVICES_CATALOG_CATALOG_H_ | 115 #endif // SERVICES_CATALOG_CATALOG_H_ |
OLD | NEW |