Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: services/catalog/catalog.h

Issue 2476063002: Service Manager: Rework Service and ServiceContext lifetime (Closed)
Patch Set: . Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/mojo/services/media_service.cc ('k') | services/catalog/catalog.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "components/filesystem/public/interfaces/directory.mojom.h" 14 #include "components/filesystem/public/interfaces/directory.mojom.h"
15 #include "mojo/public/cpp/bindings/binding.h" 15 #include "mojo/public/cpp/bindings/binding.h"
16 #include "mojo/public/cpp/bindings/binding_set.h" 16 #include "mojo/public/cpp/bindings/binding_set.h"
17 #include "services/catalog/public/interfaces/catalog.mojom.h" 17 #include "services/catalog/public/interfaces/catalog.mojom.h"
18 #include "services/catalog/types.h" 18 #include "services/catalog/types.h"
19 #include "services/service_manager/public/cpp/interface_factory.h"
19 #include "services/service_manager/public/cpp/service.h" 20 #include "services/service_manager/public/cpp/service.h"
20 #include "services/service_manager/public/interfaces/resolver.mojom.h" 21 #include "services/service_manager/public/interfaces/resolver.mojom.h"
21 #include "services/service_manager/public/interfaces/service.mojom.h" 22 #include "services/service_manager/public/interfaces/service.mojom.h"
22 23
23 namespace base { 24 namespace base {
24 class SequencedWorkerPool; 25 class SequencedWorkerPool;
25 class SingleThreadTaskRunner; 26 class SingleThreadTaskRunner;
26 } 27 }
27 28
28 namespace filesystem { 29 namespace filesystem {
29 class LockTable; 30 class LockTable;
30 } 31 }
31 32
32 namespace service_manager { 33 namespace service_manager {
33 class ServiceContext; 34 class ServiceContext;
34 } 35 }
35 36
36 namespace catalog { 37 namespace catalog {
37 38
38 class Instance; 39 class Instance;
39 class ManifestProvider; 40 class ManifestProvider;
40 class Reader; 41 class Reader;
41 class Store; 42 class Store;
42 43
43 // Creates and owns an instance of the catalog. Exposes a ServicePtr that 44 // Creates and owns an instance of the catalog. Exposes a ServicePtr that
44 // can be passed to the service manager, potentially in a different process. 45 // can be passed to the service manager, potentially in a different process.
45 class Catalog 46 class Catalog
46 : public service_manager::Service, 47 : public service_manager::InterfaceFactory<mojom::Catalog>,
47 public service_manager::InterfaceFactory<mojom::Catalog>,
48 public service_manager::InterfaceFactory<filesystem::mojom::Directory>, 48 public service_manager::InterfaceFactory<filesystem::mojom::Directory>,
49 public service_manager::InterfaceFactory< 49 public service_manager::InterfaceFactory<
50 service_manager::mojom::Resolver>, 50 service_manager::mojom::Resolver>,
51 public service_manager::InterfaceFactory<mojom::CatalogControl>, 51 public service_manager::InterfaceFactory<mojom::CatalogControl>,
52 public mojom::CatalogControl { 52 public mojom::CatalogControl {
53 public: 53 public:
54 // |manifest_provider| may be null. 54 // |manifest_provider| may be null.
55 Catalog(base::SequencedWorkerPool* worker_pool, 55 Catalog(base::SequencedWorkerPool* worker_pool,
56 std::unique_ptr<Store> store, 56 std::unique_ptr<Store> store,
57 ManifestProvider* manifest_provider); 57 ManifestProvider* manifest_provider);
58 Catalog(base::SingleThreadTaskRunner* task_runner, 58 Catalog(base::SingleThreadTaskRunner* task_runner,
59 std::unique_ptr<Store> store, 59 std::unique_ptr<Store> store,
60 ManifestProvider* manifest_provider); 60 ManifestProvider* manifest_provider);
61 ~Catalog() override; 61 ~Catalog() override;
62 62
63 // 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
64 // 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
65 // called before the catalog is connected to the ServiceManager. 65 // called before the catalog is connected to the ServiceManager.
66 void OverridePackageName(const std::string& service_name, 66 void OverridePackageName(const std::string& service_name,
67 const std::string& package_name); 67 const std::string& package_name);
68 68
69 service_manager::mojom::ServicePtr TakeService(); 69 service_manager::mojom::ServicePtr TakeService();
70 70
71 private: 71 private:
72 class ServiceImpl;
73
72 explicit Catalog(std::unique_ptr<Store> store); 74 explicit Catalog(std::unique_ptr<Store> store);
73 75
74 // Starts a scane for system packages. 76 // Starts a scane for system packages.
75 void ScanSystemPackageDir(); 77 void ScanSystemPackageDir();
76 78
77 // service_manager::Service:
78 bool OnConnect(const service_manager::ServiceInfo& remote_info,
79 service_manager::InterfaceRegistry* registry) override;
80
81 // service_manager::InterfaceFactory<service_manager::mojom::Resolver>: 79 // service_manager::InterfaceFactory<service_manager::mojom::Resolver>:
82 void Create(const service_manager::Identity& remote_identity, 80 void Create(const service_manager::Identity& remote_identity,
83 service_manager::mojom::ResolverRequest request) override; 81 service_manager::mojom::ResolverRequest request) override;
84 82
85 // service_manager::InterfaceFactory<mojom::Catalog>: 83 // service_manager::InterfaceFactory<mojom::Catalog>:
86 void Create(const service_manager::Identity& remote_identity, 84 void Create(const service_manager::Identity& remote_identity,
87 mojom::CatalogRequest request) override; 85 mojom::CatalogRequest request) override;
88 86
89 // service_manager::InterfaceFactory<filesystem::mojom::Directory>: 87 // service_manager::InterfaceFactory<filesystem::mojom::Directory>:
90 void Create(const service_manager::Identity& remote_identity, 88 void Create(const service_manager::Identity& remote_identity,
91 filesystem::mojom::DirectoryRequest request) override; 89 filesystem::mojom::DirectoryRequest request) override;
92 90
93 // service_manager::InterfaceFactory<mojom::CatalogControl>: 91 // service_manager::InterfaceFactory<mojom::CatalogControl>:
94 void Create(const service_manager::Identity& remote_identity, 92 void Create(const service_manager::Identity& remote_identity,
95 mojom::CatalogControlRequest request) override; 93 mojom::CatalogControlRequest request) override;
96 94
97 // mojom::CatalogControl: 95 // mojom::CatalogControl:
98 void OverrideManifestPath( 96 void OverrideManifestPath(
99 const std::string& service_name, 97 const std::string& service_name,
100 const base::FilePath& path, 98 const base::FilePath& path,
101 const OverrideManifestPathCallback& callback) override; 99 const OverrideManifestPathCallback& callback) override;
102 100
103 Instance* GetInstanceForUserId(const std::string& user_id); 101 Instance* GetInstanceForUserId(const std::string& user_id);
104 102
105 void SystemPackageDirScanned(); 103 void SystemPackageDirScanned();
106 104
107 std::unique_ptr<Store> store_; 105 std::unique_ptr<Store> store_;
108 106
109 service_manager::mojom::ServicePtr service_; 107 service_manager::mojom::ServicePtr service_;
110 std::unique_ptr<service_manager::ServiceContext> service_manager_connection_; 108 std::unique_ptr<service_manager::ServiceContext> service_context_;
111 109
112 std::map<std::string, std::unique_ptr<Instance>> instances_; 110 std::map<std::string, std::unique_ptr<Instance>> instances_;
113 111
114 std::unique_ptr<Reader> system_reader_; 112 std::unique_ptr<Reader> system_reader_;
115 EntryCache system_cache_; 113 EntryCache system_cache_;
116 bool loaded_ = false; 114 bool loaded_ = false;
117 115
118 scoped_refptr<filesystem::LockTable> lock_table_; 116 scoped_refptr<filesystem::LockTable> lock_table_;
119 117
120 mojo::BindingSet<mojom::CatalogControl> control_bindings_; 118 mojo::BindingSet<mojom::CatalogControl> control_bindings_;
121 119
122 base::WeakPtrFactory<Catalog> weak_factory_; 120 base::WeakPtrFactory<Catalog> weak_factory_;
123 121
124 DISALLOW_COPY_AND_ASSIGN(Catalog); 122 DISALLOW_COPY_AND_ASSIGN(Catalog);
125 }; 123 };
126 124
127 } // namespace catalog 125 } // namespace catalog
128 126
129 #endif // SERVICES_CATALOG_CATALOG_H_ 127 #endif // SERVICES_CATALOG_CATALOG_H_
OLDNEW
« no previous file with comments | « media/mojo/services/media_service.cc ('k') | services/catalog/catalog.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698