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 "services/catalog/constants.h" | 17 #include "services/catalog/constants.h" |
18 #include "services/catalog/instance.h" | 18 #include "services/catalog/instance.h" |
19 #include "services/catalog/reader.h" | 19 #include "services/catalog/reader.h" |
20 #include "services/shell/public/cpp/connection.h" | 20 #include "services/shell/public/cpp/connection.h" |
21 #include "services/shell/public/cpp/shell_connection.h" | 21 #include "services/shell/public/cpp/service_context.h" |
22 | 22 |
23 namespace catalog { | 23 namespace catalog { |
24 namespace { | 24 namespace { |
25 | 25 |
26 bool IsPathNameValid(const std::string& name) { | 26 bool IsPathNameValid(const std::string& name) { |
27 if (name.empty() || name == "." || name == "..") | 27 if (name.empty() || name == "." || name == "..") |
28 return false; | 28 return false; |
29 | 29 |
30 for (auto c : name) { | 30 for (auto c : name) { |
31 if (!base::IsAsciiAlpha(c) && !base::IsAsciiDigit(c) && | 31 if (!base::IsAsciiAlpha(c) && !base::IsAsciiDigit(c) && |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 85 |
86 Catalog::~Catalog() {} | 86 Catalog::~Catalog() {} |
87 | 87 |
88 shell::mojom::ServicePtr Catalog::TakeService() { | 88 shell::mojom::ServicePtr Catalog::TakeService() { |
89 return std::move(service_); | 89 return std::move(service_); |
90 } | 90 } |
91 | 91 |
92 Catalog::Catalog(std::unique_ptr<Store> store) | 92 Catalog::Catalog(std::unique_ptr<Store> store) |
93 : store_(std::move(store)), weak_factory_(this) { | 93 : store_(std::move(store)), weak_factory_(this) { |
94 shell::mojom::ServiceRequest request = GetProxy(&service_); | 94 shell::mojom::ServiceRequest request = GetProxy(&service_); |
95 shell_connection_.reset(new shell::ShellConnection(this, std::move(request))); | 95 shell_connection_.reset(new shell::ServiceContext(this, std::move(request))); |
96 } | 96 } |
97 | 97 |
98 void Catalog::ScanSystemPackageDir() { | 98 void Catalog::ScanSystemPackageDir() { |
99 base::FilePath system_package_dir; | 99 base::FilePath system_package_dir; |
100 PathService::Get(base::DIR_MODULE, &system_package_dir); | 100 PathService::Get(base::DIR_MODULE, &system_package_dir); |
101 system_package_dir = system_package_dir.AppendASCII(kMojoApplicationsDirName); | 101 system_package_dir = system_package_dir.AppendASCII(kMojoApplicationsDirName); |
102 system_reader_->Read(system_package_dir, &system_cache_, | 102 system_reader_->Read(system_package_dir, &system_cache_, |
103 base::Bind(&Catalog::SystemPackageDirScanned, | 103 base::Bind(&Catalog::SystemPackageDirScanned, |
104 weak_factory_.GetWeakPtr())); | 104 weak_factory_.GetWeakPtr())); |
105 } | 105 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 return instance; | 150 return instance; |
151 } | 151 } |
152 | 152 |
153 void Catalog::SystemPackageDirScanned() { | 153 void Catalog::SystemPackageDirScanned() { |
154 loaded_ = true; | 154 loaded_ = true; |
155 for (auto& instance : instances_) | 155 for (auto& instance : instances_) |
156 instance.second->CacheReady(&system_cache_); | 156 instance.second->CacheReady(&system_cache_); |
157 } | 157 } |
158 | 158 |
159 } // namespace catalog | 159 } // namespace catalog |
OLD | NEW |