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