diff options
author | ericu@google.com <ericu@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-28 22:26:50 +0000 |
---|---|---|
committer | ericu@google.com <ericu@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-28 22:26:50 +0000 |
commit | bacef3cbbc55efebb2573194d329eabac5f5c7e3 (patch) | |
tree | caa96791f328bb36601bcb839e6544f3cfdf8290 /webkit/fileapi | |
parent | 748ce719f7594754695dfbd17b35618a58a5ffd1 (diff) | |
download | chromium_src-bacef3cbbc55efebb2573194d329eabac5f5c7e3.zip chromium_src-bacef3cbbc55efebb2573194d329eabac5f5c7e3.tar.gz chromium_src-bacef3cbbc55efebb2573194d329eabac5f5c7e3.tar.bz2 |
Remove the path from PlatformFileInfo; it's cleaner just to pass it along as a
separate parameter, and not clutter up a base type.
BUG:none
TEST:none
Review URL: http://codereview.chromium.org/6731033
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79624 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi')
-rw-r--r-- | webkit/fileapi/file_system_callback_dispatcher.h | 4 | ||||
-rw-r--r-- | webkit/fileapi/file_system_file_util.cc | 5 | ||||
-rw-r--r-- | webkit/fileapi/file_system_file_util.h | 4 | ||||
-rw-r--r-- | webkit/fileapi/file_system_file_util_proxy.cc | 5 | ||||
-rw-r--r-- | webkit/fileapi/file_system_file_util_proxy.h | 7 | ||||
-rw-r--r-- | webkit/fileapi/file_system_operation.cc | 11 | ||||
-rw-r--r-- | webkit/fileapi/file_system_operation.h | 9 | ||||
-rw-r--r-- | webkit/fileapi/file_system_operation_unittest.cc | 16 | ||||
-rw-r--r-- | webkit/fileapi/local_file_system_file_util.cc | 5 | ||||
-rw-r--r-- | webkit/fileapi/local_file_system_file_util.h | 4 |
10 files changed, 49 insertions, 21 deletions
diff --git a/webkit/fileapi/file_system_callback_dispatcher.h b/webkit/fileapi/file_system_callback_dispatcher.h index e5265bd..2bffe54 100644 --- a/webkit/fileapi/file_system_callback_dispatcher.h +++ b/webkit/fileapi/file_system_callback_dispatcher.h @@ -22,7 +22,9 @@ class FileSystemCallbackDispatcher { virtual void DidSucceed() = 0; // Callback to report information for a file. - virtual void DidReadMetadata(const base::PlatformFileInfo& file_info) = 0; + virtual void DidReadMetadata( + const base::PlatformFileInfo& file_info, + const FilePath& platform_path) = 0; // Callback to report the contents of a directory. If the contents of // the given directory are reported in one batch, then |entries| will have diff --git a/webkit/fileapi/file_system_file_util.cc b/webkit/fileapi/file_system_file_util.cc index 10af22f..1dceed2 100644 --- a/webkit/fileapi/file_system_file_util.cc +++ b/webkit/fileapi/file_system_file_util.cc @@ -61,12 +61,13 @@ PlatformFileError FileSystemFileUtil::EnsureFileExists( PlatformFileError FileSystemFileUtil::GetFileInfo( FileSystemOperationContext* unused, const FilePath& file_path, - base::PlatformFileInfo* file_info) { + base::PlatformFileInfo* file_info, + FilePath* platform_file_path) { if (!file_util::PathExists(file_path)) return base::PLATFORM_FILE_ERROR_NOT_FOUND; if (!file_util::GetFileInfo(file_path, file_info)) return base::PLATFORM_FILE_ERROR_FAILED; - file_info->path = file_path; + *platform_file_path = file_path; return base::PLATFORM_FILE_OK; } diff --git a/webkit/fileapi/file_system_file_util.h b/webkit/fileapi/file_system_file_util.h index 620ff09..a208ae4 100644 --- a/webkit/fileapi/file_system_file_util.h +++ b/webkit/fileapi/file_system_file_util.h @@ -68,7 +68,9 @@ class FileSystemFileUtil { // callback. virtual PlatformFileError GetFileInfo( FileSystemOperationContext* context, - const FilePath& file_, base::PlatformFileInfo* file_info); + const FilePath& file_, + base::PlatformFileInfo* file_info, + FilePath* platform_path); virtual PlatformFileError ReadDirectory( FileSystemOperationContext* context, diff --git a/webkit/fileapi/file_system_file_util_proxy.cc b/webkit/fileapi/file_system_file_util_proxy.cc index faf3d4a..0f88ff0 100644 --- a/webkit/fileapi/file_system_file_util_proxy.cc +++ b/webkit/fileapi/file_system_file_util_proxy.cc @@ -208,11 +208,11 @@ class RelayGetFileInfo : public MessageLoopRelay { virtual void RunWork() { set_error_code( file_system_file_util()->GetFileInfo( - context(), file_path_, &file_info_)); + context(), file_path_, &file_info_, &platform_path_)); } virtual void RunCallback() { - callback_->Run(error_code(), file_info_); + callback_->Run(error_code(), file_info_, platform_path_); delete callback_; } @@ -220,6 +220,7 @@ class RelayGetFileInfo : public MessageLoopRelay { fileapi::FileSystemFileUtilProxy::GetFileInfoCallback* callback_; FilePath file_path_; base::PlatformFileInfo file_info_; + FilePath platform_path_; }; class RelayReadDirectory : public MessageLoopRelay { diff --git a/webkit/fileapi/file_system_file_util_proxy.h b/webkit/fileapi/file_system_file_util_proxy.h index 288d4cf..de4b320 100644 --- a/webkit/fileapi/file_system_file_util_proxy.h +++ b/webkit/fileapi/file_system_file_util_proxy.h @@ -25,6 +25,8 @@ class FileSystemOperationContext; using base::MessageLoopProxy; using base::PlatformFile; +using base::PlatformFileError; +using base::PlatformFileInfo; // This class provides asynchronous access to common file routines for the // FileSystem API. @@ -34,7 +36,10 @@ class FileSystemFileUtilProxy { typedef base::FileUtilProxy::CreateOrOpenCallback CreateOrOpenCallback; typedef base::FileUtilProxy::EnsureFileExistsCallback EnsureFileExistsCallback; - typedef base::FileUtilProxy::GetFileInfoCallback GetFileInfoCallback; + typedef Callback3<PlatformFileError /* error code */, + const PlatformFileInfo& /* file_info */, + const FilePath& /* platform_path, where possible */ + >::Type GetFileInfoCallback; typedef base::FileUtilProxy::ReadDirectoryCallback ReadDirectoryCallback; // Creates or opens a file with the given flags. It is invalid to pass NULL diff --git a/webkit/fileapi/file_system_operation.cc b/webkit/fileapi/file_system_operation.cc index 1555cd7..4ddfd0c 100644 --- a/webkit/fileapi/file_system_operation.cc +++ b/webkit/fileapi/file_system_operation.cc @@ -454,7 +454,8 @@ void FileSystemOperation::DidFinishFileOperation( void FileSystemOperation::DidDirectoryExists( base::PlatformFileError rv, - const base::PlatformFileInfo& file_info) { + const base::PlatformFileInfo& file_info, + const FilePath& unused) { if (rv == base::PLATFORM_FILE_OK) { if (file_info.is_directory) dispatcher_->DidSucceed(); @@ -468,7 +469,8 @@ void FileSystemOperation::DidDirectoryExists( void FileSystemOperation::DidFileExists( base::PlatformFileError rv, - const base::PlatformFileInfo& file_info) { + const base::PlatformFileInfo& file_info, + const FilePath& unused) { if (rv == base::PLATFORM_FILE_OK) { if (file_info.is_directory) dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_NOT_A_FILE); @@ -482,9 +484,10 @@ void FileSystemOperation::DidFileExists( void FileSystemOperation::DidGetMetadata( base::PlatformFileError rv, - const base::PlatformFileInfo& file_info) { + const base::PlatformFileInfo& file_info, + const FilePath& platform_path) { if (rv == base::PLATFORM_FILE_OK) - dispatcher_->DidReadMetadata(file_info); + dispatcher_->DidReadMetadata(file_info, platform_path); else dispatcher_->DidFail(rv); delete this; diff --git a/webkit/fileapi/file_system_operation.h b/webkit/fileapi/file_system_operation.h index 719ac8e..f6d2016 100644 --- a/webkit/fileapi/file_system_operation.h +++ b/webkit/fileapi/file_system_operation.h @@ -112,11 +112,14 @@ class FileSystemOperation { void DidFinishFileOperation(base::PlatformFileError rv); void DidDirectoryExists(base::PlatformFileError rv, - const base::PlatformFileInfo& file_info); + const base::PlatformFileInfo& file_info, + const FilePath& unused); void DidFileExists(base::PlatformFileError rv, - const base::PlatformFileInfo& file_info); + const base::PlatformFileInfo& file_info, + const FilePath& unused); void DidGetMetadata(base::PlatformFileError rv, - const base::PlatformFileInfo& file_info); + const base::PlatformFileInfo& file_info, + const FilePath& platform_path); void DidReadDirectory( base::PlatformFileError rv, const std::vector<base::FileUtilProxy::Entry>& entries); diff --git a/webkit/fileapi/file_system_operation_unittest.cc b/webkit/fileapi/file_system_operation_unittest.cc index 5641923..9cd128c 100644 --- a/webkit/fileapi/file_system_operation_unittest.cc +++ b/webkit/fileapi/file_system_operation_unittest.cc @@ -43,6 +43,8 @@ class FileSystemOperationTest : public testing::Test { int status() const { return status_; } void set_info(const base::PlatformFileInfo& info) { info_ = info; } const base::PlatformFileInfo& info() const { return info_; } + void set_path(const FilePath& path) { path_ = path; } + const FilePath& path() const { return path_; } void set_entries(const std::vector<base::FileUtilProxy::Entry>& entries) { entries_ = entries; } @@ -57,6 +59,7 @@ class FileSystemOperationTest : public testing::Test { // For post-operation status. int status_; base::PlatformFileInfo info_; + FilePath path_; std::vector<base::FileUtilProxy::Entry> entries_; DISALLOW_COPY_AND_ASSIGN(FileSystemOperationTest); @@ -74,8 +77,11 @@ class MockDispatcher : public FileSystemCallbackDispatcher { test_->set_status(kFileOperationSucceeded); } - virtual void DidReadMetadata(const base::PlatformFileInfo& info) { + virtual void DidReadMetadata( + const base::PlatformFileInfo& info, + const FilePath& platform_path) { test_->set_info(info); + test_->set_path(platform_path); test_->set_status(kFileOperationSucceeded); } @@ -564,6 +570,7 @@ TEST_F(FileSystemOperationTest, TestExistsAndMetadataSuccess) { MessageLoop::current()->RunAllPending(); EXPECT_EQ(kFileOperationSucceeded, status()); EXPECT_TRUE(info().is_directory); + EXPECT_EQ(dir.path(), path()); FilePath file; file_util::CreateTemporaryFileInDir(dir.path(), &file); @@ -575,6 +582,7 @@ TEST_F(FileSystemOperationTest, TestExistsAndMetadataSuccess) { MessageLoop::current()->RunAllPending(); EXPECT_EQ(kFileOperationSucceeded, status()); EXPECT_FALSE(info().is_directory); + EXPECT_EQ(file, path()); } TEST_F(FileSystemOperationTest, TestTypeMismatchErrors) { @@ -592,9 +600,9 @@ TEST_F(FileSystemOperationTest, TestTypeMismatchErrors) { } TEST_F(FileSystemOperationTest, TestReadDirFailure) { - // Path doesn't exists - FilePath nonexisting_dir_path(base_.path().Append( - FILE_PATH_LITERAL("NonExistingDir"))); + // Path doesn't exist + FilePath nonexisting_dir_path(base_.path().Append( + FILE_PATH_LITERAL("NonExistingDir"))); file_util::EnsureEndsWithSeparator(&nonexisting_dir_path); operation()->ReadDirectory(nonexisting_dir_path); MessageLoop::current()->RunAllPending(); diff --git a/webkit/fileapi/local_file_system_file_util.cc b/webkit/fileapi/local_file_system_file_util.cc index 8def3f6..068a052 100644 --- a/webkit/fileapi/local_file_system_file_util.cc +++ b/webkit/fileapi/local_file_system_file_util.cc @@ -47,14 +47,15 @@ PlatformFileError LocalFileSystemFileUtil::EnsureFileExists( PlatformFileError LocalFileSystemFileUtil::GetFileInfo( FileSystemOperationContext* context, const FilePath& file_path, - base::PlatformFileInfo* file_info) { + base::PlatformFileInfo* file_info, + FilePath* platform_file_path) { FilePath local_path = GetLocalPath(context, context->src_origin_url(), context->src_type(), file_path); if (local_path.empty()) return base::PLATFORM_FILE_ERROR_INVALID_OPERATION; return FileSystemFileUtil::GetInstance()->GetFileInfo( - context, local_path, file_info); + context, local_path, file_info, platform_file_path); } PlatformFileError LocalFileSystemFileUtil::ReadDirectory( diff --git a/webkit/fileapi/local_file_system_file_util.h b/webkit/fileapi/local_file_system_file_util.h index 428b157..3e5855a 100644 --- a/webkit/fileapi/local_file_system_file_util.h +++ b/webkit/fileapi/local_file_system_file_util.h @@ -51,7 +51,9 @@ class LocalFileSystemFileUtil : public FileSystemFileUtil { virtual PlatformFileError GetFileInfo( FileSystemOperationContext* context, - const FilePath& file_, base::PlatformFileInfo* file_info); + const FilePath& file_, + base::PlatformFileInfo* file_info, + FilePath* platform_file); virtual PlatformFileError ReadDirectory( FileSystemOperationContext* context, |