| 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" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 GetManifestPath(package_dir, mojo_name), package_dir); | 126 GetManifestPath(package_dir, mojo_name), package_dir); |
| 127 if (!entry) { | 127 if (!entry) { |
| 128 entry.reset(new Entry(mojo_name)); | 128 entry.reset(new Entry(mojo_name)); |
| 129 entry->set_path(GetExecutablePath( | 129 entry->set_path(GetExecutablePath( |
| 130 package_dir.AppendASCII(kPackagesDirName), mojo_name)); | 130 package_dir.AppendASCII(kPackagesDirName), mojo_name)); |
| 131 } | 131 } |
| 132 return entry; | 132 return entry; |
| 133 } | 133 } |
| 134 | 134 |
| 135 void AddEntryToCache(EntryCache* cache, std::unique_ptr<Entry> entry) { | 135 void AddEntryToCache(EntryCache* cache, std::unique_ptr<Entry> entry) { |
| 136 std::vector<std::unique_ptr<Entry>> children = entry->TakeChildren(); | 136 for (auto* child : entry->services()) |
| 137 for (auto& child : children) | 137 AddEntryToCache(cache, base::WrapUnique(child)); |
| 138 AddEntryToCache(cache, std::move(child)); | |
| 139 (*cache)[entry->name()] = std::move(entry); | 138 (*cache)[entry->name()] = std::move(entry); |
| 140 } | 139 } |
| 141 | 140 |
| 142 void DoNothing(shell::mojom::ResolveResultPtr) {} | 141 void DoNothing(shell::mojom::ResolveResultPtr) {} |
| 143 | 142 |
| 144 } // namespace | 143 } // namespace |
| 145 | 144 |
| 146 // A sequenced task runner is used to guarantee requests are serviced in the | 145 // A sequenced task runner is used to guarantee requests are serviced in the |
| 147 // order requested. To do otherwise means we may run callbacks in an | 146 // order requested. To do otherwise means we may run callbacks in an |
| 148 // unpredictable order, leading to flake. | 147 // unpredictable order, leading to flake. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 EntryCache* cache, | 207 EntryCache* cache, |
| 209 const CreateEntryForNameCallback& entry_created_callback, | 208 const CreateEntryForNameCallback& entry_created_callback, |
| 210 std::unique_ptr<Entry> entry) { | 209 std::unique_ptr<Entry> entry) { |
| 211 shell::mojom::ResolveResultPtr result = | 210 shell::mojom::ResolveResultPtr result = |
| 212 shell::mojom::ResolveResult::From(*entry); | 211 shell::mojom::ResolveResult::From(*entry); |
| 213 AddEntryToCache(cache, std::move(entry)); | 212 AddEntryToCache(cache, std::move(entry)); |
| 214 entry_created_callback.Run(std::move(result)); | 213 entry_created_callback.Run(std::move(result)); |
| 215 } | 214 } |
| 216 | 215 |
| 217 } // namespace catalog | 216 } // namespace catalog |
| OLD | NEW |