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

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

Issue 2346593002: Revert of Enforce capability spec renderer <--> browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 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_provider.h ('k') | no next file » | 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"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 base::Bind(&Reader::OnReadManifest, weak_factory_.GetWeakPtr(), 171 base::Bind(&Reader::OnReadManifest, weak_factory_.GetWeakPtr(),
172 cache, base::Bind(&DoNothing)), 172 cache, base::Bind(&DoNothing)),
173 base::ThreadTaskRunnerHandle::Get(), 173 base::ThreadTaskRunnerHandle::Get(),
174 read_complete_closure)); 174 read_complete_closure));
175 } 175 }
176 176
177 void Reader::CreateEntryForName( 177 void Reader::CreateEntryForName(
178 const std::string& mojo_name, 178 const std::string& mojo_name,
179 EntryCache* cache, 179 EntryCache* cache,
180 const CreateEntryForNameCallback& entry_created_callback) { 180 const CreateEntryForNameCallback& entry_created_callback) {
181 if (manifest_provider_) { 181 std::string manifest_contents;
182 if (manifest_provider_ &&
183 manifest_provider_->GetApplicationManifest(mojo_name,
184 &manifest_contents)) {
182 std::unique_ptr<base::Value> manifest_root = 185 std::unique_ptr<base::Value> manifest_root =
183 manifest_provider_->GetManifest(mojo_name); 186 base::JSONReader::Read(manifest_contents);
184 if (manifest_root) { 187 base::PostTaskAndReplyWithResult(
185 base::PostTaskAndReplyWithResult( 188 file_task_runner_.get(), FROM_HERE,
186 file_task_runner_.get(), FROM_HERE, 189 base::Bind(&ProcessManifest, base::Passed(&manifest_root),
187 base::Bind(&ProcessManifest, base::Passed(&manifest_root), 190 system_package_dir_),
188 system_package_dir_), 191 base::Bind(&Reader::OnReadManifest, weak_factory_.GetWeakPtr(), cache,
189 base::Bind(&Reader::OnReadManifest, weak_factory_.GetWeakPtr(), cache, 192 entry_created_callback));
190 entry_created_callback)); 193 } else {
191 return; 194 base::PostTaskAndReplyWithResult(
192 } 195 file_task_runner_.get(), FROM_HERE,
196 base::Bind(&ReadManifest, system_package_dir_, mojo_name),
197 base::Bind(&Reader::OnReadManifest, weak_factory_.GetWeakPtr(), cache,
198 entry_created_callback));
193 } 199 }
194 base::PostTaskAndReplyWithResult(
195 file_task_runner_.get(), FROM_HERE,
196 base::Bind(&ReadManifest, system_package_dir_, mojo_name),
197 base::Bind(&Reader::OnReadManifest, weak_factory_.GetWeakPtr(), cache,
198 entry_created_callback));
199 } 200 }
200 201
201 Reader::Reader(ManifestProvider* manifest_provider) 202 Reader::Reader(ManifestProvider* manifest_provider)
202 : manifest_provider_(manifest_provider), weak_factory_(this) { 203 : manifest_provider_(manifest_provider), weak_factory_(this) {
203 PathService::Get(base::DIR_MODULE, &system_package_dir_); 204 PathService::Get(base::DIR_MODULE, &system_package_dir_);
204 } 205 }
205 206
206 void Reader::OnReadManifest( 207 void Reader::OnReadManifest(
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 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_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698