Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: services/catalog/reader.cc

Issue 2390013002: Rename mojo: to service: (Closed)
Patch Set: . Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « services/catalog/manifest.json ('k') | services/file/manifest.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/shell/public/cpp/names.h" 19 #include "services/shell/public/cpp/names.h"
20 20
21 namespace catalog { 21 namespace catalog {
22 namespace { 22 namespace {
23 23
24 base::FilePath GetManifestPath(const base::FilePath& package_dir, 24 base::FilePath GetManifestPath(const base::FilePath& package_dir,
25 const std::string& name) { 25 const std::string& name) {
26 // TODO(beng): think more about how this should be done for exe targets. 26 // TODO(beng): think more about how this should be done for exe targets.
27 std::string type = shell::GetNameType(name); 27 std::string type = shell::GetNameType(name);
28 std::string path = shell::GetNamePath(name); 28 std::string path = shell::GetNamePath(name);
29 if (type == shell::kNameType_Mojo) { 29 if (type == shell::kNameType_Service) {
30 return package_dir.AppendASCII(kPackagesDirName).AppendASCII( 30 return package_dir.AppendASCII(kPackagesDirName).AppendASCII(
31 path + "/manifest.json"); 31 path + "/manifest.json");
32 } 32 }
33 if (type == shell::kNameType_Exe) 33 if (type == shell::kNameType_Exe)
34 return package_dir.AppendASCII(path + "_manifest.json"); 34 return package_dir.AppendASCII(path + "_manifest.json");
35 return base::FilePath(); 35 return base::FilePath();
36 } 36 }
37 37
38 38
39 base::FilePath GetExecutablePath(const base::FilePath& package_dir, 39 base::FilePath GetExecutablePath(const base::FilePath& package_dir,
40 const std::string& name) { 40 const std::string& name) {
41 std::string type = shell::GetNameType(name); 41 std::string type = shell::GetNameType(name);
42 if (type == shell::kNameType_Mojo) { 42 if (type == shell::kNameType_Service) {
43 // It's still a mojo: URL, use the default mapping scheme. 43 // It's still a mojo: URL, use the default mapping scheme.
44 const std::string host = shell::GetNamePath(name); 44 const std::string host = shell::GetNamePath(name);
45 return package_dir.AppendASCII(host + "/" + host + ".library"); 45 return package_dir.AppendASCII(host + "/" + host + ".library");
46 } 46 }
47 if (type == shell::kNameType_Exe) { 47 if (type == shell::kNameType_Exe) {
48 #if defined OS_WIN 48 #if defined OS_WIN
49 std::string extension = ".exe"; 49 std::string extension = ".exe";
50 #else 50 #else
51 std::string extension; 51 std::string extension;
52 #endif 52 #endif
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 base::FilePath manifest_path = path.AppendASCII("manifest.json"); 100 base::FilePath manifest_path = path.AppendASCII("manifest.json");
101 std::unique_ptr<Entry> entry = 101 std::unique_ptr<Entry> entry =
102 CreateEntryForManifestAt(manifest_path, package_dir); 102 CreateEntryForManifestAt(manifest_path, package_dir);
103 if (!entry) 103 if (!entry)
104 continue; 104 continue;
105 105
106 // Skip over subdirs that contain only manifests, they're artifacts of the 106 // Skip over subdirs that contain only manifests, they're artifacts of the
107 // build (e.g. for applications that are packaged into others) and are not 107 // build (e.g. for applications that are packaged into others) and are not
108 // valid standalone packages. 108 // valid standalone packages.
109 base::FilePath package_path = GetExecutablePath(package_dir, entry->name()); 109 base::FilePath package_path = GetExecutablePath(package_dir, entry->name());
110 if (entry->name() != "mojo:shell" && entry->name() != "mojo:catalog" && 110 if (entry->name() != "service:shell" &&
111 entry->name() != "service:catalog" &&
111 !base::PathExists(package_path)) { 112 !base::PathExists(package_path)) {
112 continue; 113 continue;
113 } 114 }
114 115
115 original_thread_task_runner->PostTask( 116 original_thread_task_runner->PostTask(
116 FROM_HERE, 117 FROM_HERE,
117 base::Bind(read_manifest_callback, base::Passed(&entry))); 118 base::Bind(read_manifest_callback, base::Passed(&entry)));
118 } 119 }
119 120
120 original_thread_task_runner->PostTask(FROM_HERE, read_complete_closure); 121 original_thread_task_runner->PostTask(FROM_HERE, read_complete_closure);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 std::unique_ptr<Entry> entry) { 210 std::unique_ptr<Entry> entry) {
210 if (!entry) 211 if (!entry)
211 return; 212 return;
212 shell::mojom::ResolveResultPtr result = 213 shell::mojom::ResolveResultPtr result =
213 shell::mojom::ResolveResult::From(*entry); 214 shell::mojom::ResolveResult::From(*entry);
214 AddEntryToCache(cache, std::move(entry)); 215 AddEntryToCache(cache, std::move(entry));
215 entry_created_callback.Run(std::move(result)); 216 entry_created_callback.Run(std::move(result));
216 } 217 }
217 218
218 } // namespace catalog 219 } // namespace catalog
OLDNEW
« no previous file with comments | « services/catalog/manifest.json ('k') | services/file/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698