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 Catalog::Delegate* delegate) |
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 delegate_(delegate), |
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 } |
21 Factory::~Factory() {} | 24 Factory::~Factory() {} |
22 | 25 |
23 mojo::shell::mojom::ShellClientPtr Factory::TakeShellClient() { | 26 mojo::shell::mojom::ShellClientPtr Factory::TakeShellClient() { |
24 return std::move(shell_client_); | 27 return std::move(shell_client_); |
25 } | 28 } |
26 | 29 |
(...skipping 24 matching lines...) Expand all Loading... |
51 GetCatalogForUserId(connection->GetRemoteIdentity().user_id()); | 54 GetCatalogForUserId(connection->GetRemoteIdentity().user_id()); |
52 instance->BindCatalog(std::move(request)); | 55 instance->BindCatalog(std::move(request)); |
53 } | 56 } |
54 | 57 |
55 Catalog* Factory::GetCatalogForUserId(const std::string& user_id) { | 58 Catalog* Factory::GetCatalogForUserId(const std::string& user_id) { |
56 auto it = catalogs_.find(user_id); | 59 auto it = catalogs_.find(user_id); |
57 if (it != catalogs_.end()) | 60 if (it != catalogs_.end()) |
58 return it->second.get(); | 61 return it->second.get(); |
59 | 62 |
60 // TODO(beng): There needs to be a way to load the store from different users. | 63 // TODO(beng): There needs to be a way to load the store from different users. |
61 Catalog* instance = new Catalog(file_task_runner_, std::move(store_)); | 64 Catalog* instance = |
| 65 new Catalog(file_task_runner_, std::move(store_), delegate_); |
62 catalogs_[user_id] = make_scoped_ptr(instance); | 66 catalogs_[user_id] = make_scoped_ptr(instance); |
63 return instance; | 67 return instance; |
64 } | 68 } |
65 | 69 |
66 } // namespace catalog | 70 } // namespace catalog |
OLD | NEW |