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/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 DB_OPEN_SUCCESS, | 22 DB_OPEN_SUCCESS, |
23 DB_OPEN_FAILURE_CORRUPTION, | 23 DB_OPEN_FAILURE_CORRUPTION, |
24 DB_OPEN_FAILURE_OTHER, | 24 DB_OPEN_FAILURE_OTHER, |
25 DB_OPEN_FAILURE_UNRECOVERABLE, | 25 DB_OPEN_FAILURE_UNRECOVERABLE, |
26 DB_OPEN_MAX_VALUE, | 26 DB_OPEN_MAX_VALUE, |
27 }; | 27 }; |
28 | 28 |
29 // A map table of resource ID to file path. | 29 // A map table of resource ID to file path. |
30 typedef std::map<std::string, base::FilePath> ResourceIdToFilePathMap; | 30 typedef std::map<std::string, base::FilePath> ResourceIdToFilePathMap; |
31 | 31 |
32 // Scans cache subdirectory and build or update |cache_map| | 32 // Scans cache subdirectory and build or update |cache_map| with found files. |
33 // with found file blobs or symlinks. | |
34 // | 33 // |
35 // The resource IDs and file paths of discovered files are collected as a | 34 // The resource IDs and file paths of discovered files are collected as a |
36 // ResourceIdToFilePathMap, if these are processed properly. | 35 // ResourceIdToFilePathMap, if these are processed properly. |
37 void ScanCacheDirectory( | 36 void ScanCacheDirectory( |
38 const std::vector<base::FilePath>& cache_paths, | 37 const std::vector<base::FilePath>& cache_paths, |
39 FileCache::CacheSubDirectoryType sub_dir_type, | 38 FileCache::CacheSubDirectoryType sub_dir_type, |
40 FileCacheMetadata::CacheMap* cache_map, | 39 FileCacheMetadata::CacheMap* cache_map, |
41 ResourceIdToFilePathMap* processed_file_map) { | 40 ResourceIdToFilePathMap* processed_file_map) { |
42 DCHECK(cache_map); | 41 DCHECK(cache_map); |
43 DCHECK(processed_file_map); | 42 DCHECK(processed_file_map); |
44 | 43 |
45 file_util::FileEnumerator enumerator( | 44 file_util::FileEnumerator enumerator(cache_paths[sub_dir_type], |
46 cache_paths[sub_dir_type], | 45 false, // not recursive |
47 false, // not recursive | 46 file_util::FileEnumerator::FILES, |
48 file_util::FileEnumerator::FILES | | 47 util::kWildCard); |
49 file_util::FileEnumerator::SHOW_SYM_LINKS, | |
50 util::kWildCard); | |
51 for (base::FilePath current = enumerator.Next(); !current.empty(); | 48 for (base::FilePath current = enumerator.Next(); !current.empty(); |
52 current = enumerator.Next()) { | 49 current = enumerator.Next()) { |
53 // Extract resource_id and md5 from filename. | 50 // Extract resource_id and md5 from filename. |
54 std::string resource_id; | 51 std::string resource_id; |
55 std::string md5; | 52 std::string md5; |
56 std::string extra_extension; | 53 std::string extra_extension; |
57 util::ParseCacheFilePath(current, &resource_id, &md5, &extra_extension); | 54 util::ParseCacheFilePath(current, &resource_id, &md5, &extra_extension); |
58 | 55 |
59 // Determine cache state. | 56 // Determine cache state. |
60 FileCacheEntry cache_entry; | 57 FileCacheEntry cache_entry; |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 new FakeCacheMetadata(blocking_task_runner)); | 490 new FakeCacheMetadata(blocking_task_runner)); |
494 } | 491 } |
495 | 492 |
496 void FileCacheMetadata::AssertOnSequencedWorkerPool() { | 493 void FileCacheMetadata::AssertOnSequencedWorkerPool() { |
497 DCHECK(!blocking_task_runner_ || | 494 DCHECK(!blocking_task_runner_ || |
498 blocking_task_runner_->RunsTasksOnCurrentThread()); | 495 blocking_task_runner_->RunsTasksOnCurrentThread()); |
499 } | 496 } |
500 | 497 |
501 } // namespace internal | 498 } // namespace internal |
502 } // namespace drive | 499 } // namespace drive |
OLD | NEW |