Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: chrome/browser/chromeos/drive/file_cache_metadata.cc

Issue 13165005: Move FileEnumerator to its own file, do some refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge, fixes Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/browser/chromeos/drive/drive.pb.h" 12 #include "chrome/browser/chromeos/drive/drive.pb.h"
12 #include "chrome/browser/chromeos/drive/file_cache.h" 13 #include "chrome/browser/chromeos/drive/file_cache.h"
13 #include "chrome/browser/chromeos/drive/file_system_util.h" 14 #include "chrome/browser/chromeos/drive/file_system_util.h"
14 #include "third_party/leveldatabase/src/include/leveldb/db.h" 15 #include "third_party/leveldatabase/src/include/leveldb/db.h"
15 16
16 namespace drive { 17 namespace drive {
17 namespace internal { 18 namespace internal {
18 19
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 // The resource IDs and file paths of discovered files are collected as a 64 // The resource IDs and file paths of discovered files are collected as a
64 // ResourceIdToFilePathMap, if these are processed properly. 65 // ResourceIdToFilePathMap, if these are processed properly.
65 void ScanCacheDirectory( 66 void ScanCacheDirectory(
66 const std::vector<base::FilePath>& cache_paths, 67 const std::vector<base::FilePath>& cache_paths,
67 FileCache::CacheSubDirectoryType sub_dir_type, 68 FileCache::CacheSubDirectoryType sub_dir_type,
68 FileCacheMetadata::CacheMap* cache_map, 69 FileCacheMetadata::CacheMap* cache_map,
69 ResourceIdToFilePathMap* processed_file_map) { 70 ResourceIdToFilePathMap* processed_file_map) {
70 DCHECK(cache_map); 71 DCHECK(cache_map);
71 DCHECK(processed_file_map); 72 DCHECK(processed_file_map);
72 73
73 file_util::FileEnumerator enumerator( 74 base::FileEnumerator enumerator(
74 cache_paths[sub_dir_type], 75 cache_paths[sub_dir_type],
75 false, // not recursive 76 false, // not recursive
76 file_util::FileEnumerator::FILES | 77 base::FileEnumerator::FILES | base::FileEnumerator::SHOW_SYM_LINKS,
77 file_util::FileEnumerator::SHOW_SYM_LINKS,
78 util::kWildCard); 78 util::kWildCard);
79 for (base::FilePath current = enumerator.Next(); !current.empty(); 79 for (base::FilePath current = enumerator.Next(); !current.empty();
80 current = enumerator.Next()) { 80 current = enumerator.Next()) {
81 // Extract resource_id and md5 from filename. 81 // Extract resource_id and md5 from filename.
82 std::string resource_id; 82 std::string resource_id;
83 std::string md5; 83 std::string md5;
84 std::string extra_extension; 84 std::string extra_extension;
85 util::ParseCacheFilePath(current, &resource_id, &md5, &extra_extension); 85 util::ParseCacheFilePath(current, &resource_id, &md5, &extra_extension);
86 86
87 // Determine cache state. 87 // Determine cache state.
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 new FakeCacheMetadata(blocking_task_runner)); 569 new FakeCacheMetadata(blocking_task_runner));
570 } 570 }
571 571
572 void FileCacheMetadata::AssertOnSequencedWorkerPool() { 572 void FileCacheMetadata::AssertOnSequencedWorkerPool() {
573 DCHECK(!blocking_task_runner_ || 573 DCHECK(!blocking_task_runner_ ||
574 blocking_task_runner_->RunsTasksOnCurrentThread()); 574 blocking_task_runner_->RunsTasksOnCurrentThread());
575 } 575 }
576 576
577 } // namespace internal 577 } // namespace internal
578 } // namespace drive 578 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/file_cache.cc ('k') | chrome/browser/chromeos/drive/file_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698