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 <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 namespace base { | 23 namespace base { |
24 class SequencedWorkerPool; | 24 class SequencedWorkerPool; |
25 class SingleThreadTaskRunner; | 25 class SingleThreadTaskRunner; |
26 } | 26 } |
27 | 27 |
28 namespace filesystem { | 28 namespace filesystem { |
29 class LockTable; | 29 class LockTable; |
30 } | 30 } |
31 | 31 |
32 namespace shell { | 32 namespace service_manager { |
33 class ServiceContext; | 33 class ServiceContext; |
34 } | 34 } |
35 | 35 |
36 namespace catalog { | 36 namespace catalog { |
37 | 37 |
38 class Instance; | 38 class Instance; |
39 class ManifestProvider; | 39 class ManifestProvider; |
40 class Reader; | 40 class Reader; |
41 class Store; | 41 class Store; |
42 | 42 |
43 // Creates and owns an instance of the catalog. Exposes a ServicePtr that | 43 // Creates and owns an instance of the catalog. Exposes a ServicePtr that |
44 // can be passed to the Shell, potentially in a different process. | 44 // can be passed to the Shell, potentially in a different process. |
45 class Catalog : public shell::Service, | 45 class Catalog |
46 public shell::InterfaceFactory<mojom::Catalog>, | 46 : public service_manager::Service, |
47 public shell::InterfaceFactory<filesystem::mojom::Directory>, | 47 public service_manager::InterfaceFactory<mojom::Catalog>, |
48 public shell::InterfaceFactory<shell::mojom::Resolver>, | 48 public service_manager::InterfaceFactory<filesystem::mojom::Directory>, |
49 public shell::InterfaceFactory<mojom::CatalogControl>, | 49 public service_manager::InterfaceFactory< |
50 public mojom::CatalogControl { | 50 service_manager::mojom::Resolver>, |
| 51 public service_manager::InterfaceFactory<mojom::CatalogControl>, |
| 52 public mojom::CatalogControl { |
51 public: | 53 public: |
52 // |manifest_provider| may be null. | 54 // |manifest_provider| may be null. |
53 Catalog(base::SequencedWorkerPool* worker_pool, | 55 Catalog(base::SequencedWorkerPool* worker_pool, |
54 std::unique_ptr<Store> store, | 56 std::unique_ptr<Store> store, |
55 ManifestProvider* manifest_provider); | 57 ManifestProvider* manifest_provider); |
56 Catalog(base::SingleThreadTaskRunner* task_runner, | 58 Catalog(base::SingleThreadTaskRunner* task_runner, |
57 std::unique_ptr<Store> store, | 59 std::unique_ptr<Store> store, |
58 ManifestProvider* manifest_provider); | 60 ManifestProvider* manifest_provider); |
59 ~Catalog() override; | 61 ~Catalog() override; |
60 | 62 |
61 // By default, "service:foo" resolves to a package named "foo". This allows | 63 // By default, "service:foo" resolves to a package named "foo". This allows |
62 // an embedder to override that behavior for specific service names. Must be | 64 // an embedder to override that behavior for specific service names. Must be |
63 // called before the catalog is connected to the ServiceManager. | 65 // called before the catalog is connected to the ServiceManager. |
64 void OverridePackageName(const std::string& service_name, | 66 void OverridePackageName(const std::string& service_name, |
65 const std::string& package_name); | 67 const std::string& package_name); |
66 | 68 |
67 shell::mojom::ServicePtr TakeService(); | 69 service_manager::mojom::ServicePtr TakeService(); |
68 | 70 |
69 private: | 71 private: |
70 explicit Catalog(std::unique_ptr<Store> store); | 72 explicit Catalog(std::unique_ptr<Store> store); |
71 | 73 |
72 // Starts a scane for system packages. | 74 // Starts a scane for system packages. |
73 void ScanSystemPackageDir(); | 75 void ScanSystemPackageDir(); |
74 | 76 |
75 // shell::Service: | 77 // service_manager::Service: |
76 bool OnConnect(const shell::Identity& remote_identity, | 78 bool OnConnect(const service_manager::Identity& remote_identity, |
77 shell::InterfaceRegistry* registry) override; | 79 service_manager::InterfaceRegistry* registry) override; |
78 | 80 |
79 // shell::InterfaceFactory<shell::mojom::Resolver>: | 81 // service_manager::InterfaceFactory<service_manager::mojom::Resolver>: |
80 void Create(const shell::Identity& remote_identity, | 82 void Create(const service_manager::Identity& remote_identity, |
81 shell::mojom::ResolverRequest request) override; | 83 service_manager::mojom::ResolverRequest request) override; |
82 | 84 |
83 // shell::InterfaceFactory<mojom::Catalog>: | 85 // service_manager::InterfaceFactory<mojom::Catalog>: |
84 void Create(const shell::Identity& remote_identity, | 86 void Create(const service_manager::Identity& remote_identity, |
85 mojom::CatalogRequest request) override; | 87 mojom::CatalogRequest request) override; |
86 | 88 |
87 // shell::InterfaceFactory<filesystem::mojom::Directory>: | 89 // service_manager::InterfaceFactory<filesystem::mojom::Directory>: |
88 void Create(const shell::Identity& remote_identity, | 90 void Create(const service_manager::Identity& remote_identity, |
89 filesystem::mojom::DirectoryRequest request) override; | 91 filesystem::mojom::DirectoryRequest request) override; |
90 | 92 |
91 // shell::InterfaceFactory<mojom::CatalogControl>: | 93 // service_manager::InterfaceFactory<mojom::CatalogControl>: |
92 void Create(const shell::Identity& remote_identity, | 94 void Create(const service_manager::Identity& remote_identity, |
93 mojom::CatalogControlRequest request) override; | 95 mojom::CatalogControlRequest request) override; |
94 | 96 |
95 // mojom::CatalogControl: | 97 // mojom::CatalogControl: |
96 void OverrideManifestPath( | 98 void OverrideManifestPath( |
97 const std::string& service_name, | 99 const std::string& service_name, |
98 const base::FilePath& path, | 100 const base::FilePath& path, |
99 const OverrideManifestPathCallback& callback) override; | 101 const OverrideManifestPathCallback& callback) override; |
100 | 102 |
101 Instance* GetInstanceForUserId(const std::string& user_id); | 103 Instance* GetInstanceForUserId(const std::string& user_id); |
102 | 104 |
103 void SystemPackageDirScanned(); | 105 void SystemPackageDirScanned(); |
104 | 106 |
105 std::unique_ptr<Store> store_; | 107 std::unique_ptr<Store> store_; |
106 | 108 |
107 shell::mojom::ServicePtr service_; | 109 service_manager::mojom::ServicePtr service_; |
108 std::unique_ptr<shell::ServiceContext> shell_connection_; | 110 std::unique_ptr<service_manager::ServiceContext> service_manager_connection_; |
109 | 111 |
110 std::map<std::string, std::unique_ptr<Instance>> instances_; | 112 std::map<std::string, std::unique_ptr<Instance>> instances_; |
111 | 113 |
112 std::unique_ptr<Reader> system_reader_; | 114 std::unique_ptr<Reader> system_reader_; |
113 EntryCache system_cache_; | 115 EntryCache system_cache_; |
114 bool loaded_ = false; | 116 bool loaded_ = false; |
115 | 117 |
116 scoped_refptr<filesystem::LockTable> lock_table_; | 118 scoped_refptr<filesystem::LockTable> lock_table_; |
117 | 119 |
118 mojo::BindingSet<mojom::CatalogControl> control_bindings_; | 120 mojo::BindingSet<mojom::CatalogControl> control_bindings_; |
119 | 121 |
120 base::WeakPtrFactory<Catalog> weak_factory_; | 122 base::WeakPtrFactory<Catalog> weak_factory_; |
121 | 123 |
122 DISALLOW_COPY_AND_ASSIGN(Catalog); | 124 DISALLOW_COPY_AND_ASSIGN(Catalog); |
123 }; | 125 }; |
124 | 126 |
125 } // namespace catalog | 127 } // namespace catalog |
126 | 128 |
127 #endif // SERVICES_CATALOG_CATALOG_H_ | 129 #endif // SERVICES_CATALOG_CATALOG_H_ |
OLD | NEW |