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_hash_fetcher.h" | 5 #include "extensions/browser/content_hash_fetcher.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 return result; | 215 return result; |
216 } | 216 } |
217 | 217 |
218 ContentHashFetcherJob::~ContentHashFetcherJob() { | 218 ContentHashFetcherJob::~ContentHashFetcherJob() { |
219 } | 219 } |
220 | 220 |
221 bool ContentHashFetcherJob::LoadVerifiedContents(const base::FilePath& path) { | 221 bool ContentHashFetcherJob::LoadVerifiedContents(const base::FilePath& path) { |
222 if (!base::PathExists(path)) | 222 if (!base::PathExists(path)) |
223 return false; | 223 return false; |
224 verified_contents_.reset(new VerifiedContents(key_.data, key_.size)); | 224 verified_contents_.reset(new VerifiedContents(key_.data, key_.size)); |
225 if (!verified_contents_->InitFrom(path, false)) { | 225 if (!verified_contents_->InitFrom(path)) { |
226 verified_contents_.reset(); | 226 verified_contents_.reset(); |
227 if (!base::DeleteFile(path, false)) | 227 if (!base::DeleteFile(path, false)) |
228 LOG(WARNING) << "Failed to delete " << path.value(); | 228 LOG(WARNING) << "Failed to delete " << path.value(); |
229 return false; | 229 return false; |
230 } | 230 } |
231 return true; | 231 return true; |
232 } | 232 } |
233 | 233 |
234 void ContentHashFetcherJob::DoneCheckingForVerifiedContents(bool found) { | 234 void ContentHashFetcherJob::DoneCheckingForVerifiedContents(bool found) { |
235 if (IsCancelled()) | 235 if (IsCancelled()) |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 if (IsCancelled()) | 345 if (IsCancelled()) |
346 return false; | 346 return false; |
347 // Make sure the directory exists. | 347 // Make sure the directory exists. |
348 if (!base::CreateDirectoryAndGetError(hashes_file.DirName(), NULL)) | 348 if (!base::CreateDirectoryAndGetError(hashes_file.DirName(), NULL)) |
349 return false; | 349 return false; |
350 | 350 |
351 if (!verified_contents_.get()) { | 351 if (!verified_contents_.get()) { |
352 base::FilePath verified_contents_path = | 352 base::FilePath verified_contents_path = |
353 file_util::GetVerifiedContentsPath(extension_path_); | 353 file_util::GetVerifiedContentsPath(extension_path_); |
354 verified_contents_.reset(new VerifiedContents(key_.data, key_.size)); | 354 verified_contents_.reset(new VerifiedContents(key_.data, key_.size)); |
355 if (!verified_contents_->InitFrom(verified_contents_path, false)) { | 355 if (!verified_contents_->InitFrom(verified_contents_path)) { |
356 verified_contents_.reset(); | 356 verified_contents_.reset(); |
357 return false; | 357 return false; |
358 } | 358 } |
359 } | 359 } |
360 | 360 |
361 base::FileEnumerator enumerator(extension_path_, | 361 base::FileEnumerator enumerator(extension_path_, |
362 true, /* recursive */ | 362 true, /* recursive */ |
363 base::FileEnumerator::FILES); | 363 base::FileEnumerator::FILES); |
364 // First discover all the file paths and put them in a sorted set. | 364 // First discover all the file paths and put them in a sorted set. |
365 SortedFilePathSet paths; | 365 SortedFilePathSet paths; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 | 497 |
498 for (JobMap::iterator i = jobs_.begin(); i != jobs_.end(); ++i) { | 498 for (JobMap::iterator i = jobs_.begin(); i != jobs_.end(); ++i) { |
499 if (i->second.get() == job) { | 499 if (i->second.get() == job) { |
500 jobs_.erase(i); | 500 jobs_.erase(i); |
501 break; | 501 break; |
502 } | 502 } |
503 } | 503 } |
504 } | 504 } |
505 | 505 |
506 } // namespace extensions | 506 } // namespace extensions |
OLD | NEW |