| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/drive/file_cache_metadata.h" | 5 #include "chrome/browser/chromeos/drive/file_cache_metadata.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/files/file_enumerator.h" |
| 9 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 10 #include "base/sequenced_task_runner.h" | 11 #include "base/sequenced_task_runner.h" |
| 11 #include "base/threading/thread_restrictions.h" | 12 #include "base/threading/thread_restrictions.h" |
| 12 #include "chrome/browser/chromeos/drive/drive.pb.h" | 13 #include "chrome/browser/chromeos/drive/drive.pb.h" |
| 13 #include "chrome/browser/chromeos/drive/file_cache.h" | 14 #include "chrome/browser/chromeos/drive/file_cache.h" |
| 14 #include "chrome/browser/chromeos/drive/file_system_util.h" | 15 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 15 #include "third_party/leveldatabase/src/include/leveldb/db.h" | 16 #include "third_party/leveldatabase/src/include/leveldb/db.h" |
| 16 | 17 |
| 17 namespace drive { | 18 namespace drive { |
| 18 namespace internal { | 19 namespace internal { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 36 // | 37 // |
| 37 // The resource IDs and file paths of discovered files are collected as a | 38 // The resource IDs and file paths of discovered files are collected as a |
| 38 // ResourceIdToFilePathMap, if these are processed properly. | 39 // ResourceIdToFilePathMap, if these are processed properly. |
| 39 void ScanCacheDirectory(const std::vector<base::FilePath>& cache_paths, | 40 void ScanCacheDirectory(const std::vector<base::FilePath>& cache_paths, |
| 40 FileCache::CacheSubDirectoryType sub_dir_type, | 41 FileCache::CacheSubDirectoryType sub_dir_type, |
| 41 CacheMap* cache_map, | 42 CacheMap* cache_map, |
| 42 ResourceIdToFilePathMap* processed_file_map) { | 43 ResourceIdToFilePathMap* processed_file_map) { |
| 43 DCHECK(cache_map); | 44 DCHECK(cache_map); |
| 44 DCHECK(processed_file_map); | 45 DCHECK(processed_file_map); |
| 45 | 46 |
| 46 file_util::FileEnumerator enumerator(cache_paths[sub_dir_type], | 47 base::FileEnumerator enumerator(cache_paths[sub_dir_type], |
| 47 false, // not recursive | 48 false, // not recursive |
| 48 file_util::FileEnumerator::FILES, | 49 base::FileEnumerator::FILES, |
| 49 util::kWildCard); | 50 util::kWildCard); |
| 50 for (base::FilePath current = enumerator.Next(); !current.empty(); | 51 for (base::FilePath current = enumerator.Next(); !current.empty(); |
| 51 current = enumerator.Next()) { | 52 current = enumerator.Next()) { |
| 52 // Extract resource_id and md5 from filename. | 53 // Extract resource_id and md5 from filename. |
| 53 std::string resource_id; | 54 std::string resource_id; |
| 54 std::string md5; | 55 std::string md5; |
| 55 std::string extra_extension; | 56 std::string extra_extension; |
| 56 util::ParseCacheFilePath(current, &resource_id, &md5, &extra_extension); | 57 util::ParseCacheFilePath(current, &resource_id, &md5, &extra_extension); |
| 57 | 58 |
| 58 // Determine cache state. | 59 // Determine cache state. |
| 59 FileCacheEntry cache_entry; | 60 FileCacheEntry cache_entry; |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 return make_scoped_ptr(new Iterator(iter.Pass())); | 343 return make_scoped_ptr(new Iterator(iter.Pass())); |
| 343 } | 344 } |
| 344 | 345 |
| 345 void FileCacheMetadata::AssertOnSequencedWorkerPool() { | 346 void FileCacheMetadata::AssertOnSequencedWorkerPool() { |
| 346 DCHECK(!blocking_task_runner_ || | 347 DCHECK(!blocking_task_runner_ || |
| 347 blocking_task_runner_->RunsTasksOnCurrentThread()); | 348 blocking_task_runner_->RunsTasksOnCurrentThread()); |
| 348 } | 349 } |
| 349 | 350 |
| 350 } // namespace internal | 351 } // namespace internal |
| 351 } // namespace drive | 352 } // namespace drive |
| OLD | NEW |