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

Side by Side Diff: extensions/browser/content_verify_job.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_verify_job.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 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_verify_job.h" 5 #include "extensions/browser/content_verify_job.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 23 matching lines...) Expand all
34 // destruction. 34 // destruction.
35 base::TimeDelta* total_; 35 base::TimeDelta* total_;
36 36
37 // A timer for how long this object has been alive. 37 // A timer for how long this object has been alive.
38 base::ElapsedTimer timer; 38 base::ElapsedTimer timer;
39 }; 39 };
40 40
41 } // namespace 41 } // namespace
42 42
43 ContentVerifyJob::ContentVerifyJob(ContentHashReader* hash_reader, 43 ContentVerifyJob::ContentVerifyJob(ContentHashReader* hash_reader,
44 const FailureCallback& failure_callback) 44 FailureCallback failure_callback)
45 : done_reading_(false), 45 : done_reading_(false),
46 hashes_ready_(false), 46 hashes_ready_(false),
47 total_bytes_read_(0), 47 total_bytes_read_(0),
48 current_block_(0), 48 current_block_(0),
49 current_hash_byte_count_(0), 49 current_hash_byte_count_(0),
50 hash_reader_(hash_reader), 50 hash_reader_(hash_reader),
51 failure_callback_(failure_callback), 51 failure_callback_(std::move(failure_callback)),
52 failed_(false) { 52 failed_(false) {
53 // It's ok for this object to be constructed on a different thread from where 53 // It's ok for this object to be constructed on a different thread from where
54 // it's used. 54 // it's used.
55 thread_checker_.DetachFromThread(); 55 thread_checker_.DetachFromThread();
56 } 56 }
57 57
58 ContentVerifyJob::~ContentVerifyJob() { 58 ContentVerifyJob::~ContentVerifyJob() {
59 UMA_HISTOGRAM_COUNTS("ExtensionContentVerifyJob.TimeSpentUS", 59 UMA_HISTOGRAM_COUNTS("ExtensionContentVerifyJob.TimeSpentUS",
60 time_spent_.InMicroseconds()); 60 time_spent_.InMicroseconds());
61 } 61 }
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 g_test_observer = observer; 220 g_test_observer = observer;
221 } 221 }
222 222
223 void ContentVerifyJob::DispatchFailureCallback(FailureReason reason) { 223 void ContentVerifyJob::DispatchFailureCallback(FailureReason reason) {
224 DCHECK(!failed_); 224 DCHECK(!failed_);
225 failed_ = true; 225 failed_ = true;
226 if (!failure_callback_.is_null()) { 226 if (!failure_callback_.is_null()) {
227 VLOG(1) << "job failed for " << hash_reader_->extension_id() << " " 227 VLOG(1) << "job failed for " << hash_reader_->extension_id() << " "
228 << hash_reader_->relative_path().MaybeAsASCII() 228 << hash_reader_->relative_path().MaybeAsASCII()
229 << " reason:" << reason; 229 << " reason:" << reason;
230 failure_callback_.Run(reason); 230 std::move(failure_callback_).Run(reason);
231 failure_callback_.Reset();
232 } 231 }
233 if (g_test_observer) { 232 if (g_test_observer) {
234 g_test_observer->JobFinished(hash_reader_->extension_id(), 233 g_test_observer->JobFinished(hash_reader_->extension_id(),
235 hash_reader_->relative_path(), reason); 234 hash_reader_->relative_path(), reason);
236 } 235 }
237 } 236 }
238 237
239 } // namespace extensions 238 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/content_verify_job.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698