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/reader.h" | 5 #include "services/catalog/reader.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_enumerator.h" | 8 #include "base/files/file_enumerator.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/json/json_file_value_serializer.h" | 10 #include "base/json/json_file_value_serializer.h" |
11 #include "base/json/json_reader.h" | 11 #include "base/json/json_reader.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
14 #include "base/task_runner_util.h" | 14 #include "base/task_runner_util.h" |
15 #include "base/threading/thread_task_runner_handle.h" | 15 #include "base/threading/thread_task_runner_handle.h" |
16 #include "services/catalog/constants.h" | 16 #include "services/catalog/constants.h" |
17 #include "services/catalog/entry.h" | 17 #include "services/catalog/entry.h" |
18 #include "services/catalog/manifest_provider.h" | 18 #include "services/catalog/manifest_provider.h" |
19 #include "services/catalog/public/interfaces/constants.mojom.h" | 19 #include "services/catalog/public/interfaces/constants.mojom.h" |
20 #include "services/service_manager/public/interfaces/constants.mojom.h" | 20 #include "services/service_manager/public/interfaces/constants.mojom.h" |
21 | 21 |
22 namespace catalog { | 22 namespace catalog { |
23 namespace { | 23 namespace { |
24 | 24 |
| 25 #if defined(OS_WIN) |
| 26 const char kServiceExecutableExtension[] = ".service.exe"; |
| 27 #else |
| 28 const char kServiceExecutableExtension[] = ".service"; |
| 29 #endif |
| 30 |
25 base::FilePath GetManifestPath(const base::FilePath& package_dir, | 31 base::FilePath GetManifestPath(const base::FilePath& package_dir, |
26 const std::string& name, | 32 const std::string& name, |
27 const std::string& package_name_override) { | 33 const std::string& package_name_override) { |
28 // TODO(beng): think more about how this should be done for exe targets. | 34 // TODO(beng): think more about how this should be done for exe targets. |
29 std::string package_name = | 35 std::string package_name = |
30 package_name_override.empty() ? name : package_name_override; | 36 package_name_override.empty() ? name : package_name_override; |
31 return package_dir.AppendASCII(kPackagesDirName).AppendASCII( | 37 return package_dir.AppendASCII(kPackagesDirName).AppendASCII( |
32 package_name + "/manifest.json"); | 38 package_name + "/manifest.json"); |
33 } | 39 } |
34 | 40 |
35 base::FilePath GetExecutablePath(const base::FilePath& package_dir, | 41 base::FilePath GetExecutablePath(const base::FilePath& package_dir, |
36 const std::string& name) { | 42 const std::string& name) { |
37 return package_dir.AppendASCII(name + "/" + name + ".service"); | 43 return package_dir.AppendASCII( |
| 44 name + "/" + name + kServiceExecutableExtension); |
38 } | 45 } |
39 | 46 |
40 std::unique_ptr<Entry> ProcessManifest( | 47 std::unique_ptr<Entry> ProcessManifest( |
41 std::unique_ptr<base::Value> manifest_root, | 48 std::unique_ptr<base::Value> manifest_root, |
42 const base::FilePath& package_dir) { | 49 const base::FilePath& package_dir) { |
43 // Manifest was malformed or did not exist. | 50 // Manifest was malformed or did not exist. |
44 if (!manifest_root) | 51 if (!manifest_root) |
45 return nullptr; | 52 return nullptr; |
46 | 53 |
47 const base::DictionaryValue* dictionary = nullptr; | 54 const base::DictionaryValue* dictionary = nullptr; |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 std::unique_ptr<Entry> entry) { | 235 std::unique_ptr<Entry> entry) { |
229 if (!entry) | 236 if (!entry) |
230 return; | 237 return; |
231 service_manager::mojom::ResolveResultPtr result = | 238 service_manager::mojom::ResolveResultPtr result = |
232 service_manager::mojom::ResolveResult::From(*entry); | 239 service_manager::mojom::ResolveResult::From(*entry); |
233 AddEntryToCache(cache, std::move(entry)); | 240 AddEntryToCache(cache, std::move(entry)); |
234 entry_created_callback.Run(std::move(result)); | 241 entry_created_callback.Run(std::move(result)); |
235 } | 242 } |
236 | 243 |
237 } // namespace catalog | 244 } // namespace catalog |
OLD | NEW |