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" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "components/filesystem/directory_impl.h" | 14 #include "components/filesystem/directory_impl.h" |
15 #include "components/filesystem/lock_table.h" | 15 #include "components/filesystem/lock_table.h" |
16 #include "components/filesystem/public/interfaces/types.mojom.h" | 16 #include "components/filesystem/public/interfaces/types.mojom.h" |
| 17 #include "mojo/public/cpp/bindings/strong_binding.h" |
17 #include "services/catalog/constants.h" | 18 #include "services/catalog/constants.h" |
18 #include "services/catalog/instance.h" | 19 #include "services/catalog/instance.h" |
19 #include "services/catalog/reader.h" | 20 #include "services/catalog/reader.h" |
20 #include "services/shell/public/cpp/connection.h" | 21 #include "services/shell/public/cpp/connection.h" |
21 #include "services/shell/public/cpp/service_context.h" | 22 #include "services/shell/public/cpp/service_context.h" |
22 | 23 |
23 namespace catalog { | 24 namespace catalog { |
24 namespace { | 25 namespace { |
25 | 26 |
26 bool IsPathNameValid(const std::string& name) { | 27 bool IsPathNameValid(const std::string& name) { |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 Instance* instance = GetInstanceForUserId(remote_identity.user_id()); | 124 Instance* instance = GetInstanceForUserId(remote_identity.user_id()); |
124 instance->BindCatalog(std::move(request)); | 125 instance->BindCatalog(std::move(request)); |
125 } | 126 } |
126 | 127 |
127 void Catalog::Create(const shell::Identity& remote_identity, | 128 void Catalog::Create(const shell::Identity& remote_identity, |
128 filesystem::mojom::DirectoryRequest request) { | 129 filesystem::mojom::DirectoryRequest request) { |
129 if (!lock_table_) | 130 if (!lock_table_) |
130 lock_table_ = new filesystem::LockTable; | 131 lock_table_ = new filesystem::LockTable; |
131 base::FilePath resources_path = | 132 base::FilePath resources_path = |
132 GetPathForApplicationName(remote_identity.name()); | 133 GetPathForApplicationName(remote_identity.name()); |
133 new filesystem::DirectoryImpl(std::move(request), resources_path, | 134 mojo::MakeStrongBinding( |
134 scoped_refptr<filesystem::SharedTempDir>(), | 135 base::MakeUnique<filesystem::DirectoryImpl>( |
135 lock_table_); | 136 resources_path, scoped_refptr<filesystem::SharedTempDir>(), |
| 137 lock_table_), |
| 138 std::move(request)); |
136 } | 139 } |
137 | 140 |
138 Instance* Catalog::GetInstanceForUserId(const std::string& user_id) { | 141 Instance* Catalog::GetInstanceForUserId(const std::string& user_id) { |
139 auto it = instances_.find(user_id); | 142 auto it = instances_.find(user_id); |
140 if (it != instances_.end()) | 143 if (it != instances_.end()) |
141 return it->second.get(); | 144 return it->second.get(); |
142 | 145 |
143 // TODO(beng): There needs to be a way to load the store from different users. | 146 // TODO(beng): There needs to be a way to load the store from different users. |
144 Instance* instance = new Instance(std::move(store_), system_reader_.get()); | 147 Instance* instance = new Instance(std::move(store_), system_reader_.get()); |
145 instances_[user_id] = base::WrapUnique(instance); | 148 instances_[user_id] = base::WrapUnique(instance); |
146 if (loaded_) | 149 if (loaded_) |
147 instance->CacheReady(&system_cache_); | 150 instance->CacheReady(&system_cache_); |
148 | 151 |
149 return instance; | 152 return instance; |
150 } | 153 } |
151 | 154 |
152 void Catalog::SystemPackageDirScanned() { | 155 void Catalog::SystemPackageDirScanned() { |
153 loaded_ = true; | 156 loaded_ = true; |
154 for (auto& instance : instances_) | 157 for (auto& instance : instances_) |
155 instance.second->CacheReady(&system_cache_); | 158 instance.second->CacheReady(&system_cache_); |
156 } | 159 } |
157 | 160 |
158 } // namespace catalog | 161 } // namespace catalog |
OLD | NEW |