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

Side by Side Diff: base/file_util_proxy.cc

Issue 4261001: Moving Entry from base::file_util_proxy namespace to within class base::FileU... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/file_util_proxy.h" 5 #include "base/file_util_proxy.h"
6 6
7 #include "base/message_loop_proxy.h" 7 #include "base/message_loop_proxy.h"
8 8
9 // TODO(jianli): Move the code from anonymous namespace to base namespace so 9 // TODO(jianli): Move the code from anonymous namespace to base namespace so
10 // that all of the base:: prefixes would be unnecessary. 10 // that all of the base:: prefixes would be unnecessary.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 // TODO(kinuko): may be better to change the file_util::{Copy,Move}. 59 // TODO(kinuko): may be better to change the file_util::{Copy,Move}.
60 if (!file_util::Delete(dest_file_path, false /* recursive */)) { 60 if (!file_util::Delete(dest_file_path, false /* recursive */)) {
61 if (!file_util::IsDirectoryEmpty(dest_file_path)) 61 if (!file_util::IsDirectoryEmpty(dest_file_path))
62 return base::PLATFORM_FILE_ERROR_NOT_EMPTY; 62 return base::PLATFORM_FILE_ERROR_NOT_EMPTY;
63 return base::PLATFORM_FILE_ERROR_FAILED; 63 return base::PLATFORM_FILE_ERROR_FAILED;
64 } 64 }
65 } 65 }
66 return base::PLATFORM_FILE_OK; 66 return base::PLATFORM_FILE_OK;
67 } 67 }
68 68
69 } // anonymous namespace 69 } // anonymous namespace
70 70
71 class MessageLoopRelay 71 class MessageLoopRelay
72 : public base::RefCountedThreadSafe<MessageLoopRelay> { 72 : public base::RefCountedThreadSafe<MessageLoopRelay> {
73 public: 73 public:
74 MessageLoopRelay() 74 MessageLoopRelay()
75 : origin_message_loop_proxy_( 75 : origin_message_loop_proxy_(
76 base::MessageLoopProxy::CreateForCurrentThread()), 76 base::MessageLoopProxy::CreateForCurrentThread()),
77 error_code_(base::PLATFORM_FILE_OK) { 77 error_code_(base::PLATFORM_FILE_OK) {
78 } 78 }
79 79
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 set_error_code(base::PLATFORM_FILE_ERROR_NOT_FOUND); 435 set_error_code(base::PLATFORM_FILE_ERROR_NOT_FOUND);
436 return; 436 return;
437 } 437 }
438 438
439 file_util::FileEnumerator file_enum( 439 file_util::FileEnumerator file_enum(
440 file_path_, false, static_cast<file_util::FileEnumerator::FILE_TYPE>( 440 file_path_, false, static_cast<file_util::FileEnumerator::FILE_TYPE>(
441 file_util::FileEnumerator::FILES | 441 file_util::FileEnumerator::FILES |
442 file_util::FileEnumerator::DIRECTORIES)); 442 file_util::FileEnumerator::DIRECTORIES));
443 FilePath current; 443 FilePath current;
444 while (!(current = file_enum.Next()).empty()) { 444 while (!(current = file_enum.Next()).empty()) {
445 base::file_util_proxy::Entry entry; 445 base::FileUtilProxy::Entry entry;
446 file_util::FileEnumerator::FindInfo info; 446 file_util::FileEnumerator::FindInfo info;
447 file_enum.GetFindInfo(&info); 447 file_enum.GetFindInfo(&info);
448 entry.is_directory = file_enum.IsDirectory(info); 448 entry.is_directory = file_enum.IsDirectory(info);
449 // This will just give the entry's name instead of entire path 449 // This will just give the entry's name instead of entire path
450 // if we use current.value(). 450 // if we use current.value().
451 entry.name = file_util::FileEnumerator::GetFilename(info).value(); 451 entry.name = file_util::FileEnumerator::GetFilename(info).value();
452 entries_.push_back(entry); 452 entries_.push_back(entry);
453 } 453 }
454 } 454 }
455 455
456 virtual void RunCallback() { 456 virtual void RunCallback() {
457 callback_->Run(error_code(), entries_); 457 callback_->Run(error_code(), entries_);
458 delete callback_; 458 delete callback_;
459 } 459 }
460 460
461 private: 461 private:
462 base::FileUtilProxy::ReadDirectoryCallback* callback_; 462 base::FileUtilProxy::ReadDirectoryCallback* callback_;
463 FilePath file_path_; 463 FilePath file_path_;
464 std::vector<base::file_util_proxy::Entry> entries_; 464 std::vector<base::FileUtilProxy::Entry> entries_;
465 }; 465 };
466 466
467 class RelayGetFileInfo : public MessageLoopRelay { 467 class RelayGetFileInfo : public MessageLoopRelay {
468 public: 468 public:
469 RelayGetFileInfo(const FilePath& file_path, 469 RelayGetFileInfo(const FilePath& file_path,
470 base::FileUtilProxy::GetFileInfoCallback* callback) 470 base::FileUtilProxy::GetFileInfoCallback* callback)
471 : callback_(callback), 471 : callback_(callback),
472 file_path_(file_path) { 472 file_path_(file_path) {
473 DCHECK(callback); 473 DCHECK(callback);
474 } 474 }
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 908
909 // static 909 // static
910 bool FileUtilProxy::Flush( 910 bool FileUtilProxy::Flush(
911 scoped_refptr<MessageLoopProxy> message_loop_proxy, 911 scoped_refptr<MessageLoopProxy> message_loop_proxy,
912 PlatformFile file, 912 PlatformFile file,
913 StatusCallback* callback) { 913 StatusCallback* callback) {
914 return Start(FROM_HERE, message_loop_proxy, new RelayFlush(file, callback)); 914 return Start(FROM_HERE, message_loop_proxy, new RelayFlush(file, callback));
915 } 915 }
916 916
917 } // namespace base 917 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698