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

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

Issue 1882423004: Move shell service to toplevel shell namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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
« no previous file with comments | « services/catalog/factory.h ('k') | services/shell/background/background_shell.h » ('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 #include "services/catalog/factory.h" 5 #include "services/catalog/factory.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "services/catalog/catalog.h" 8 #include "services/catalog/catalog.h"
9 #include "services/shell/public/cpp/connection.h" 9 #include "services/shell/public/cpp/connection.h"
10 #include "services/shell/public/cpp/shell_connection.h" 10 #include "services/shell/public/cpp/shell_connection.h"
11 11
12 namespace catalog { 12 namespace catalog {
13 13
14 Factory::Factory(base::TaskRunner* file_task_runner, 14 Factory::Factory(base::TaskRunner* file_task_runner,
15 scoped_ptr<Store> store, 15 scoped_ptr<Store> store,
16 ManifestProvider* manifest_provider) 16 ManifestProvider* manifest_provider)
17 : file_task_runner_(file_task_runner), 17 : file_task_runner_(file_task_runner),
18 store_(std::move(store)), 18 store_(std::move(store)),
19 manifest_provider_(manifest_provider), 19 manifest_provider_(manifest_provider),
20 weak_factory_(this) { 20 weak_factory_(this) {
21 mojo::shell::mojom::ShellClientRequest request = GetProxy(&shell_client_); 21 shell::mojom::ShellClientRequest request = GetProxy(&shell_client_);
22 shell_connection_.reset(new mojo::ShellConnection(this, std::move(request))); 22 shell_connection_.reset(new shell::ShellConnection(this, std::move(request)));
23 } 23 }
24 24
25 Factory::~Factory() {} 25 Factory::~Factory() {}
26 26
27 mojo::shell::mojom::ShellClientPtr Factory::TakeShellClient() { 27 shell::mojom::ShellClientPtr Factory::TakeShellClient() {
28 return std::move(shell_client_); 28 return std::move(shell_client_);
29 } 29 }
30 30
31 bool Factory::AcceptConnection(mojo::Connection* connection) { 31 bool Factory::AcceptConnection(shell::Connection* connection) {
32 connection->AddInterface<mojom::Catalog>(this); 32 connection->AddInterface<mojom::Catalog>(this);
33 connection->AddInterface<mojom::Resolver>(this); 33 connection->AddInterface<mojom::Resolver>(this);
34 connection->AddInterface<mojo::shell::mojom::ShellResolver>(this); 34 connection->AddInterface<shell::mojom::ShellResolver>(this);
35 return true; 35 return true;
36 } 36 }
37 37
38 void Factory::Create(mojo::Connection* connection, 38 void Factory::Create(shell::Connection* connection,
39 mojom::ResolverRequest request) { 39 mojom::ResolverRequest request) {
40 Catalog* instance = 40 Catalog* instance =
41 GetCatalogForUserId(connection->GetRemoteIdentity().user_id()); 41 GetCatalogForUserId(connection->GetRemoteIdentity().user_id());
42 instance->BindResolver(std::move(request)); 42 instance->BindResolver(std::move(request));
43 } 43 }
44 44
45 void Factory::Create(mojo::Connection* connection, 45 void Factory::Create(shell::Connection* connection,
46 mojo::shell::mojom::ShellResolverRequest request) { 46 shell::mojom::ShellResolverRequest request) {
47 Catalog* instance = 47 Catalog* instance =
48 GetCatalogForUserId(connection->GetRemoteIdentity().user_id()); 48 GetCatalogForUserId(connection->GetRemoteIdentity().user_id());
49 instance->BindShellResolver(std::move(request)); 49 instance->BindShellResolver(std::move(request));
50 } 50 }
51 51
52 void Factory::Create(mojo::Connection* connection, 52 void Factory::Create(shell::Connection* connection,
53 mojom::CatalogRequest request) { 53 mojom::CatalogRequest request) {
54 Catalog* instance = 54 Catalog* instance =
55 GetCatalogForUserId(connection->GetRemoteIdentity().user_id()); 55 GetCatalogForUserId(connection->GetRemoteIdentity().user_id());
56 instance->BindCatalog(std::move(request)); 56 instance->BindCatalog(std::move(request));
57 } 57 }
58 58
59 Catalog* Factory::GetCatalogForUserId(const std::string& user_id) { 59 Catalog* Factory::GetCatalogForUserId(const std::string& user_id) {
60 auto it = catalogs_.find(user_id); 60 auto it = catalogs_.find(user_id);
61 if (it != catalogs_.end()) 61 if (it != catalogs_.end())
62 return it->second.get(); 62 return it->second.get();
63 63
64 // TODO(beng): There needs to be a way to load the store from different users. 64 // TODO(beng): There needs to be a way to load the store from different users.
65 Catalog* instance = new Catalog(std::move(store_), file_task_runner_, 65 Catalog* instance = new Catalog(std::move(store_), file_task_runner_,
66 &system_catalog_, manifest_provider_); 66 &system_catalog_, manifest_provider_);
67 catalogs_[user_id] = make_scoped_ptr(instance); 67 catalogs_[user_id] = make_scoped_ptr(instance);
68 return instance; 68 return instance;
69 } 69 }
70 70
71 } // namespace catalog 71 } // namespace catalog
OLDNEW
« no previous file with comments | « services/catalog/factory.h ('k') | services/shell/background/background_shell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698