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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Loading... |
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 |
OLD | NEW |