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

Side by Side Diff: chrome/browser/media_galleries/fileapi/native_media_file_util.cc

Issue 16392011: Move FileEnumerator to its own file, do some refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix incorrect includes Created 7 years, 6 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/media_galleries/fileapi/native_media_file_util.h" 5 #include "chrome/browser/media_galleries/fileapi/native_media_file_util.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/file_enumerator.h"
9 #include "base/string_util.h" 10 #include "base/string_util.h"
10 #include "base/task_runner_util.h" 11 #include "base/task_runner_util.h"
11 #include "chrome/browser/media_galleries/fileapi/media_file_system_mount_point_p rovider.h" 12 #include "chrome/browser/media_galleries/fileapi/media_file_system_mount_point_p rovider.h"
12 #include "chrome/browser/media_galleries/fileapi/media_path_filter.h" 13 #include "chrome/browser/media_galleries/fileapi/media_path_filter.h"
13 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
14 #include "googleurl/src/gurl.h" 15 #include "googleurl/src/gurl.h"
15 #include "net/base/mime_sniffer.h" 16 #include "net/base/mime_sniffer.h"
16 #include "webkit/browser/fileapi/file_system_context.h" 17 #include "webkit/browser/fileapi/file_system_context.h"
17 #include "webkit/browser/fileapi/file_system_operation_context.h" 18 #include "webkit/browser/fileapi/file_system_operation_context.h"
18 #include "webkit/browser/fileapi/file_system_task_runners.h" 19 #include "webkit/browser/fileapi/file_system_task_runners.h"
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 base::FilePath platform_path; 525 base::FilePath platform_path;
525 base::PlatformFileError error = GetFileInfoSync(context, url, &file_info, 526 base::PlatformFileError error = GetFileInfoSync(context, url, &file_info,
526 &platform_path); 527 &platform_path);
527 528
528 if (error != base::PLATFORM_FILE_OK) 529 if (error != base::PLATFORM_FILE_OK)
529 return error; 530 return error;
530 531
531 if (!file_info.is_directory) 532 if (!file_info.is_directory)
532 return base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY; 533 return base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY;
533 534
534 file_util::FileEnumerator file_enum( 535 base::FileEnumerator file_enum(
535 platform_path, 536 platform_path,
536 false /* recursive */, 537 false /* recursive */,
537 file_util::FileEnumerator::FILES | 538 base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES);
538 file_util::FileEnumerator::DIRECTORIES);
539 file_util::FileEnumerator::FindInfo file_util_info;
540 #if defined(OS_WIN)
541 memset(&file_util_info, 0, sizeof(file_util_info));
542 #endif // defined(OS_WIN)
543
544 for (base::FilePath platform_path = file_enum.Next(); 539 for (base::FilePath platform_path = file_enum.Next();
545 !platform_path.empty(); 540 !platform_path.empty();
546 platform_path = file_enum.Next()) { 541 platform_path = file_enum.Next()) {
547 // Skip symlinks. 542 // Skip symlinks.
548 if (file_util::IsLink(platform_path)) 543 if (file_util::IsLink(platform_path))
549 continue; 544 continue;
550 545
551 file_enum.GetFindInfo(&file_util_info); 546 base::FileEnumerator::FileInfo info = file_enum.GetInfo();
552 547
553 // NativeMediaFileUtil skip criteria. 548 // NativeMediaFileUtil skip criteria.
554 if (ShouldSkip(platform_path)) 549 if (ShouldSkip(platform_path))
555 continue; 550 continue;
556 if (!file_util::FileEnumerator::IsDirectory(file_util_info) && 551 if (!info.IsDirectory() &&
557 !GetMediaPathFilter(context)->Match(platform_path)) 552 !GetMediaPathFilter(context)->Match(platform_path))
558 continue; 553 continue;
559 554
560 fileapi::DirectoryEntry entry; 555 fileapi::DirectoryEntry entry;
561 entry.is_directory = file_util::FileEnumerator::IsDirectory(file_util_info); 556 entry.is_directory = info.IsDirectory();
562 entry.name = platform_path.BaseName().value(); 557 entry.name = platform_path.BaseName().value();
563 entry.size = file_util::FileEnumerator::GetFilesize(file_util_info); 558 entry.size = info.GetSize();
564 entry.last_modified_time = 559 entry.last_modified_time = info.GetLastModifiedTime();
565 file_util::FileEnumerator::GetLastModifiedTime(file_util_info);
566 560
567 file_list->push_back(entry); 561 file_list->push_back(entry);
568 } 562 }
569 563
570 return base::PLATFORM_FILE_OK; 564 return base::PLATFORM_FILE_OK;
571 } 565 }
572 566
573 base::PlatformFileError NativeMediaFileUtil::DeleteDirectorySync( 567 base::PlatformFileError NativeMediaFileUtil::DeleteDirectorySync(
574 fileapi::FileSystemOperationContext* context, 568 fileapi::FileSystemOperationContext* context,
575 const fileapi::FileSystemURL& url) { 569 const fileapi::FileSystemURL& url) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 if (!file_info.is_directory && 634 if (!file_info.is_directory &&
641 !GetMediaPathFilter(context)->Match(file_path)) { 635 !GetMediaPathFilter(context)->Match(file_path)) {
642 return failure_error; 636 return failure_error;
643 } 637 }
644 638
645 *local_file_path = file_path; 639 *local_file_path = file_path;
646 return base::PLATFORM_FILE_OK; 640 return base::PLATFORM_FILE_OK;
647 } 641 }
648 642
649 } // namespace chrome 643 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/importer/ie_importer.cc ('k') | chrome/browser/policy/config_dir_policy_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698