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

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

Issue 2795883002: Eliminate OnConnect usage (Closed)
Patch Set: . Created 3 years, 8 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
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 #include "services/catalog/catalog.h" 5 #include "services/catalog/catalog.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "base/base_paths.h" 10 #include "base/base_paths.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/json/json_reader.h" 13 #include "base/json/json_reader.h"
14 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.h"
17 #include "base/path_service.h" 17 #include "base/path_service.h"
18 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
19 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
20 #include "components/filesystem/directory_impl.h" 20 #include "components/filesystem/directory_impl.h"
21 #include "components/filesystem/lock_table.h" 21 #include "components/filesystem/lock_table.h"
22 #include "components/filesystem/public/interfaces/types.mojom.h" 22 #include "components/filesystem/public/interfaces/types.mojom.h"
23 #include "mojo/public/cpp/bindings/strong_binding.h" 23 #include "mojo/public/cpp/bindings/strong_binding.h"
24 #include "services/catalog/constants.h" 24 #include "services/catalog/constants.h"
25 #include "services/catalog/entry_cache.h" 25 #include "services/catalog/entry_cache.h"
26 #include "services/catalog/instance.h" 26 #include "services/catalog/instance.h"
27 #include "services/service_manager/public/cpp/binder_registry.h"
27 #include "services/service_manager/public/cpp/connection.h" 28 #include "services/service_manager/public/cpp/connection.h"
28 #include "services/service_manager/public/cpp/interface_registry.h"
29 #include "services/service_manager/public/cpp/service_context.h" 29 #include "services/service_manager/public/cpp/service_context.h"
30 30
31 namespace catalog { 31 namespace catalog {
32 32
33 namespace { 33 namespace {
34 34
35 const char kCatalogServicesKey[] = "services"; 35 const char kCatalogServicesKey[] = "services";
36 const char kCatalogServiceEmbeddedKey[] = "embedded"; 36 const char kCatalogServiceEmbeddedKey[] = "embedded";
37 const char kCatalogServiceExecutableKey[] = "executable"; 37 const char kCatalogServiceExecutableKey[] = "executable";
38 const char kCatalogServiceManifestKey[] = "manifest"; 38 const char kCatalogServiceManifestKey[] = "manifest";
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } else { 105 } else {
106 LOG(ERROR) << "Failed to read manifest entry for \"" << it.key() << "\"."; 106 LOG(ERROR) << "Failed to read manifest entry for \"" << it.key() << "\".";
107 } 107 }
108 } 108 }
109 } 109 }
110 110
111 } // namespace 111 } // namespace
112 112
113 class Catalog::ServiceImpl : public service_manager::Service { 113 class Catalog::ServiceImpl : public service_manager::Service {
114 public: 114 public:
115 explicit ServiceImpl(Catalog* catalog) : catalog_(catalog) {} 115 explicit ServiceImpl(Catalog* catalog) : catalog_(catalog) {
116 registry_.AddInterface<mojom::Catalog>(catalog_);
117 registry_.AddInterface<filesystem::mojom::Directory>(catalog_);
118 registry_.AddInterface<service_manager::mojom::Resolver>(catalog_);
119 }
116 ~ServiceImpl() override {} 120 ~ServiceImpl() override {}
117 121
118 // service_manager::Service: 122 // service_manager::Service:
119 bool OnConnect(const service_manager::ServiceInfo& remote_info, 123 void OnBindInterface(const service_manager::ServiceInfo& source_info,
120 service_manager::InterfaceRegistry* registry) override { 124 const std::string& interface_name,
121 registry->AddInterface<mojom::Catalog>(catalog_); 125 mojo::ScopedMessagePipeHandle interface_pipe) override {
122 registry->AddInterface<filesystem::mojom::Directory>(catalog_); 126 registry_.BindInterface(source_info.identity, interface_name,
123 registry->AddInterface<service_manager::mojom::Resolver>(catalog_); 127 std::move(interface_pipe));
124 return true;
125 } 128 }
126 129
127 private: 130 private:
128 Catalog* const catalog_; 131 Catalog* const catalog_;
132 service_manager::BinderRegistry registry_;
129 133
130 DISALLOW_COPY_AND_ASSIGN(ServiceImpl); 134 DISALLOW_COPY_AND_ASSIGN(ServiceImpl);
131 }; 135 };
132 136
133 Catalog::Catalog(std::unique_ptr<base::Value> static_manifest, 137 Catalog::Catalog(std::unique_ptr<base::Value> static_manifest,
134 ManifestProvider* service_manifest_provider) 138 ManifestProvider* service_manifest_provider)
135 : service_context_(new service_manager::ServiceContext( 139 : service_context_(new service_manager::ServiceContext(
136 base::MakeUnique<ServiceImpl>(this), 140 base::MakeUnique<ServiceImpl>(this),
137 service_manager::mojom::ServiceRequest(&service_))), 141 service_manager::mojom::ServiceRequest(&service_))),
138 service_manifest_provider_(service_manifest_provider), 142 service_manifest_provider_(service_manifest_provider),
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 if (it != instances_.end()) 206 if (it != instances_.end())
203 return it->second.get(); 207 return it->second.get();
204 208
205 auto result = instances_.insert(std::make_pair( 209 auto result = instances_.insert(std::make_pair(
206 user_id, 210 user_id,
207 base::MakeUnique<Instance>(&system_cache_, service_manifest_provider_))); 211 base::MakeUnique<Instance>(&system_cache_, service_manifest_provider_)));
208 return result.first->second.get(); 212 return result.first->second.get();
209 } 213 }
210 214
211 } // namespace catalog 215 } // namespace catalog
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/tests/versioning_test_service.cc ('k') | services/data_decoder/data_decoder_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698