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

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

Issue 512573003: Content verification: Don't fail on non-existence. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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_hash_reader.cc ('k') | no next file » | 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 const std::string* expected_hash = NULL; 145 const std::string* expected_hash = NULL;
146 if (!hash_reader_->GetHashForBlock(block, &expected_hash) || 146 if (!hash_reader_->GetHashForBlock(block, &expected_hash) ||
147 *expected_hash != final) 147 *expected_hash != final)
148 return false; 148 return false;
149 149
150 return true; 150 return true;
151 } 151 }
152 152
153 void ContentVerifyJob::OnHashesReady(bool success) { 153 void ContentVerifyJob::OnHashesReady(bool success) {
154 if (!success && !g_test_delegate) { 154 if (!success && !g_test_delegate) {
155 if (hash_reader_->have_verified_contents() && 155 if (!hash_reader_->content_exists()) {
156 hash_reader_->have_computed_hashes()) 156 // Ignore verification of non-existent resources.
157 return;
158 } else if (hash_reader_->have_verified_contents() &&
159 hash_reader_->have_computed_hashes()) {
157 DispatchFailureCallback(NO_HASHES_FOR_FILE); 160 DispatchFailureCallback(NO_HASHES_FOR_FILE);
158 else 161 } else {
159 DispatchFailureCallback(MISSING_ALL_HASHES); 162 DispatchFailureCallback(MISSING_ALL_HASHES);
163 }
160 return; 164 return;
161 } 165 }
162 166
163 hashes_ready_ = true; 167 hashes_ready_ = true;
164 if (!queue_.empty()) { 168 if (!queue_.empty()) {
165 std::string tmp; 169 std::string tmp;
166 queue_.swap(tmp); 170 queue_.swap(tmp);
167 BytesRead(tmp.size(), string_as_array(&tmp)); 171 BytesRead(tmp.size(), string_as_array(&tmp));
168 } 172 }
169 if (done_reading_) { 173 if (done_reading_) {
(...skipping 14 matching lines...) Expand all
184 if (!failure_callback_.is_null()) { 188 if (!failure_callback_.is_null()) {
185 VLOG(1) << "job failed for " << hash_reader_->extension_id() << " " 189 VLOG(1) << "job failed for " << hash_reader_->extension_id() << " "
186 << hash_reader_->relative_path().MaybeAsASCII() 190 << hash_reader_->relative_path().MaybeAsASCII()
187 << " reason:" << reason; 191 << " reason:" << reason;
188 failure_callback_.Run(reason); 192 failure_callback_.Run(reason);
189 failure_callback_.Reset(); 193 failure_callback_.Reset();
190 } 194 }
191 } 195 }
192 196
193 } // namespace extensions 197 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/content_hash_reader.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698