| 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 "services/catalog/catalog.h" | 5 #include "services/catalog/catalog.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/ptr_util.h" |
| 8 #include "services/catalog/constants.h" | 9 #include "services/catalog/constants.h" |
| 9 #include "services/catalog/instance.h" | 10 #include "services/catalog/instance.h" |
| 10 #include "services/catalog/reader.h" | 11 #include "services/catalog/reader.h" |
| 11 #include "services/shell/public/cpp/connection.h" | 12 #include "services/shell/public/cpp/connection.h" |
| 12 #include "services/shell/public/cpp/shell_connection.h" | 13 #include "services/shell/public/cpp/shell_connection.h" |
| 13 | 14 |
| 14 namespace catalog { | 15 namespace catalog { |
| 15 | 16 |
| 16 Catalog::Catalog(base::TaskRunner* file_task_runner, | 17 Catalog::Catalog(base::TaskRunner* file_task_runner, |
| 17 scoped_ptr<Store> store, | 18 std::unique_ptr<Store> store, |
| 18 ManifestProvider* manifest_provider) | 19 ManifestProvider* manifest_provider) |
| 19 : file_task_runner_(file_task_runner), | 20 : file_task_runner_(file_task_runner), |
| 20 store_(std::move(store)), | 21 store_(std::move(store)), |
| 21 weak_factory_(this) { | 22 weak_factory_(this) { |
| 22 shell::mojom::ShellClientRequest request = GetProxy(&shell_client_); | 23 shell::mojom::ShellClientRequest request = GetProxy(&shell_client_); |
| 23 shell_connection_.reset(new shell::ShellConnection(this, std::move(request))); | 24 shell_connection_.reset(new shell::ShellConnection(this, std::move(request))); |
| 24 | 25 |
| 25 base::FilePath system_package_dir; | 26 base::FilePath system_package_dir; |
| 26 PathService::Get(base::DIR_MODULE, &system_package_dir); | 27 PathService::Get(base::DIR_MODULE, &system_package_dir); |
| 27 system_package_dir = system_package_dir.AppendASCII(kMojoApplicationsDirName); | 28 system_package_dir = system_package_dir.AppendASCII(kMojoApplicationsDirName); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 57 instance->BindCatalog(std::move(request)); | 58 instance->BindCatalog(std::move(request)); |
| 58 } | 59 } |
| 59 | 60 |
| 60 Instance* Catalog::GetInstanceForUserId(const std::string& user_id) { | 61 Instance* Catalog::GetInstanceForUserId(const std::string& user_id) { |
| 61 auto it = instances_.find(user_id); | 62 auto it = instances_.find(user_id); |
| 62 if (it != instances_.end()) | 63 if (it != instances_.end()) |
| 63 return it->second.get(); | 64 return it->second.get(); |
| 64 | 65 |
| 65 // TODO(beng): There needs to be a way to load the store from different users. | 66 // TODO(beng): There needs to be a way to load the store from different users. |
| 66 Instance* instance = new Instance(std::move(store_), system_reader_.get()); | 67 Instance* instance = new Instance(std::move(store_), system_reader_.get()); |
| 67 instances_[user_id] = make_scoped_ptr(instance); | 68 instances_[user_id] = base::WrapUnique(instance); |
| 68 if (loaded_) | 69 if (loaded_) |
| 69 instance->CacheReady(&system_cache_); | 70 instance->CacheReady(&system_cache_); |
| 70 | 71 |
| 71 return instance; | 72 return instance; |
| 72 } | 73 } |
| 73 | 74 |
| 74 void Catalog::SystemPackageDirScanned() { | 75 void Catalog::SystemPackageDirScanned() { |
| 75 loaded_ = true; | 76 loaded_ = true; |
| 76 for (auto& instance : instances_) | 77 for (auto& instance : instances_) |
| 77 instance.second->CacheReady(&system_cache_); | 78 instance.second->CacheReady(&system_cache_); |
| 78 } | 79 } |
| 79 | 80 |
| 80 } // namespace catalog | 81 } // namespace catalog |
| OLD | NEW |