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

Side by Side Diff: extensions/browser/content_verifier.cc

Issue 2824333003: Bind ContentVerifer::VerifyFailed as OnceCallback. (Closed)
Patch Set: Only ContentVerifyJob::FailureCallback Created 3 years, 8 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 | « extensions/browser/content_verifier.h ('k') | extensions/browser/content_verify_job.h » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/content_verifier.h" 5 #include "extensions/browser/content_verifier.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 std::set<base::FilePath> paths; 118 std::set<base::FilePath> paths;
119 paths.insert(normalized_path); 119 paths.insert(normalized_path);
120 if (!ShouldVerifyAnyPaths(extension_id, extension_root, paths)) 120 if (!ShouldVerifyAnyPaths(extension_id, extension_root, paths))
121 return NULL; 121 return NULL;
122 122
123 // TODO(asargent) - we can probably get some good performance wins by having 123 // TODO(asargent) - we can probably get some good performance wins by having
124 // a cache of ContentHashReader's that we hold onto past the end of each job. 124 // a cache of ContentHashReader's that we hold onto past the end of each job.
125 return new ContentVerifyJob( 125 return new ContentVerifyJob(
126 new ContentHashReader(extension_id, data->version, extension_root, 126 new ContentHashReader(extension_id, data->version, extension_root,
127 normalized_path, delegate_->GetPublicKey()), 127 normalized_path, delegate_->GetPublicKey()),
128 base::Bind(&ContentVerifier::VerifyFailed, this, extension_id)); 128 base::BindOnce(&ContentVerifier::VerifyFailed, this, extension_id));
129 } 129 }
130 130
131 void ContentVerifier::VerifyFailed(const std::string& extension_id, 131 void ContentVerifier::VerifyFailed(const std::string& extension_id,
132 ContentVerifyJob::FailureReason reason) { 132 ContentVerifyJob::FailureReason reason) {
133 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { 133 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) {
134 content::BrowserThread::PostTask( 134 content::BrowserThread::PostTask(
135 content::BrowserThread::UI, 135 content::BrowserThread::UI,
136 FROM_HERE, 136 FROM_HERE,
137 base::Bind(&ContentVerifier::VerifyFailed, this, extension_id, reason)); 137 base::Bind(&ContentVerifier::VerifyFailed, this, extension_id, reason));
138 return; 138 return;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 return; 200 return;
201 content::BrowserThread::PostTask( 201 content::BrowserThread::PostTask(
202 content::BrowserThread::IO, 202 content::BrowserThread::IO,
203 FROM_HERE, 203 FROM_HERE,
204 base::Bind( 204 base::Bind(
205 &ContentVerifierIOData::RemoveData, io_data_, extension->id())); 205 &ContentVerifierIOData::RemoveData, io_data_, extension->id()));
206 if (fetcher_) 206 if (fetcher_)
207 fetcher_->ExtensionUnloaded(extension); 207 fetcher_->ExtensionUnloaded(extension);
208 } 208 }
209 209
210 void ContentVerifier::OnFetchCompleteHelper(const std::string& extension_id, 210 void ContentVerifier::OnFetchCompleteHelper(
211 bool shouldVerifyAnyPathsResult) { 211 const std::string& extension_id,
212 if (shouldVerifyAnyPathsResult) 212 bool should_verify_any_paths_result) {
213 if (should_verify_any_paths_result)
213 delegate_->VerifyFailed(extension_id, ContentVerifyJob::MISSING_ALL_HASHES); 214 delegate_->VerifyFailed(extension_id, ContentVerifyJob::MISSING_ALL_HASHES);
214 } 215 }
215 216
216 void ContentVerifier::OnFetchComplete( 217 void ContentVerifier::OnFetchComplete(
217 const std::string& extension_id, 218 const std::string& extension_id,
218 bool success, 219 bool success,
219 bool was_force_check, 220 bool was_force_check,
220 const std::set<base::FilePath>& hash_mismatch_paths) { 221 const std::set<base::FilePath>& hash_mismatch_paths) {
221 if (g_test_observer) 222 if (g_test_observer)
222 g_test_observer->OnFetchComplete(extension_id, success); 223 g_test_observer->OnFetchComplete(extension_id, success);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 !extension_l10n_util::ShouldSkipValidation( 296 !extension_l10n_util::ShouldSkipValidation(
296 locales_dir, full_path.DirName(), *all_locales)) 297 locales_dir, full_path.DirName(), *all_locales))
297 continue; 298 continue;
298 } 299 }
299 return true; 300 return true;
300 } 301 }
301 return false; 302 return false;
302 } 303 }
303 304
304 } // namespace extensions 305 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/content_verifier.h ('k') | extensions/browser/content_verify_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698