| 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/computed_hashes.h" | 5 #include "extensions/browser/computed_hashes.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 const char* block_start = contents.data() + offset; | 177 const char* block_start = contents.data() + offset; |
| 178 DCHECK(offset <= contents.size()); | 178 DCHECK(offset <= contents.size()); |
| 179 size_t bytes_to_read = std::min(contents.size() - offset, block_size); | 179 size_t bytes_to_read = std::min(contents.size() - offset, block_size); |
| 180 std::unique_ptr<crypto::SecureHash> hash( | 180 std::unique_ptr<crypto::SecureHash> hash( |
| 181 crypto::SecureHash::Create(crypto::SecureHash::SHA256)); | 181 crypto::SecureHash::Create(crypto::SecureHash::SHA256)); |
| 182 hash->Update(block_start, bytes_to_read); | 182 hash->Update(block_start, bytes_to_read); |
| 183 | 183 |
| 184 hashes->push_back(std::string()); | 184 hashes->push_back(std::string()); |
| 185 std::string* buffer = &(hashes->back()); | 185 std::string* buffer = &(hashes->back()); |
| 186 buffer->resize(crypto::kSHA256Length); | 186 buffer->resize(crypto::kSHA256Length); |
| 187 hash->Finish(string_as_array(buffer), buffer->size()); | 187 hash->Finish(base::string_as_array(buffer), buffer->size()); |
| 188 | 188 |
| 189 // If |contents| is empty, then we want to just exit here. | 189 // If |contents| is empty, then we want to just exit here. |
| 190 if (bytes_to_read == 0) | 190 if (bytes_to_read == 0) |
| 191 break; | 191 break; |
| 192 | 192 |
| 193 offset += bytes_to_read; | 193 offset += bytes_to_read; |
| 194 } while (offset < contents.size()); | 194 } while (offset < contents.size()); |
| 195 } | 195 } |
| 196 | 196 |
| 197 } // namespace extensions | 197 } // namespace extensions |
| OLD | NEW |