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 #include "mojo/services/catalog/factory.h" | 5 #include "mojo/services/catalog/factory.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "mojo/services/catalog/catalog.h" | 8 #include "mojo/services/catalog/catalog.h" |
9 #include "mojo/shell/public/cpp/connection.h" | 9 #include "mojo/shell/public/cpp/connection.h" |
10 #include "mojo/shell/public/cpp/shell_connection.h" | 10 #include "mojo/shell/public/cpp/shell_connection.h" |
11 | 11 |
12 namespace catalog { | 12 namespace catalog { |
13 | 13 |
14 Factory::Factory(base::TaskRunner* file_task_runner, scoped_ptr<Store> store) | 14 Factory::Factory(base::TaskRunner* file_task_runner, |
| 15 scoped_ptr<Store> store, |
| 16 ManifestProvider* manifest_provider) |
15 : file_task_runner_(file_task_runner), | 17 : file_task_runner_(file_task_runner), |
16 store_(std::move(store)), | 18 store_(std::move(store)), |
| 19 manifest_provider_(manifest_provider), |
17 weak_factory_(this) { | 20 weak_factory_(this) { |
18 mojo::shell::mojom::ShellClientRequest request = GetProxy(&shell_client_); | 21 mojo::shell::mojom::ShellClientRequest request = GetProxy(&shell_client_); |
19 shell_connection_.reset(new mojo::ShellConnection(this, std::move(request))); | 22 shell_connection_.reset(new mojo::ShellConnection(this, std::move(request))); |
20 } | 23 } |
| 24 |
21 Factory::~Factory() {} | 25 Factory::~Factory() {} |
22 | 26 |
23 mojo::shell::mojom::ShellClientPtr Factory::TakeShellClient() { | 27 mojo::shell::mojom::ShellClientPtr Factory::TakeShellClient() { |
24 return std::move(shell_client_); | 28 return std::move(shell_client_); |
25 } | 29 } |
26 | 30 |
27 bool Factory::AcceptConnection(mojo::Connection* connection) { | 31 bool Factory::AcceptConnection(mojo::Connection* connection) { |
28 connection->AddInterface<mojom::Catalog>(this); | 32 connection->AddInterface<mojom::Catalog>(this); |
29 connection->AddInterface<mojom::Resolver>(this); | 33 connection->AddInterface<mojom::Resolver>(this); |
30 connection->AddInterface<mojo::shell::mojom::ShellResolver>(this); | 34 connection->AddInterface<mojo::shell::mojom::ShellResolver>(this); |
(...skipping 20 matching lines...) Expand all Loading... |
51 GetCatalogForUserId(connection->GetRemoteIdentity().user_id()); | 55 GetCatalogForUserId(connection->GetRemoteIdentity().user_id()); |
52 instance->BindCatalog(std::move(request)); | 56 instance->BindCatalog(std::move(request)); |
53 } | 57 } |
54 | 58 |
55 Catalog* Factory::GetCatalogForUserId(const std::string& user_id) { | 59 Catalog* Factory::GetCatalogForUserId(const std::string& user_id) { |
56 auto it = catalogs_.find(user_id); | 60 auto it = catalogs_.find(user_id); |
57 if (it != catalogs_.end()) | 61 if (it != catalogs_.end()) |
58 return it->second.get(); | 62 return it->second.get(); |
59 | 63 |
60 // 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. |
61 Catalog* instance = | 65 Catalog* instance = new Catalog(std::move(store_), file_task_runner_, |
62 new Catalog(std::move(store_), file_task_runner_, &system_catalog_); | 66 &system_catalog_, manifest_provider_); |
63 catalogs_[user_id] = make_scoped_ptr(instance); | 67 catalogs_[user_id] = make_scoped_ptr(instance); |
64 return instance; | 68 return instance; |
65 } | 69 } |
66 | 70 |
67 } // namespace catalog | 71 } // namespace catalog |
OLD | NEW |