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

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

Issue 407043002: Content Verification: Don't access UI-thread objects on the IO thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added DCHECK Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « extensions/browser/content_verifier_io_data.cc ('k') | extensions/extensions.gyp » ('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_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.h" 9 #include "base/metrics/histogram.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 done_reading_ = true; 130 done_reading_ = true;
131 if (hashes_ready_ && !FinishBlock()) 131 if (hashes_ready_ && !FinishBlock())
132 DispatchFailureCallback(HASH_MISMATCH); 132 DispatchFailureCallback(HASH_MISMATCH);
133 } 133 }
134 134
135 bool ContentVerifyJob::FinishBlock() { 135 bool ContentVerifyJob::FinishBlock() {
136 if (current_hash_byte_count_ <= 0) 136 if (current_hash_byte_count_ <= 0)
137 return true; 137 return true;
138 std::string final(crypto::kSHA256Length, 0); 138 std::string final(crypto::kSHA256Length, 0);
139 current_hash_->Finish(string_as_array(&final), final.size()); 139 current_hash_->Finish(string_as_array(&final), final.size());
140 current_hash_.reset();
141 current_hash_byte_count_ = 0;
142
143 int block = current_block_++;
140 144
141 const std::string* expected_hash = NULL; 145 const std::string* expected_hash = NULL;
142 if (!hash_reader_->GetHashForBlock(current_block_, &expected_hash) || 146 if (!hash_reader_->GetHashForBlock(block, &expected_hash) ||
143 *expected_hash != final) 147 *expected_hash != final)
144 return false; 148 return false;
145 149
146 current_hash_.reset();
147 current_hash_byte_count_ = 0;
148 current_block_++;
149 return true; 150 return true;
150 } 151 }
151 152
152 void ContentVerifyJob::OnHashesReady(bool success) { 153 void ContentVerifyJob::OnHashesReady(bool success) {
153 if (!success && !g_test_delegate) { 154 if (!success && !g_test_delegate) {
154 if (hash_reader_->have_verified_contents() && 155 if (hash_reader_->have_verified_contents() &&
155 hash_reader_->have_computed_hashes()) 156 hash_reader_->have_computed_hashes())
156 DispatchFailureCallback(NO_HASHES_FOR_FILE); 157 DispatchFailureCallback(NO_HASHES_FOR_FILE);
157 else 158 else
158 DispatchFailureCallback(MISSING_ALL_HASHES); 159 DispatchFailureCallback(MISSING_ALL_HASHES);
(...skipping 24 matching lines...) Expand all
183 if (!failure_callback_.is_null()) { 184 if (!failure_callback_.is_null()) {
184 VLOG(1) << "job failed for " << hash_reader_->extension_id() << " " 185 VLOG(1) << "job failed for " << hash_reader_->extension_id() << " "
185 << hash_reader_->relative_path().MaybeAsASCII() 186 << hash_reader_->relative_path().MaybeAsASCII()
186 << " reason:" << reason; 187 << " reason:" << reason;
187 failure_callback_.Run(reason); 188 failure_callback_.Run(reason);
188 failure_callback_.Reset(); 189 failure_callback_.Reset();
189 } 190 }
190 } 191 }
191 192
192 } // namespace extensions 193 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/content_verifier_io_data.cc ('k') | extensions/extensions.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698