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

Unified Diff: extensions/browser/content_verify_job.cc

Issue 1361513002: Improve ContentVerifierTest.Fail* tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/content_verifier_browsertest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/content_verify_job.cc
diff --git a/extensions/browser/content_verify_job.cc b/extensions/browser/content_verify_job.cc
index efd763eaf7294e48e7b7fd59267a2405d5ae7137..701c01d41070791244b5b1600cb7ab54226b7d6f 100644
--- a/extensions/browser/content_verify_job.cc
+++ b/extensions/browser/content_verify_job.cc
@@ -24,7 +24,9 @@ ContentVerifyJob::TestObserver* g_test_observer = NULL;
class ScopedElapsedTimer {
public:
- ScopedElapsedTimer(base::TimeDelta* total) : total_(total) { DCHECK(total_); }
+ explicit ScopedElapsedTimer(base::TimeDelta* total) : total_(total) {
+ DCHECK(total_);
+ }
~ScopedElapsedTimer() { *total_ += timer.Elapsed(); }
@@ -80,7 +82,8 @@ void ContentVerifyJob::BytesRead(int count, const char* data) {
FailureReason reason =
g_test_delegate->BytesRead(hash_reader_->extension_id(), count, data);
if (reason != NONE)
- return DispatchFailureCallback(reason);
+ DispatchFailureCallback(reason);
+ return;
}
if (!hashes_ready_) {
queue_.append(data, count);
@@ -102,7 +105,7 @@ void ContentVerifyJob::BytesRead(int count, const char* data) {
int bytes_to_hash =
std::min(hash_reader_->block_size() - current_hash_byte_count_,
count - bytes_added);
- DCHECK(bytes_to_hash > 0);
+ DCHECK_GT(bytes_to_hash, 0);
current_hash_->Update(data + bytes_added, bytes_to_hash);
bytes_added += bytes_to_hash;
current_hash_byte_count_ += bytes_to_hash;
@@ -126,10 +129,9 @@ void ContentVerifyJob::DoneReading() {
if (g_test_delegate) {
FailureReason reason =
g_test_delegate->DoneReading(hash_reader_->extension_id());
- if (reason != NONE) {
+ if (reason != NONE)
DispatchFailureCallback(reason);
- return;
- }
+ return;
}
done_reading_ = true;
if (hashes_ready_) {
@@ -181,9 +183,9 @@ void ContentVerifyJob::OnHashesReady(bool success) {
}
if (done_reading_) {
ScopedElapsedTimer timer(&time_spent_);
- if (!FinishBlock())
+ if (!FinishBlock()) {
DispatchFailureCallback(HASH_MISMATCH);
- else if (g_test_observer) {
+ } else if (g_test_observer) {
g_test_observer->JobFinished(hash_reader_->extension_id(),
hash_reader_->relative_path(), failed_);
}
« no previous file with comments | « chrome/browser/extensions/content_verifier_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698