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

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

Issue 2645973006: [Service Manager] Get rid of dynamic service discovery (Closed)
Patch Set: . Created 3 years, 11 months 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 | « services/catalog/BUILD.gn ('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/entry_cache.h"
17 #include "services/catalog/public/interfaces/catalog.mojom.h" 18 #include "services/catalog/public/interfaces/catalog.mojom.h"
18 #include "services/service_manager/public/cpp/interface_factory.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 FilePath;
25 class SingleThreadTaskRunner;
26 class Value; 26 class Value;
27 } 27 }
28 28
29 namespace filesystem { 29 namespace filesystem {
30 class LockTable; 30 class LockTable;
31 } 31 }
32 32
33 namespace service_manager { 33 namespace service_manager {
34 class ServiceContext; 34 class ServiceContext;
35 } 35 }
36 36
37 namespace catalog { 37 namespace catalog {
38 38
39 class EntryCache;
40 class Instance; 39 class Instance;
41 class ManifestProvider; 40 class ManifestProvider;
42 class Reader;
43 41
44 // Creates and owns an instance of the catalog. Exposes a ServicePtr that 42 // Creates and owns an instance of the catalog. Exposes a ServicePtr that
45 // can be passed to the service manager, potentially in a different process. 43 // can be passed to the service manager, potentially in a different process.
46 class Catalog 44 class Catalog
47 : public service_manager::InterfaceFactory<mojom::Catalog>, 45 : public service_manager::InterfaceFactory<mojom::Catalog>,
48 public service_manager::InterfaceFactory<filesystem::mojom::Directory>, 46 public service_manager::InterfaceFactory<filesystem::mojom::Directory>,
49 public service_manager::InterfaceFactory< 47 public service_manager::InterfaceFactory<
50 service_manager::mojom::Resolver>, 48 service_manager::mojom::Resolver> {
51 public service_manager::InterfaceFactory<mojom::CatalogControl>,
52 public mojom::CatalogControl {
53 public: 49 public:
54 // Constructs a catalog over a static manifest. This catalog never performs 50 // Constructs a catalog over a static manifest. This catalog never performs
55 // file I/O. 51 // file I/O. Note that either |static_manifest| or |service_manifest_provider|
56 explicit Catalog(std::unique_ptr<base::Value> static_manifest); 52 // may be null. If both are null, no service names will be resolved.
57 53 explicit Catalog(std::unique_ptr<base::Value> static_manifest,
58 // |manifest_provider| may be null. 54 ManifestProvider* service_manifest_provider = nullptr);
59 Catalog(base::SequencedWorkerPool* worker_pool,
60 ManifestProvider* manifest_provider);
61 Catalog(base::SingleThreadTaskRunner* task_runner,
62 ManifestProvider* manifest_provider);
63 55
64 ~Catalog() override; 56 ~Catalog() override;
65 57
66 // By default, "foo" resolves to a package named "foo". This allows 58 service_manager::mojom::ServicePtr TakeService();
67 // an embedder to override that behavior for specific service names. Must be
68 // called before the catalog is connected to the ServiceManager.
69 void OverridePackageName(const std::string& service_name,
70 const std::string& package_name);
71 59
72 service_manager::mojom::ServicePtr TakeService(); 60 // Allows an embedder to override the default static manifest contents for
61 // Catalog instances which are constructed with a null static manifest.
62 static void SetDefaultCatalogManifest(
63 std::unique_ptr<base::Value> static_manifest);
64
65 // Loads a default catalog manifest from the given FilePath. |path| is taken
66 // to be relative to the current executable's path.
67 static void LoadDefaultCatalogManifest(const base::FilePath& path);
73 68
74 private: 69 private:
75 class ServiceImpl; 70 class ServiceImpl;
76 71
77 Catalog();
78
79 // Starts a scane for system packages.
80 void ScanSystemPackageDir();
81
82 // service_manager::InterfaceFactory<service_manager::mojom::Resolver>: 72 // service_manager::InterfaceFactory<service_manager::mojom::Resolver>:
83 void Create(const service_manager::Identity& remote_identity, 73 void Create(const service_manager::Identity& remote_identity,
84 service_manager::mojom::ResolverRequest request) override; 74 service_manager::mojom::ResolverRequest request) override;
85 75
86 // service_manager::InterfaceFactory<mojom::Catalog>: 76 // service_manager::InterfaceFactory<mojom::Catalog>:
87 void Create(const service_manager::Identity& remote_identity, 77 void Create(const service_manager::Identity& remote_identity,
88 mojom::CatalogRequest request) override; 78 mojom::CatalogRequest request) override;
89 79
90 // service_manager::InterfaceFactory<filesystem::mojom::Directory>: 80 // service_manager::InterfaceFactory<filesystem::mojom::Directory>:
91 void Create(const service_manager::Identity& remote_identity, 81 void Create(const service_manager::Identity& remote_identity,
92 filesystem::mojom::DirectoryRequest request) override; 82 filesystem::mojom::DirectoryRequest request) override;
93 83
94 // service_manager::InterfaceFactory<mojom::CatalogControl>:
95 void Create(const service_manager::Identity& remote_identity,
96 mojom::CatalogControlRequest request) override;
97
98 // mojom::CatalogControl:
99 void OverrideManifestPath(
100 const std::string& service_name,
101 const base::FilePath& path,
102 const OverrideManifestPathCallback& callback) override;
103
104 Instance* GetInstanceForUserId(const std::string& user_id); 84 Instance* GetInstanceForUserId(const std::string& user_id);
105 85
106 void SystemPackageDirScanned();
107
108 service_manager::mojom::ServicePtr service_; 86 service_manager::mojom::ServicePtr service_;
109 std::unique_ptr<service_manager::ServiceContext> service_context_; 87 std::unique_ptr<service_manager::ServiceContext> service_context_;
110 88 ManifestProvider* service_manifest_provider_;
89 EntryCache system_cache_;
111 std::map<std::string, std::unique_ptr<Instance>> instances_; 90 std::map<std::string, std::unique_ptr<Instance>> instances_;
112 91
113 std::unique_ptr<Reader> system_reader_;
114 const std::unique_ptr<EntryCache> system_cache_;
115 bool loaded_ = false;
116
117 scoped_refptr<filesystem::LockTable> lock_table_; 92 scoped_refptr<filesystem::LockTable> lock_table_;
118 93
119 mojo::BindingSet<mojom::CatalogControl> control_bindings_;
120
121 base::WeakPtrFactory<Catalog> weak_factory_; 94 base::WeakPtrFactory<Catalog> weak_factory_;
122 95
123 DISALLOW_COPY_AND_ASSIGN(Catalog); 96 DISALLOW_COPY_AND_ASSIGN(Catalog);
124 }; 97 };
125 98
126 } // namespace catalog 99 } // namespace catalog
127 100
128 #endif // SERVICES_CATALOG_CATALOG_H_ 101 #endif // SERVICES_CATALOG_CATALOG_H_
OLDNEW
« no previous file with comments | « services/catalog/BUILD.gn ('k') | services/catalog/catalog.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698