| 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.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 (current_hash_byte_count_ <= 0) |
| 147 return true; | 147 return true; |
| 148 std::string final(crypto::kSHA256Length, 0); | 148 std::string final(crypto::kSHA256Length, 0); |
| 149 current_hash_->Finish(string_as_array(&final), final.size()); | 149 current_hash_->Finish(base::string_as_array(& final), final.size()); |
| 150 current_hash_.reset(); | 150 current_hash_.reset(); |
| 151 current_hash_byte_count_ = 0; | 151 current_hash_byte_count_ = 0; |
| 152 | 152 |
| 153 int block = current_block_++; | 153 int block = current_block_++; |
| 154 | 154 |
| 155 const std::string* expected_hash = NULL; | 155 const std::string* expected_hash = NULL; |
| 156 if (!hash_reader_->GetHashForBlock(block, &expected_hash) || | 156 if (!hash_reader_->GetHashForBlock(block, &expected_hash) || |
| 157 *expected_hash != final) | 157 *expected_hash != final) |
| 158 return false; | 158 return false; |
| 159 | 159 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 171 } else { | 171 } else { |
| 172 DispatchFailureCallback(MISSING_ALL_HASHES); | 172 DispatchFailureCallback(MISSING_ALL_HASHES); |
| 173 } | 173 } |
| 174 return; | 174 return; |
| 175 } | 175 } |
| 176 | 176 |
| 177 hashes_ready_ = true; | 177 hashes_ready_ = true; |
| 178 if (!queue_.empty()) { | 178 if (!queue_.empty()) { |
| 179 std::string tmp; | 179 std::string tmp; |
| 180 queue_.swap(tmp); | 180 queue_.swap(tmp); |
| 181 BytesRead(tmp.size(), string_as_array(&tmp)); | 181 BytesRead(tmp.size(), base::string_as_array(&tmp)); |
| 182 } | 182 } |
| 183 if (done_reading_) { | 183 if (done_reading_) { |
| 184 ScopedElapsedTimer timer(&time_spent_); | 184 ScopedElapsedTimer timer(&time_spent_); |
| 185 if (!FinishBlock()) { | 185 if (!FinishBlock()) { |
| 186 DispatchFailureCallback(HASH_MISMATCH); | 186 DispatchFailureCallback(HASH_MISMATCH); |
| 187 } else if (g_test_observer) { | 187 } else if (g_test_observer) { |
| 188 g_test_observer->JobFinished(hash_reader_->extension_id(), | 188 g_test_observer->JobFinished(hash_reader_->extension_id(), |
| 189 hash_reader_->relative_path(), failed_); | 189 hash_reader_->relative_path(), failed_); |
| 190 } | 190 } |
| 191 } | 191 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 213 << " reason:" << reason; | 213 << " reason:" << reason; |
| 214 failure_callback_.Run(reason); | 214 failure_callback_.Run(reason); |
| 215 failure_callback_.Reset(); | 215 failure_callback_.Reset(); |
| 216 } | 216 } |
| 217 if (g_test_observer) | 217 if (g_test_observer) |
| 218 g_test_observer->JobFinished( | 218 g_test_observer->JobFinished( |
| 219 hash_reader_->extension_id(), hash_reader_->relative_path(), failed_); | 219 hash_reader_->extension_id(), hash_reader_->relative_path(), failed_); |
| 220 } | 220 } |
| 221 | 221 |
| 222 } // namespace extensions | 222 } // namespace extensions |
| OLD | NEW |