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/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/task_runner_util.h" | 10 #include "base/task_runner_util.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 114 |
115 if (*expected_hash != final) | 115 if (*expected_hash != final) |
116 return DispatchFailureCallback(HASH_MISMATCH); | 116 return DispatchFailureCallback(HASH_MISMATCH); |
117 | 117 |
118 current_hash_.reset(); | 118 current_hash_.reset(); |
119 current_hash_byte_count_ = 0; | 119 current_hash_byte_count_ = 0; |
120 current_block_++; | 120 current_block_++; |
121 } | 121 } |
122 | 122 |
123 void ContentVerifyJob::OnHashesReady(bool success) { | 123 void ContentVerifyJob::OnHashesReady(bool success) { |
124 if (!success) | 124 if (!success && !g_test_delegate) |
125 return DispatchFailureCallback(NO_HASHES); | 125 return DispatchFailureCallback(NO_HASHES); |
126 | 126 |
127 hashes_ready_ = true; | 127 hashes_ready_ = true; |
128 if (!queue_.empty()) { | 128 if (!queue_.empty()) { |
129 std::string tmp; | 129 std::string tmp; |
130 queue_.swap(tmp); | 130 queue_.swap(tmp); |
131 BytesRead(tmp.size(), string_as_array(&tmp)); | 131 BytesRead(tmp.size(), string_as_array(&tmp)); |
132 } | 132 } |
133 if (done_reading_) | 133 if (done_reading_) |
134 FinishBlock(); | 134 FinishBlock(); |
135 } | 135 } |
136 | 136 |
137 // static | 137 // static |
138 void ContentVerifyJob::SetDelegateForTests(TestDelegate* delegate) { | 138 void ContentVerifyJob::SetDelegateForTests(TestDelegate* delegate) { |
139 g_test_delegate = delegate; | 139 g_test_delegate = delegate; |
140 } | 140 } |
141 | 141 |
142 void ContentVerifyJob::DispatchFailureCallback(FailureReason reason) { | 142 void ContentVerifyJob::DispatchFailureCallback(FailureReason reason) { |
143 if (!failure_callback_.is_null()) { | 143 if (!failure_callback_.is_null()) { |
144 failure_callback_.Run(reason); | 144 failure_callback_.Run(reason); |
145 failure_callback_.Reset(); | 145 failure_callback_.Reset(); |
146 } | 146 } |
147 } | 147 } |
148 | 148 |
149 } // namespace extensions | 149 } // namespace extensions |
OLD | NEW |