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 | |
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
-rw-r--r-- | chrome/browser/bookmarks/bookmark_html_writer.cc | 8 | ||||
-rw-r--r-- | chrome/common/unzip.cc | 2 | ||||
-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 |
8 files changed, 19 insertions, 14 deletions
diff --git a/chrome/browser/bookmarks/bookmark_html_writer.cc b/chrome/browser/bookmarks/bookmark_html_writer.cc index cb5cf87..bb39ebe 100644 --- a/chrome/browser/bookmarks/bookmark_html_writer.cc +++ b/chrome/browser/bookmarks/bookmark_html_writer.cc @@ -4,6 +4,7 @@ #include "chrome/browser/bookmarks/bookmark_html_writer.h" +#include "base/file_path.h" #include "base/file_util.h" #include "base/message_loop.h" #include "base/platform_file.h" @@ -71,7 +72,7 @@ const size_t kIndentSize = 4; // Class responsible for the actual writing. class Writer : public Task { public: - Writer(Value* bookmarks, const std::wstring& path) + Writer(Value* bookmarks, const FilePath& path) : bookmarks_(bookmarks), path_(path) { } @@ -300,7 +301,7 @@ class Writer : public Task { scoped_ptr<Value> bookmarks_; // Path we're writing to. - std::wstring path_; + FilePath path_; // File we're writing to. net::FileStream file_stream_; @@ -319,7 +320,8 @@ void WriteBookmarks(MessageLoop* thread, // for the duration of the write), as such we make a copy of the // BookmarkModel using BookmarkCodec then write from that. BookmarkCodec codec; - scoped_ptr<Writer> writer(new Writer(codec.Encode(model), path)); + scoped_ptr<Writer> writer(new Writer(codec.Encode(model), + FilePath::FromWStringHack(path))); if (thread) thread->PostTask(FROM_HERE, writer.release()); else diff --git a/chrome/common/unzip.cc b/chrome/common/unzip.cc index 4295a21..b59ae8e 100644 --- a/chrome/common/unzip.cc +++ b/chrome/common/unzip.cc @@ -62,7 +62,7 @@ static bool ExtractCurrentFile(unzFile zip_file, net::FileStream stream; int flags = base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_WRITE; - if (stream.Open(dest_file.ToWStringHack(), flags) != 0) + if (stream.Open(dest_file, flags) != 0) return false; bool ret = true; 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) { |