diff options
author | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-26 21:38:11 +0000 |
---|---|---|
committer | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-26 21:38:11 +0000 |
commit | 07167e8f26d8c0272dd528944f0d105aa2962bab (patch) | |
tree | 4afb3d77169a9f1ac873a86cb3eafa824d6e47a0 /net | |
parent | 25a873babf94d9e1647a9722d313b4e52286220d (diff) | |
download | chromium_src-07167e8f26d8c0272dd528944f0d105aa2962bab.zip chromium_src-07167e8f26d8c0272dd528944f0d105aa2962bab.tar.gz chromium_src-07167e8f26d8c0272dd528944f0d105aa2962bab.tar.bz2 |
Change FileStream to use FilePath instead of wstring.
Review URL: http://codereview.chromium.org/18764
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8663 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/file_stream.h | 3 | ||||
-rw-r--r-- | net/base/file_stream_posix.cc | 4 | ||||
-rw-r--r-- | net/base/file_stream_unittest.cc | 7 | ||||
-rw-r--r-- | net/base/file_stream_win.cc | 4 | ||||
-rw-r--r-- | net/base/upload_data_stream.cc | 3 | ||||
-rw-r--r-- | net/url_request/url_request_file_job.cc | 2 |
6 files changed, 13 insertions, 10 deletions
diff --git a/net/base/file_stream.h b/net/base/file_stream.h index ccdcf80..67f93ed 100644 --- a/net/base/file_stream.h +++ b/net/base/file_stream.h @@ -10,6 +10,7 @@ #ifndef NET_BASE_FILE_STREAM_H_ #define NET_BASE_FILE_STREAM_H_ +#include "base/file_path.h" #include "base/platform_file.h" #include "net/base/completion_callback.h" @@ -37,7 +38,7 @@ class FileStream { // cannot be used unless this method returns OK. If the file cannot be // opened then an error code is returned. // open_flags is a bitfield of base::PlatformFileFlags - int Open(const std::wstring& path, int open_flags); + int Open(const FilePath& path, int open_flags); // Returns true if Open succeeded and Close has not been called. bool IsOpen() const; diff --git a/net/base/file_stream_posix.cc b/net/base/file_stream_posix.cc index 53589166..abef9c2 100644 --- a/net/base/file_stream_posix.cc +++ b/net/base/file_stream_posix.cc @@ -74,14 +74,14 @@ static int64 MapErrorCode(int err) { } } -int FileStream::Open(const std::wstring& path, int open_flags) { +int FileStream::Open(const FilePath& path, int open_flags) { if (IsOpen()) { DLOG(FATAL) << "File is already open!"; return ERR_UNEXPECTED; } open_flags_ = open_flags; - file_ = base::CreatePlatformFile(path, open_flags_, NULL); + file_ = base::CreatePlatformFile(path.ToWStringHack(), open_flags_, NULL); if (file_ == base::kInvalidPlatformFileValue) { LOG(WARNING) << "Failed to open file: " << errno; return MapErrorCode(errno); diff --git a/net/base/file_stream_unittest.cc b/net/base/file_stream_unittest.cc index d970175..abee897 100644 --- a/net/base/file_stream_unittest.cc +++ b/net/base/file_stream_unittest.cc @@ -19,16 +19,17 @@ class FileStreamTest : public PlatformTest { PlatformTest::SetUp(); file_util::CreateTemporaryFileName(&temp_file_path_); - file_util::WriteFile(temp_file_path_, kTestData, kTestDataSize); + file_util::WriteFile(temp_file_path_.ToWStringHack(), + kTestData, kTestDataSize); } virtual void TearDown() { file_util::Delete(temp_file_path_, false); PlatformTest::TearDown(); } - const std::wstring temp_file_path() const { return temp_file_path_; } + const FilePath temp_file_path() const { return temp_file_path_; } private: - std::wstring temp_file_path_; + FilePath temp_file_path_; }; TEST_F(FileStreamTest, BasicOpenClose) { diff --git a/net/base/file_stream_win.cc b/net/base/file_stream_win.cc index 56d0368..d70b398 100644 --- a/net/base/file_stream_win.cc +++ b/net/base/file_stream_win.cc @@ -125,14 +125,14 @@ void FileStream::Close() { } } -int FileStream::Open(const std::wstring& path, int open_flags) { +int FileStream::Open(const FilePath& path, int open_flags) { if (IsOpen()) { DLOG(FATAL) << "File is already open!"; return ERR_UNEXPECTED; } open_flags_ = open_flags; - file_ = base::CreatePlatformFile(path, open_flags_, NULL); + file_ = base::CreatePlatformFile(path.value(), open_flags_, NULL); if (file_ == INVALID_HANDLE_VALUE) { DWORD error = GetLastError(); LOG(WARNING) << "Failed to open file: " << error; diff --git a/net/base/upload_data_stream.cc b/net/base/upload_data_stream.cc index c25ccba..d872002 100644 --- a/net/base/upload_data_stream.cc +++ b/net/base/upload_data_stream.cc @@ -65,7 +65,8 @@ void UploadDataStream::FillBuf() { if (!next_element_stream_.IsOpen()) { int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ; - int rv = next_element_stream_.Open(element.file_path(), flags); + int rv = next_element_stream_.Open( + FilePath::FromWStringHack(element.file_path()), flags); // If the file does not exist, that's technically okay.. we'll just // upload an empty file. This is for consistency with Mozilla. DLOG_IF(WARNING, rv != OK) << "Failed to open \"" << diff --git a/net/url_request/url_request_file_job.cc b/net/url_request/url_request_file_job.cc index 994a58c..93bda90 100644 --- a/net/url_request/url_request_file_job.cc +++ b/net/url_request/url_request_file_job.cc @@ -172,7 +172,7 @@ void URLRequestFileJob::DidResolve( int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ | base::PLATFORM_FILE_ASYNC; - rv = stream_.Open(file_path_.ToWStringHack(), flags); + rv = stream_.Open(file_path_, flags); } if (rv == net::OK) { |