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

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

Issue 2236443003: extensions: Use stl utilities from the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't add braces Created 4 years, 4 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_verifier.cc ('k') | extensions/browser/error_map.cc » ('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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
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
OLDNEW
« no previous file with comments | « extensions/browser/content_verifier.cc ('k') | extensions/browser/error_map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698