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/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 PathService::Get(base::DIR_MODULE, &system_package_dir); | 104 PathService::Get(base::DIR_MODULE, &system_package_dir); |
105 system_package_dir = system_package_dir.AppendASCII(kPackagesDirName); | 105 system_package_dir = system_package_dir.AppendASCII(kPackagesDirName); |
106 system_reader_->Read(system_package_dir, &system_cache_, | 106 system_reader_->Read(system_package_dir, &system_cache_, |
107 base::Bind(&Catalog::SystemPackageDirScanned, | 107 base::Bind(&Catalog::SystemPackageDirScanned, |
108 weak_factory_.GetWeakPtr())); | 108 weak_factory_.GetWeakPtr())); |
109 } | 109 } |
110 | 110 |
111 bool Catalog::OnConnect(const shell::Identity& remote_identity, | 111 bool Catalog::OnConnect(const shell::Identity& remote_identity, |
112 shell::InterfaceRegistry* registry) { | 112 shell::InterfaceRegistry* registry) { |
113 registry->AddInterface<mojom::Catalog>(this); | 113 registry->AddInterface<mojom::Catalog>(this); |
| 114 registry->AddInterface<mojom::CatalogControl>(this); |
114 registry->AddInterface<filesystem::mojom::Directory>(this); | 115 registry->AddInterface<filesystem::mojom::Directory>(this); |
115 registry->AddInterface<shell::mojom::Resolver>(this); | 116 registry->AddInterface<shell::mojom::Resolver>(this); |
116 return true; | 117 return true; |
117 } | 118 } |
118 | 119 |
119 void Catalog::Create(const shell::Identity& remote_identity, | 120 void Catalog::Create(const shell::Identity& remote_identity, |
120 shell::mojom::ResolverRequest request) { | 121 shell::mojom::ResolverRequest request) { |
121 Instance* instance = GetInstanceForUserId(remote_identity.user_id()); | 122 Instance* instance = GetInstanceForUserId(remote_identity.user_id()); |
122 instance->BindResolver(std::move(request)); | 123 instance->BindResolver(std::move(request)); |
123 } | 124 } |
(...skipping 10 matching lines...) Expand all Loading... |
134 lock_table_ = new filesystem::LockTable; | 135 lock_table_ = new filesystem::LockTable; |
135 base::FilePath resources_path = | 136 base::FilePath resources_path = |
136 GetPathForApplicationName(remote_identity.name()); | 137 GetPathForApplicationName(remote_identity.name()); |
137 mojo::MakeStrongBinding( | 138 mojo::MakeStrongBinding( |
138 base::MakeUnique<filesystem::DirectoryImpl>( | 139 base::MakeUnique<filesystem::DirectoryImpl>( |
139 resources_path, scoped_refptr<filesystem::SharedTempDir>(), | 140 resources_path, scoped_refptr<filesystem::SharedTempDir>(), |
140 lock_table_), | 141 lock_table_), |
141 std::move(request)); | 142 std::move(request)); |
142 } | 143 } |
143 | 144 |
| 145 void Catalog::Create(const shell::Identity& remote_identity, |
| 146 mojom::CatalogControlRequest request) { |
| 147 control_bindings_.AddBinding(this, std::move(request)); |
| 148 } |
| 149 |
| 150 void Catalog::OverrideManifestPath( |
| 151 const std::string& service_name, |
| 152 const base::FilePath& path, |
| 153 const OverrideManifestPathCallback& callback) { |
| 154 system_reader_->OverrideManifestPath(service_name, path); |
| 155 callback.Run(); |
| 156 } |
| 157 |
144 Instance* Catalog::GetInstanceForUserId(const std::string& user_id) { | 158 Instance* Catalog::GetInstanceForUserId(const std::string& user_id) { |
145 auto it = instances_.find(user_id); | 159 auto it = instances_.find(user_id); |
146 if (it != instances_.end()) | 160 if (it != instances_.end()) |
147 return it->second.get(); | 161 return it->second.get(); |
148 | 162 |
149 // TODO(beng): There needs to be a way to load the store from different users. | 163 // TODO(beng): There needs to be a way to load the store from different users. |
150 Instance* instance = new Instance(std::move(store_), system_reader_.get()); | 164 Instance* instance = new Instance(std::move(store_), system_reader_.get()); |
151 instances_[user_id] = base::WrapUnique(instance); | 165 instances_[user_id] = base::WrapUnique(instance); |
152 if (loaded_) | 166 if (loaded_) |
153 instance->CacheReady(&system_cache_); | 167 instance->CacheReady(&system_cache_); |
154 | 168 |
155 return instance; | 169 return instance; |
156 } | 170 } |
157 | 171 |
158 void Catalog::SystemPackageDirScanned() { | 172 void Catalog::SystemPackageDirScanned() { |
159 loaded_ = true; | 173 loaded_ = true; |
160 for (auto& instance : instances_) | 174 for (auto& instance : instances_) |
161 instance.second->CacheReady(&system_cache_); | 175 instance.second->CacheReady(&system_cache_); |
162 } | 176 } |
163 | 177 |
164 } // namespace catalog | 178 } // namespace catalog |
OLD | NEW |