OLD | NEW |
---|---|
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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 if (hashes_ready_) { | 136 if (hashes_ready_) { |
137 if (!FinishBlock()) | 137 if (!FinishBlock()) |
138 DispatchFailureCallback(HASH_MISMATCH); | 138 DispatchFailureCallback(HASH_MISMATCH); |
139 else if (g_test_observer) | 139 else if (g_test_observer) |
140 g_test_observer->JobFinished(hash_reader_->extension_id(), | 140 g_test_observer->JobFinished(hash_reader_->extension_id(), |
141 hash_reader_->relative_path(), failed_); | 141 hash_reader_->relative_path(), failed_); |
142 } | 142 } |
143 } | 143 } |
144 | 144 |
145 bool ContentVerifyJob::FinishBlock() { | 145 bool ContentVerifyJob::FinishBlock() { |
146 if (current_hash_byte_count_ <= 0) | 146 if (!done_reading_ && current_hash_byte_count_ <= 0) |
Devlin
2017/03/24 02:01:44
unrelated to this cl, but when can current_hash_by
lazyboy
2017/03/24 18:27:47
Yes I noticed this and didn't want to change it at
| |
147 return true; | 147 return true; |
148 if (!current_hash_) { | |
149 // This happens when we fail to read the resource, compute empty content's | |
Devlin
2017/03/24 02:01:45
nitty nit: s/,/;||.
lazyboy
2017/03/24 18:27:47
Done.
| |
150 // hash in this case. | |
151 current_hash_ = crypto::SecureHash::Create(crypto::SecureHash::SHA256); | |
152 } | |
148 std::string final(crypto::kSHA256Length, 0); | 153 std::string final(crypto::kSHA256Length, 0); |
149 current_hash_->Finish(base::string_as_array(& final), final.size()); | 154 current_hash_->Finish(base::string_as_array(& final), final.size()); |
150 current_hash_.reset(); | 155 current_hash_.reset(); |
151 current_hash_byte_count_ = 0; | 156 current_hash_byte_count_ = 0; |
152 | 157 |
153 int block = current_block_++; | 158 int block = current_block_++; |
154 | 159 |
155 const std::string* expected_hash = NULL; | 160 const std::string* expected_hash = NULL; |
156 if (!hash_reader_->GetHashForBlock(block, &expected_hash) || | 161 if (!hash_reader_->GetHashForBlock(block, &expected_hash) || |
157 *expected_hash != final) | 162 *expected_hash != final) |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
213 << " reason:" << reason; | 218 << " reason:" << reason; |
214 failure_callback_.Run(reason); | 219 failure_callback_.Run(reason); |
215 failure_callback_.Reset(); | 220 failure_callback_.Reset(); |
216 } | 221 } |
217 if (g_test_observer) | 222 if (g_test_observer) |
218 g_test_observer->JobFinished( | 223 g_test_observer->JobFinished( |
219 hash_reader_->extension_id(), hash_reader_->relative_path(), failed_); | 224 hash_reader_->extension_id(), hash_reader_->relative_path(), failed_); |
220 } | 225 } |
221 | 226 |
222 } // namespace extensions | 227 } // namespace extensions |
OLD | NEW |