diff options
author | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-08 22:32:07 +0000 |
---|---|---|
committer | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-08 22:32:07 +0000 |
commit | 5ab2191f4bf80656bdec435141531f18c07859c4 (patch) | |
tree | 3f458c1f9cbba24a530cf2f1d4965c7e65517376 | |
parent | 2098fc80beaf21ef93d7fe3e886d185ce871b423 (diff) | |
download | chromium_src-5ab2191f4bf80656bdec435141531f18c07859c4.zip chromium_src-5ab2191f4bf80656bdec435141531f18c07859c4.tar.gz chromium_src-5ab2191f4bf80656bdec435141531f18c07859c4.tar.bz2 |
Back out r121064 from the trunk due to a compile failure.
http://build.chromium.org/p/chromium.chromiumos/builders/Linux%20ChromiumOS%20Builder%20%28dbg%29/builds/16/steps/compile/logs/stdio
net: Rename FileStream::Open/Close with OpenSync/CloseSync.
This is in preparation for implementing async versions of Open()
and Close().
The existing clients are changed to use OpenSync/CloseSync.
No logic is changed.
TEST=try bots to confirm everythign is built as before.
BUG=72001
Review URL: http://codereview.chromium.org/9349005
TBR=satorux@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9363036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121075 0039d316-1c4b-4281-b951-d872f2087c98
25 files changed, 85 insertions, 91 deletions
diff --git a/chrome/browser/bookmarks/bookmark_html_writer.cc b/chrome/browser/bookmarks/bookmark_html_writer.cc index 5a6d670..8ab2de4 100644 --- a/chrome/browser/bookmarks/bookmark_html_writer.cc +++ b/chrome/browser/bookmarks/bookmark_html_writer.cc @@ -145,7 +145,7 @@ class Writer : public base::RefCountedThreadSafe<Writer> { Write(kFolderChildrenEnd); Write(kNewline); // File stream close is forced so that unit test could read it. - file_stream_.CloseSync(); + file_stream_.Close(); NotifyOnFinish(); } @@ -165,7 +165,7 @@ class Writer : public base::RefCountedThreadSafe<Writer> { // Opens the file, returning true on success. bool OpenFile() { int flags = base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_WRITE; - return (file_stream_.OpenSync(path_, flags) == net::OK); + return (file_stream_.Open(path_, flags) == net::OK); } // Increments the indent. diff --git a/chrome/browser/safe_browsing/bloom_filter.cc b/chrome/browser/safe_browsing/bloom_filter.cc index 6f928b5..c21c1c0 100644 --- a/chrome/browser/safe_browsing/bloom_filter.cc +++ b/chrome/browser/safe_browsing/bloom_filter.cc @@ -90,9 +90,9 @@ bool BloomFilter::Exists(SBPrefix hash) const { BloomFilter* BloomFilter::LoadFile(const FilePath& filter_name) { net::FileStream filter(NULL); - if (filter.OpenSync(filter_name, - base::PLATFORM_FILE_OPEN | - base::PLATFORM_FILE_READ) != net::OK) { + if (filter.Open(filter_name, + base::PLATFORM_FILE_OPEN | + base::PLATFORM_FILE_READ) != net::OK) { RecordFailure(FAILURE_FILTER_READ_OPEN); return NULL; } @@ -156,9 +156,9 @@ BloomFilter* BloomFilter::LoadFile(const FilePath& filter_name) { bool BloomFilter::WriteFile(const FilePath& filter_name) const { net::FileStream filter(NULL); - if (filter.OpenSync(filter_name, - base::PLATFORM_FILE_WRITE | - base::PLATFORM_FILE_CREATE_ALWAYS) != net::OK) + if (filter.Open(filter_name, + base::PLATFORM_FILE_WRITE | + base::PLATFORM_FILE_CREATE_ALWAYS) != net::OK) return false; // Write the version information. diff --git a/chrome/browser/sessions/session_backend.cc b/chrome/browser/sessions/session_backend.cc index 419678e..ba9f9ad 100644 --- a/chrome/browser/sessions/session_backend.cc +++ b/chrome/browser/sessions/session_backend.cc @@ -48,8 +48,7 @@ class SessionFileReader { available_count_(0) { file_.reset(new net::FileStream(NULL)); if (file_util::PathExists(path)) - file_->OpenSync(path, - base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ); + file_->Open(path, base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ); } // Reads the contents of the file specified in the constructor, returning // true on success. It is up to the caller to free all SessionCommands @@ -348,7 +347,7 @@ SessionBackend::~SessionBackend() { if (current_session_file_.get()) { // Close() performs file IO. crbug.com/112512. base::ThreadRestrictions::ScopedAllowIO allow_io; - current_session_file_->CloseSync(); + current_session_file_->Close(); } } @@ -371,7 +370,7 @@ void SessionBackend::ResetFile() { net::FileStream* SessionBackend::OpenAndWriteHeader(const FilePath& path) { DCHECK(!path.empty()); scoped_ptr<net::FileStream> file(new net::FileStream(NULL)); - if (file->OpenSync(path, base::PLATFORM_FILE_CREATE_ALWAYS | + if (file->Open(path, base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_EXCLUSIVE_WRITE | base::PLATFORM_FILE_EXCLUSIVE_READ) != net::OK) return NULL; diff --git a/chrome/browser/themes/browser_theme_pack.cc b/chrome/browser/themes/browser_theme_pack.cc index 5daf9f7..28c5db2 100644 --- a/chrome/browser/themes/browser_theme_pack.cc +++ b/chrome/browser/themes/browser_theme_pack.cc @@ -288,7 +288,7 @@ RefCountedMemory* ReadFileData(const FilePath& path) { if (!path.empty()) { net::FileStream file(NULL); int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ; - if (file.OpenSync(path, flags) == net::OK) { + if (file.Open(path, flags) == net::OK) { int64 avail = file.Available(); if (avail > 0 && avail < INT_MAX) { size_t size = static_cast<size_t>(avail); diff --git a/chrome/common/zip.cc b/chrome/common/zip.cc index 1da9cff..a5635c0 100644 --- a/chrome/common/zip.cc +++ b/chrome/common/zip.cc @@ -20,7 +20,7 @@ namespace { bool AddFileToZip(zipFile zip_file, const FilePath& src_dir) { net::FileStream stream(NULL); int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ; - if (stream.OpenSync(src_dir, flags) != 0) { + if (stream.Open(src_dir, flags) != 0) { DLOG(ERROR) << "Could not open stream for path " << src_dir.value(); return false; diff --git a/chrome/common/zip_reader.cc b/chrome/common/zip_reader.cc index c89ce29..60fba5e 100644 --- a/chrome/common/zip_reader.cc +++ b/chrome/common/zip_reader.cc @@ -193,7 +193,7 @@ bool ZipReader::ExtractCurrentEntryToFilePath( net::FileStream stream(NULL); const int flags = (base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_WRITE); - if (stream.OpenSync(output_file_path, flags) != 0) + if (stream.Open(output_file_path, flags) != 0) return false; bool success = true; // This becomes false when something bad happens. @@ -218,7 +218,7 @@ bool ZipReader::ExtractCurrentEntryToFilePath( } } - stream.CloseSync(); + stream.Close(); unzCloseCurrentFile(zip_file_); return success; } diff --git a/content/browser/download/base_file.cc b/content/browser/download/base_file.cc index 51ff531..74e9b95 100644 --- a/content/browser/download/base_file.cc +++ b/content/browser/download/base_file.cc @@ -502,7 +502,7 @@ net::Error BaseFile::Open() { if (!file_stream_.get()) { CreateFileStream(); file_stream_->EnableErrorStatistics(); - int open_result = file_stream_->OpenSync( + int open_result = file_stream_->Open( full_path_, base::PLATFORM_FILE_OPEN_ALWAYS | base::PLATFORM_FILE_WRITE); if (open_result != net::OK) @@ -535,7 +535,7 @@ void BaseFile::Close() { // theres not much we can do. But we might in the future. file_stream_->Flush(); #endif - file_stream_->CloseSync(); + file_stream_->Close(); ClearStream(net::OK); } } diff --git a/content/browser/download/base_file_unittest.cc b/content/browser/download/base_file_unittest.cc index a25ba60..2ed3b9d 100644 --- a/content/browser/download/base_file_unittest.cc +++ b/content/browser/download/base_file_unittest.cc @@ -121,7 +121,7 @@ class BaseFileTest : public testing::Test { // Create a new file stream. mock_file_stream_.reset(new net::testing::MockFileStream(NULL)); - if (mock_file_stream_->OpenSync( + if (mock_file_stream_->Open( path, base::PLATFORM_FILE_OPEN_ALWAYS | base::PLATFORM_FILE_WRITE) != 0) { mock_file_stream_.reset(); diff --git a/content/browser/download/download_manager_impl_unittest.cc b/content/browser/download/download_manager_impl_unittest.cc index a86e9e1..323e267 100644 --- a/content/browser/download/download_manager_impl_unittest.cc +++ b/content/browser/download/download_manager_impl_unittest.cc @@ -1010,7 +1010,7 @@ TEST_F(DownloadManagerTest, MAYBE_DownloadFileErrorTest) { // This file stream will be used, until the first rename occurs. net::FileStream* stream = new net::FileStream(NULL); - ASSERT_EQ(0, stream->OpenSync( + ASSERT_EQ(0, stream->Open( path, base::PLATFORM_FILE_OPEN_ALWAYS | base::PLATFORM_FILE_WRITE)); diff --git a/content/browser/download/drag_download_util.cc b/content/browser/download/drag_download_util.cc index 5f3f194..ed781bb 100644 --- a/content/browser/download/drag_download_util.cc +++ b/content/browser/download/drag_download_util.cc @@ -80,7 +80,7 @@ FileStream* CreateFileStreamForDrop(FilePath* file_path) { // Explicitly (and redundantly check) for file -- despite the fact that our // open won't overwrite -- just to avoid log spew. if (!file_util::PathExists(new_file_path) && - file_stream->OpenSync(new_file_path, base::PLATFORM_FILE_CREATE | + file_stream->Open(new_file_path, base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_WRITE) == net::OK) { *file_path = new_file_path; return file_stream.release(); diff --git a/content/browser/renderer_host/redirect_to_file_resource_handler.cc b/content/browser/renderer_host/redirect_to_file_resource_handler.cc index 8ebba69..64e007b 100644 --- a/content/browser/renderer_host/redirect_to_file_resource_handler.cc +++ b/content/browser/renderer_host/redirect_to_file_resource_handler.cc @@ -141,7 +141,7 @@ void RedirectToFileResourceHandler::OnRequestClosed() { // directly from a PlatformFile. // Close() performs file IO. crbug.com/112474. base::ThreadRestrictions::ScopedAllowIO allow_io; - file_stream_->CloseSync(); + file_stream_->Close(); file_stream_.reset(); } deletable_file_ = NULL; diff --git a/content/browser/tab_contents/web_drag_source_mac.mm b/content/browser/tab_contents/web_drag_source_mac.mm index 1ffd221..ba84e6d 100644 --- a/content/browser/tab_contents/web_drag_source_mac.mm +++ b/content/browser/tab_contents/web_drag_source_mac.mm @@ -81,7 +81,7 @@ void PromiseWriterHelper(const WebDropData& drop_data, net::CompletionCallback()); if (file_stream) - file_stream->CloseSync(); + file_stream->Close(); } } // namespace diff --git a/net/base/file_stream.h b/net/base/file_stream.h index 39863a5..a50d9c0 100644 --- a/net/base/file_stream.h +++ b/net/base/file_stream.h @@ -47,20 +47,16 @@ class NET_EXPORT FileStream { virtual ~FileStream(); - // Call this method to close the FileStream synchronously. - // It is OK to call Close multiple times. Redundant calls are ignored. + // Call this method to close the FileStream. It is OK to call Close + // multiple times. Redundant calls are ignored. // Note that if there are any pending async operations, they'll be aborted. - // - // TODO(satorux): Implement the asynchronous version of this. - virtual void CloseSync(); + virtual void Close(); - // Call this method to open the FileStream synchronously. - // The remaining methods 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 - // - // TODO(satorux): Implement the asynchronous version of this. - virtual int OpenSync(const FilePath& path, int open_flags); + // Call this method to open the FileStream. The remaining methods + // 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 + virtual int Open(const FilePath& path, int open_flags); // Returns true if Open succeeded and Close has not been called. virtual bool IsOpen() const; diff --git a/net/base/file_stream_posix.cc b/net/base/file_stream_posix.cc index 86f64ec..a094eed 100644 --- a/net/base/file_stream_posix.cc +++ b/net/base/file_stream_posix.cc @@ -341,12 +341,12 @@ FileStream::FileStream(base::PlatformFile file, int flags, net::NetLog* net_log) FileStream::~FileStream() { if (auto_closed_) - CloseSync(); + Close(); bound_net_log_.EndEvent(net::NetLog::TYPE_FILE_STREAM_ALIVE, NULL); } -void FileStream::CloseSync() { +void FileStream::Close() { bound_net_log_.AddEvent(net::NetLog::TYPE_FILE_STREAM_CLOSE, NULL); // Abort any existing asynchronous operations. @@ -361,7 +361,7 @@ void FileStream::CloseSync() { } } -int FileStream::OpenSync(const FilePath& path, int open_flags) { +int FileStream::Open(const FilePath& path, int open_flags) { if (IsOpen()) { DLOG(FATAL) << "File is already open!"; return ERR_UNEXPECTED; diff --git a/net/base/file_stream_unittest.cc b/net/base/file_stream_unittest.cc index a0500c1..c92ce9f 100644 --- a/net/base/file_stream_unittest.cc +++ b/net/base/file_stream_unittest.cc @@ -54,7 +54,7 @@ TEST_F(FileStreamTest, BasicOpenClose) { base::PlatformFile file = base::kInvalidPlatformFileValue; { FileStream stream(NULL); - int rv = stream.OpenSync(temp_file_path(), + int rv = stream.Open(temp_file_path(), base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ); EXPECT_EQ(OK, rv); EXPECT_TRUE(stream.IsOpen()); @@ -108,7 +108,7 @@ TEST_F(FileStreamTest, UseFileHandle) { ASSERT_EQ(kTestDataSize, read_stream.Read(buffer, kTestDataSize, CompletionCallback())); ASSERT_EQ(0, memcmp(kTestData, buffer, kTestDataSize)); - read_stream.CloseSync(); + read_stream.Close(); // 2. Test writing with a file handle. file_util::Delete(temp_file_path(), false); @@ -119,7 +119,7 @@ TEST_F(FileStreamTest, UseFileHandle) { ASSERT_EQ(0, write_stream.Seek(FROM_BEGIN, 0)); ASSERT_EQ(kTestDataSize, write_stream.Write(kTestData, kTestDataSize, CompletionCallback())); - write_stream.CloseSync(); + write_stream.Close(); // Read into buffer and compare to make sure the handle worked fine. ASSERT_EQ(kTestDataSize, @@ -154,7 +154,7 @@ TEST_F(FileStreamTest, BasicRead) { FileStream stream(NULL); int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ; - int rv = stream.OpenSync(temp_file_path(), flags); + int rv = stream.Open(temp_file_path(), flags); EXPECT_EQ(OK, rv); int64 total_bytes_avail = stream.Available(); @@ -185,7 +185,7 @@ TEST_F(FileStreamTest, AsyncRead) { int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ | base::PLATFORM_FILE_ASYNC; - int rv = stream.OpenSync(temp_file_path(), flags); + int rv = stream.Open(temp_file_path(), flags); EXPECT_EQ(OK, rv); int64 total_bytes_avail = stream.Available(); @@ -220,7 +220,7 @@ TEST_F(FileStreamTest, AsyncRead_EarlyClose) { int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ | base::PLATFORM_FILE_ASYNC; - int rv = stream.OpenSync(temp_file_path(), flags); + int rv = stream.Open(temp_file_path(), flags); EXPECT_EQ(OK, rv); int64 total_bytes_avail = stream.Available(); @@ -230,7 +230,7 @@ TEST_F(FileStreamTest, AsyncRead_EarlyClose) { char buf[4]; rv = stream.Read(buf, arraysize(buf), callback.callback()); - stream.CloseSync(); + stream.Close(); if (rv < 0) { EXPECT_EQ(ERR_IO_PENDING, rv); // The callback should not be called if the request is cancelled. @@ -249,7 +249,7 @@ TEST_F(FileStreamTest, BasicRead_FromOffset) { FileStream stream(NULL); int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ; - int rv = stream.OpenSync(temp_file_path(), flags); + int rv = stream.Open(temp_file_path(), flags); EXPECT_EQ(OK, rv); const int64 kOffset = 3; @@ -285,7 +285,7 @@ TEST_F(FileStreamTest, AsyncRead_FromOffset) { int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ | base::PLATFORM_FILE_ASYNC; - int rv = stream.OpenSync(temp_file_path(), flags); + int rv = stream.Open(temp_file_path(), flags); EXPECT_EQ(OK, rv); const int64 kOffset = 3; @@ -319,7 +319,7 @@ TEST_F(FileStreamTest, SeekAround) { FileStream stream(NULL); int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ; - int rv = stream.OpenSync(temp_file_path(), flags); + int rv = stream.Open(temp_file_path(), flags); EXPECT_EQ(OK, rv); const int64 kOffset = 3; @@ -342,7 +342,7 @@ TEST_F(FileStreamTest, BasicWrite) { FileStream stream(NULL); int flags = base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_WRITE; - int rv = stream.OpenSync(temp_file_path(), flags); + int rv = stream.Open(temp_file_path(), flags); EXPECT_EQ(OK, rv); int64 file_size; @@ -352,7 +352,7 @@ TEST_F(FileStreamTest, BasicWrite) { rv = stream.Write(kTestData, kTestDataSize, CompletionCallback()); EXPECT_EQ(kTestDataSize, rv); - stream.CloseSync(); + stream.Close(); ok = file_util::GetFileSize(temp_file_path(), &file_size); EXPECT_TRUE(ok); @@ -364,7 +364,7 @@ TEST_F(FileStreamTest, AsyncWrite) { int flags = base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_ASYNC; - int rv = stream.OpenSync(temp_file_path(), flags); + int rv = stream.Open(temp_file_path(), flags); EXPECT_EQ(OK, rv); int64 file_size; @@ -396,7 +396,7 @@ TEST_F(FileStreamTest, AsyncWrite_EarlyClose) { int flags = base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_ASYNC; - int rv = stream.OpenSync(temp_file_path(), flags); + int rv = stream.Open(temp_file_path(), flags); EXPECT_EQ(OK, rv); int64 file_size; @@ -410,7 +410,7 @@ TEST_F(FileStreamTest, AsyncWrite_EarlyClose) { rv = stream.Write(kTestData + total_bytes_written, kTestDataSize - total_bytes_written, callback.callback()); - stream.CloseSync(); + stream.Close(); if (rv < 0) { EXPECT_EQ(ERR_IO_PENDING, rv); // The callback should not be called if the request is cancelled. @@ -427,7 +427,7 @@ TEST_F(FileStreamTest, BasicWrite_FromOffset) { FileStream stream(NULL); int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE; - int rv = stream.OpenSync(temp_file_path(), flags); + int rv = stream.Open(temp_file_path(), flags); EXPECT_EQ(OK, rv); int64 file_size; @@ -441,7 +441,7 @@ TEST_F(FileStreamTest, BasicWrite_FromOffset) { rv = stream.Write(kTestData, kTestDataSize, CompletionCallback()); EXPECT_EQ(kTestDataSize, rv); - stream.CloseSync(); + stream.Close(); ok = file_util::GetFileSize(temp_file_path(), &file_size); EXPECT_TRUE(ok); @@ -457,7 +457,7 @@ TEST_F(FileStreamTest, AsyncWrite_FromOffset) { int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_ASYNC; - int rv = stream.OpenSync(temp_file_path(), flags); + int rv = stream.Open(temp_file_path(), flags); EXPECT_EQ(OK, rv); const int64 kOffset = 0; @@ -492,7 +492,7 @@ TEST_F(FileStreamTest, BasicReadWrite) { int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ | base::PLATFORM_FILE_WRITE; - int rv = stream.OpenSync(temp_file_path(), flags); + int rv = stream.Open(temp_file_path(), flags); EXPECT_EQ(OK, rv); int64 total_bytes_avail = stream.Available(); @@ -515,7 +515,7 @@ TEST_F(FileStreamTest, BasicReadWrite) { rv = stream.Write(kTestData, kTestDataSize, CompletionCallback()); EXPECT_EQ(kTestDataSize, rv); - stream.CloseSync(); + stream.Close(); ok = file_util::GetFileSize(temp_file_path(), &file_size); EXPECT_TRUE(ok); @@ -531,7 +531,7 @@ TEST_F(FileStreamTest, BasicWriteRead) { int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ | base::PLATFORM_FILE_WRITE; - int rv = stream.OpenSync(temp_file_path(), flags); + int rv = stream.Open(temp_file_path(), flags); EXPECT_EQ(OK, rv); int64 total_bytes_avail = stream.Available(); @@ -558,7 +558,7 @@ TEST_F(FileStreamTest, BasicWriteRead) { total_bytes_read += rv; data_read.append(buf, rv); } - stream.CloseSync(); + stream.Close(); ok = file_util::GetFileSize(temp_file_path(), &file_size); EXPECT_TRUE(ok); @@ -580,7 +580,7 @@ TEST_F(FileStreamTest, BasicAsyncReadWrite) { base::PLATFORM_FILE_READ | base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_ASYNC; - int rv = stream.OpenSync(temp_file_path(), flags); + int rv = stream.Open(temp_file_path(), flags); EXPECT_EQ(OK, rv); int64 total_bytes_avail = stream.Available(); @@ -618,7 +618,7 @@ TEST_F(FileStreamTest, BasicAsyncReadWrite) { total_bytes_written += rv; } - stream.CloseSync(); + stream.Close(); ok = file_util::GetFileSize(temp_file_path(), &file_size); EXPECT_TRUE(ok); @@ -635,7 +635,7 @@ TEST_F(FileStreamTest, BasicAsyncWriteRead) { base::PLATFORM_FILE_READ | base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_ASYNC; - int rv = stream.OpenSync(temp_file_path(), flags); + int rv = stream.Open(temp_file_path(), flags); EXPECT_EQ(OK, rv); int64 total_bytes_avail = stream.Available(); @@ -678,7 +678,7 @@ TEST_F(FileStreamTest, BasicAsyncWriteRead) { total_bytes_read += rv; data_read.append(buf, rv); } - stream.CloseSync(); + stream.Close(); ok = file_util::GetFileSize(temp_file_path(), &file_size); EXPECT_TRUE(ok); @@ -790,7 +790,7 @@ TEST_F(FileStreamTest, AsyncWriteRead) { base::PLATFORM_FILE_READ | base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_ASYNC; - int rv = stream.OpenSync(temp_file_path(), flags); + int rv = stream.Open(temp_file_path(), flags); EXPECT_EQ(OK, rv); int64 total_bytes_avail = stream.Available(); @@ -813,7 +813,7 @@ TEST_F(FileStreamTest, AsyncWriteRead) { EXPECT_LT(0, rv); EXPECT_EQ(kTestDataSize, total_bytes_written); - stream.CloseSync(); + stream.Close(); ok = file_util::GetFileSize(temp_file_path(), &file_size); EXPECT_TRUE(ok); @@ -867,7 +867,7 @@ class TestWriteCloseCompletionCallback { rv = callback.WaitForResult(); *total_bytes_written_ += total_bytes_written; } else { // We're done writing all data. Close the file. - stream_->CloseSync(); + stream_->Close(); } result_ = *total_bytes_written_; @@ -896,7 +896,7 @@ TEST_F(FileStreamTest, AsyncWriteClose) { base::PLATFORM_FILE_READ | base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_ASYNC; - int rv = stream.OpenSync(temp_file_path(), flags); + int rv = stream.Open(temp_file_path(), flags); EXPECT_EQ(OK, rv); int64 total_bytes_avail = stream.Available(); @@ -924,7 +924,7 @@ TEST_F(FileStreamTest, Truncate) { int flags = base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_WRITE; FileStream write_stream(NULL); - ASSERT_EQ(OK, write_stream.OpenSync(temp_file_path(), flags)); + ASSERT_EQ(OK, write_stream.Open(temp_file_path(), flags)); // Write some data to the file. const char test_data[] = "0123456789"; @@ -937,7 +937,7 @@ TEST_F(FileStreamTest, Truncate) { write_stream.Write(test_data, 4, CompletionCallback()); // Close the stream. - write_stream.CloseSync(); + write_stream.Close(); // Read in the contents and make sure we get back what we expected. std::string read_contents; diff --git a/net/base/file_stream_win.cc b/net/base/file_stream_win.cc index 425a3f7..9e1f686f 100644 --- a/net/base/file_stream_win.cc +++ b/net/base/file_stream_win.cc @@ -169,12 +169,12 @@ FileStream::FileStream(base::PlatformFile file, int flags, net::NetLog* net_log) FileStream::~FileStream() { if (auto_closed_) - CloseSync(); + Close(); bound_net_log_.EndEvent(net::NetLog::TYPE_FILE_STREAM_ALIVE, NULL); } -void FileStream::CloseSync() { +void FileStream::Close() { bound_net_log_.AddEvent(net::NetLog::TYPE_FILE_STREAM_CLOSE, NULL); if (file_ != INVALID_HANDLE_VALUE) CancelIo(file_); @@ -189,7 +189,7 @@ void FileStream::CloseSync() { } } -int FileStream::OpenSync(const FilePath& path, int open_flags) { +int FileStream::Open(const FilePath& path, int open_flags) { if (IsOpen()) { DLOG(FATAL) << "File is already open!"; return ERR_UNEXPECTED; diff --git a/net/base/mock_file_stream.cc b/net/base/mock_file_stream.cc index afca747..cb59cf9 100644 --- a/net/base/mock_file_stream.cc +++ b/net/base/mock_file_stream.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -8,9 +8,9 @@ namespace net { namespace testing { -int MockFileStream::OpenSync(const FilePath& path, int open_flags) { +int MockFileStream::Open(const FilePath& path, int open_flags) { path_ = path; - return ReturnError(FileStream::OpenSync(path, open_flags)); + return ReturnError(FileStream::Open(path, open_flags)); } int64 MockFileStream::Seek(Whence whence, int64 offset) { diff --git a/net/base/mock_file_stream.h b/net/base/mock_file_stream.h index f07785a..d8a56d7 100644 --- a/net/base/mock_file_stream.h +++ b/net/base/mock_file_stream.h @@ -27,7 +27,7 @@ class MockFileStream : public net::FileStream { : net::FileStream(file, flags, net_log), forced_error_(net::OK) {} // FileStream methods. - virtual int OpenSync(const FilePath& path, int open_flags) OVERRIDE; + virtual int Open(const FilePath& path, int open_flags) OVERRIDE; virtual int64 Seek(net::Whence whence, int64 offset) OVERRIDE; virtual int64 Available() OVERRIDE; virtual int Read(char* buf, diff --git a/net/base/upload_data.cc b/net/base/upload_data.cc index bffe13b..908fb2d 100644 --- a/net/base/upload_data.cc +++ b/net/base/upload_data.cc @@ -31,7 +31,7 @@ UploadData::Element::~Element() { if (file_stream_) { // Temporarily allow until fix: http://crbug.com/72001. base::ThreadRestrictions::ScopedAllowIO allow_io; - file_stream_->CloseSync(); + file_stream_->Close(); delete file_stream_; } } @@ -107,9 +107,8 @@ FileStream* UploadData::Element::NewFileStreamForReading() { base::ThreadRestrictions::ScopedAllowIO allow_io; scoped_ptr<FileStream> file(new FileStream(NULL)); - int64 rv = file->OpenSync( - file_path_, - base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ); + int64 rv = file->Open(file_path_, + base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ); if (rv != OK) { // If the file can't be opened, we'll just upload an empty file. DLOG(WARNING) << "Failed to open \"" << file_path_.value() diff --git a/net/base/upload_data_stream.cc b/net/base/upload_data_stream.cc index cee54c7..937ee09 100644 --- a/net/base/upload_data_stream.cc +++ b/net/base/upload_data_stream.cc @@ -154,7 +154,7 @@ void UploadDataStream::AdvanceToNextElement() { if (element_file_stream_.get()) { // Temporarily allow until fix: http://crbug.com/72001. base::ThreadRestrictions::ScopedAllowIO allow_io; - element_file_stream_->CloseSync(); + element_file_stream_->Close(); element_file_stream_.reset(); } } diff --git a/net/tools/dump_cache/dump_files.cc b/net/tools/dump_cache/dump_files.cc index f5656b0..4fab6f2 100644 --- a/net/tools/dump_cache/dump_files.cc +++ b/net/tools/dump_cache/dump_files.cc @@ -27,7 +27,7 @@ const wchar_t kDataPrefix[] = L"data_"; // Reads the |header_size| bytes from the beginning of file |name|. bool ReadHeader(const std::wstring& name, char* header, int header_size) { net::FileStream file(NULL); - file.OpenSync(FilePath::FromWStringHack(name), + file.Open(FilePath::FromWStringHack(name), base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ); if (!file.IsOpen()) { printf("Unable to open file %ls\n", name.c_str()); diff --git a/net/url_request/url_request_file_job.cc b/net/url_request/url_request_file_job.cc index fa6d6a2..8f32750 100644 --- a/net/url_request/url_request_file_job.cc +++ b/net/url_request/url_request_file_job.cc @@ -161,7 +161,7 @@ void URLRequestFileJob::Kill() { // URL requests should not block on the disk! // http://code.google.com/p/chromium/issues/detail?id=59849 base::ThreadRestrictions::ScopedAllowIO allow_io; - stream_.CloseSync(); + stream_.Close(); if (async_resolver_) { async_resolver_->Cancel(); @@ -313,7 +313,7 @@ void URLRequestFileJob::DidResolve( int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ | base::PLATFORM_FILE_ASYNC; - rv = stream_.OpenSync(file_path_, flags); + rv = stream_.Open(file_path_, flags); } if (rv != OK) { diff --git a/webkit/blob/blob_url_request_job.cc b/webkit/blob/blob_url_request_job.cc index d00761e..00d8317 100644 --- a/webkit/blob/blob_url_request_job.cc +++ b/webkit/blob/blob_url_request_job.cc @@ -102,7 +102,7 @@ void BlobURLRequestJob::CloseStream() { if (stream_ != NULL) { // stream_.Close() blocks the IO thread, see http://crbug.com/75548. base::ThreadRestrictions::ScopedAllowIO allow_io; - stream_->CloseSync(); + stream_->Close(); stream_.reset(NULL); } } diff --git a/webkit/fileapi/file_system_url_request_job.cc b/webkit/fileapi/file_system_url_request_job.cc index ca841df..342edae 100644 --- a/webkit/fileapi/file_system_url_request_job.cc +++ b/webkit/fileapi/file_system_url_request_job.cc @@ -123,7 +123,7 @@ FileSystemURLRequestJob::~FileSystemURLRequestJob() { // Since we use the two-arg constructor of FileStream, we need to call Close() // manually: ~FileStream won't call it for us. if (stream_ != NULL) - stream_->CloseSync(); + stream_->Close(); } void FileSystemURLRequestJob::Start() { @@ -135,7 +135,7 @@ void FileSystemURLRequestJob::Start() { void FileSystemURLRequestJob::Kill() { if (stream_ != NULL) { - stream_->CloseSync(); + stream_->Close(); stream_.reset(NULL); } URLRequestJob::Kill(); diff --git a/webkit/tools/test_shell/simple_resource_loader_bridge.cc b/webkit/tools/test_shell/simple_resource_loader_bridge.cc index 8f76c2b..1dd138e 100644 --- a/webkit/tools/test_shell/simple_resource_loader_bridge.cc +++ b/webkit/tools/test_shell/simple_resource_loader_bridge.cc @@ -332,7 +332,7 @@ class RequestProxy : public net::URLRequest::Delegate, if (file_util::CreateTemporaryFile(&path)) { downloaded_file_ = DeletableFileReference::GetOrCreate( path, base::MessageLoopProxy::current()); - file_stream_.OpenSync( + file_stream_.Open( path, base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE); } } @@ -426,7 +426,7 @@ class RequestProxy : public net::URLRequest::Delegate, const std::string& security_info, const base::TimeTicks& complete_time) { if (download_to_file_) - file_stream_.CloseSync(); + file_stream_.Close(); owner_loop_->PostTask( FROM_HERE, base::Bind(&RequestProxy::NotifyCompletedRequest, this, status, @@ -732,7 +732,7 @@ class SyncRequestProxy : public RequestProxy { const std::string& security_info, const base::TimeTicks& complete_time) { if (download_to_file_) - file_stream_.CloseSync(); + file_stream_.Close(); result_->status = status; event_.Signal(); } |