summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-08 21:57:08 +0000
committersatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-08 21:57:08 +0000
commitd20ab94f4e849e91a3e415a405b88a23afa408c6 (patch)
tree92189e9ce3b53aaf0185f16d6a0dd2b4bb4140e6
parentfae7753433ce0fff8e5f28bedde84f7b164bc422 (diff)
downloadchromium_src-d20ab94f4e849e91a3e415a405b88a23afa408c6.zip
chromium_src-d20ab94f4e849e91a3e415a405b88a23afa408c6.tar.gz
chromium_src-d20ab94f4e849e91a3e415a405b88a23afa408c6.tar.bz2
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 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121064 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/bookmarks/bookmark_html_writer.cc4
-rw-r--r--chrome/browser/safe_browsing/bloom_filter.cc12
-rw-r--r--chrome/browser/sessions/session_backend.cc7
-rw-r--r--chrome/browser/themes/browser_theme_pack.cc2
-rw-r--r--chrome/common/zip.cc2
-rw-r--r--chrome/common/zip_reader.cc4
-rw-r--r--content/browser/download/base_file.cc4
-rw-r--r--content/browser/download/base_file_unittest.cc2
-rw-r--r--content/browser/download/download_manager_impl_unittest.cc2
-rw-r--r--content/browser/download/drag_download_util.cc2
-rw-r--r--content/browser/renderer_host/redirect_to_file_resource_handler.cc2
-rw-r--r--content/browser/tab_contents/web_drag_source_mac.mm2
-rw-r--r--net/base/file_stream.h20
-rw-r--r--net/base/file_stream_posix.cc6
-rw-r--r--net/base/file_stream_unittest.cc64
-rw-r--r--net/base/file_stream_win.cc6
-rw-r--r--net/base/mock_file_stream.cc6
-rw-r--r--net/base/mock_file_stream.h2
-rw-r--r--net/base/upload_data.cc7
-rw-r--r--net/base/upload_data_stream.cc2
-rw-r--r--net/tools/dump_cache/dump_files.cc2
-rw-r--r--net/url_request/url_request_file_job.cc4
-rw-r--r--webkit/blob/blob_url_request_job.cc2
-rw-r--r--webkit/fileapi/file_system_url_request_job.cc4
-rw-r--r--webkit/tools/test_shell/simple_resource_loader_bridge.cc6
25 files changed, 91 insertions, 85 deletions
diff --git a/chrome/browser/bookmarks/bookmark_html_writer.cc b/chrome/browser/bookmarks/bookmark_html_writer.cc
index 8ab2de4..5a6d670 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_.Close();
+ file_stream_.CloseSync();
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_.Open(path_, flags) == net::OK);
+ return (file_stream_.OpenSync(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 c21c1c0..6f928b5 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.Open(filter_name,
- base::PLATFORM_FILE_OPEN |
- base::PLATFORM_FILE_READ) != net::OK) {
+ if (filter.OpenSync(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.Open(filter_name,
- base::PLATFORM_FILE_WRITE |
- base::PLATFORM_FILE_CREATE_ALWAYS) != net::OK)
+ if (filter.OpenSync(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 ba9f9ad..419678e 100644
--- a/chrome/browser/sessions/session_backend.cc
+++ b/chrome/browser/sessions/session_backend.cc
@@ -48,7 +48,8 @@ class SessionFileReader {
available_count_(0) {
file_.reset(new net::FileStream(NULL));
if (file_util::PathExists(path))
- file_->Open(path, base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ);
+ file_->OpenSync(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
@@ -347,7 +348,7 @@ SessionBackend::~SessionBackend() {
if (current_session_file_.get()) {
// Close() performs file IO. crbug.com/112512.
base::ThreadRestrictions::ScopedAllowIO allow_io;
- current_session_file_->Close();
+ current_session_file_->CloseSync();
}
}
@@ -370,7 +371,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->Open(path, base::PLATFORM_FILE_CREATE_ALWAYS |
+ if (file->OpenSync(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 28c5db2..5daf9f7 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.Open(path, flags) == net::OK) {
+ if (file.OpenSync(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 a5635c0..1da9cff 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.Open(src_dir, flags) != 0) {
+ if (stream.OpenSync(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 60fba5e..c89ce29 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.Open(output_file_path, flags) != 0)
+ if (stream.OpenSync(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.Close();
+ stream.CloseSync();
unzCloseCurrentFile(zip_file_);
return success;
}
diff --git a/content/browser/download/base_file.cc b/content/browser/download/base_file.cc
index 74e9b95..51ff531 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_->Open(
+ int open_result = file_stream_->OpenSync(
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_->Close();
+ file_stream_->CloseSync();
ClearStream(net::OK);
}
}
diff --git a/content/browser/download/base_file_unittest.cc b/content/browser/download/base_file_unittest.cc
index 2ed3b9d..a25ba60 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_->Open(
+ if (mock_file_stream_->OpenSync(
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 635f4fb..3d894f8 100644
--- a/content/browser/download/download_manager_impl_unittest.cc
+++ b/content/browser/download/download_manager_impl_unittest.cc
@@ -1014,7 +1014,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->Open(
+ ASSERT_EQ(0, stream->OpenSync(
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 b43cc57..aefaed296 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, net::NetLog* net_log) {
// 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->Open(new_file_path, base::PLATFORM_FILE_CREATE |
+ file_stream->OpenSync(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 64e007b..8ebba69 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_->Close();
+ file_stream_->CloseSync();
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 02f8293..624225c 100644
--- a/content/browser/tab_contents/web_drag_source_mac.mm
+++ b/content/browser/tab_contents/web_drag_source_mac.mm
@@ -82,7 +82,7 @@ void PromiseWriterHelper(const WebDropData& drop_data,
net::CompletionCallback());
if (file_stream)
- file_stream->Close();
+ file_stream->CloseSync();
}
} // namespace
diff --git a/net/base/file_stream.h b/net/base/file_stream.h
index a50d9c0..39863a5 100644
--- a/net/base/file_stream.h
+++ b/net/base/file_stream.h
@@ -47,16 +47,20 @@ class NET_EXPORT FileStream {
virtual ~FileStream();
- // Call this method to close the FileStream. It is OK to call Close
- // multiple times. Redundant calls are ignored.
+ // Call this method to close the FileStream synchronously.
+ // 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.
- virtual void Close();
+ //
+ // TODO(satorux): Implement the asynchronous version of this.
+ virtual void CloseSync();
- // 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);
+ // 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);
// 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 a094eed..86f64ec 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_)
- Close();
+ CloseSync();
bound_net_log_.EndEvent(net::NetLog::TYPE_FILE_STREAM_ALIVE, NULL);
}
-void FileStream::Close() {
+void FileStream::CloseSync() {
bound_net_log_.AddEvent(net::NetLog::TYPE_FILE_STREAM_CLOSE, NULL);
// Abort any existing asynchronous operations.
@@ -361,7 +361,7 @@ void FileStream::Close() {
}
}
-int FileStream::Open(const FilePath& path, int open_flags) {
+int FileStream::OpenSync(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 c92ce9f..a0500c1 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.Open(temp_file_path(),
+ int rv = stream.OpenSync(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.Close();
+ read_stream.CloseSync();
// 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.Close();
+ write_stream.CloseSync();
// 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.Open(temp_file_path(), flags);
+ int rv = stream.OpenSync(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.Open(temp_file_path(), flags);
+ int rv = stream.OpenSync(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.Open(temp_file_path(), flags);
+ int rv = stream.OpenSync(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.Close();
+ stream.CloseSync();
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.Open(temp_file_path(), flags);
+ int rv = stream.OpenSync(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.Open(temp_file_path(), flags);
+ int rv = stream.OpenSync(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.Open(temp_file_path(), flags);
+ int rv = stream.OpenSync(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.Open(temp_file_path(), flags);
+ int rv = stream.OpenSync(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.Close();
+ stream.CloseSync();
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.Open(temp_file_path(), flags);
+ int rv = stream.OpenSync(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.Open(temp_file_path(), flags);
+ int rv = stream.OpenSync(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.Close();
+ stream.CloseSync();
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.Open(temp_file_path(), flags);
+ int rv = stream.OpenSync(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.Close();
+ stream.CloseSync();
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.Open(temp_file_path(), flags);
+ int rv = stream.OpenSync(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.Open(temp_file_path(), flags);
+ int rv = stream.OpenSync(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.Close();
+ stream.CloseSync();
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.Open(temp_file_path(), flags);
+ int rv = stream.OpenSync(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.Close();
+ stream.CloseSync();
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.Open(temp_file_path(), flags);
+ int rv = stream.OpenSync(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.Close();
+ stream.CloseSync();
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.Open(temp_file_path(), flags);
+ int rv = stream.OpenSync(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.Close();
+ stream.CloseSync();
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.Open(temp_file_path(), flags);
+ int rv = stream.OpenSync(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.Close();
+ stream.CloseSync();
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_->Close();
+ stream_->CloseSync();
}
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.Open(temp_file_path(), flags);
+ int rv = stream.OpenSync(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.Open(temp_file_path(), flags));
+ ASSERT_EQ(OK, write_stream.OpenSync(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.Close();
+ write_stream.CloseSync();
// 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 9e1f686f..425a3f7 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_)
- Close();
+ CloseSync();
bound_net_log_.EndEvent(net::NetLog::TYPE_FILE_STREAM_ALIVE, NULL);
}
-void FileStream::Close() {
+void FileStream::CloseSync() {
bound_net_log_.AddEvent(net::NetLog::TYPE_FILE_STREAM_CLOSE, NULL);
if (file_ != INVALID_HANDLE_VALUE)
CancelIo(file_);
@@ -189,7 +189,7 @@ void FileStream::Close() {
}
}
-int FileStream::Open(const FilePath& path, int open_flags) {
+int FileStream::OpenSync(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 cb59cf9..afca747 100644
--- a/net/base/mock_file_stream.cc
+++ b/net/base/mock_file_stream.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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::Open(const FilePath& path, int open_flags) {
+int MockFileStream::OpenSync(const FilePath& path, int open_flags) {
path_ = path;
- return ReturnError(FileStream::Open(path, open_flags));
+ return ReturnError(FileStream::OpenSync(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 d8a56d7..f07785a 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 Open(const FilePath& path, int open_flags) OVERRIDE;
+ virtual int OpenSync(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 908fb2d..bffe13b 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_->Close();
+ file_stream_->CloseSync();
delete file_stream_;
}
}
@@ -107,8 +107,9 @@ FileStream* UploadData::Element::NewFileStreamForReading() {
base::ThreadRestrictions::ScopedAllowIO allow_io;
scoped_ptr<FileStream> file(new FileStream(NULL));
- int64 rv = file->Open(file_path_,
- base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ);
+ int64 rv = file->OpenSync(
+ 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 937ee09..cee54c7 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_->Close();
+ element_file_stream_->CloseSync();
element_file_stream_.reset();
}
}
diff --git a/net/tools/dump_cache/dump_files.cc b/net/tools/dump_cache/dump_files.cc
index 4fab6f2..f5656b0 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.Open(FilePath::FromWStringHack(name),
+ file.OpenSync(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 8f32750..fa6d6a2 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_.Close();
+ stream_.CloseSync();
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_.Open(file_path_, flags);
+ rv = stream_.OpenSync(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 00d8317..d00761e 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_->Close();
+ stream_->CloseSync();
stream_.reset(NULL);
}
}
diff --git a/webkit/fileapi/file_system_url_request_job.cc b/webkit/fileapi/file_system_url_request_job.cc
index 342edae..ca841df 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_->Close();
+ stream_->CloseSync();
}
void FileSystemURLRequestJob::Start() {
@@ -135,7 +135,7 @@ void FileSystemURLRequestJob::Start() {
void FileSystemURLRequestJob::Kill() {
if (stream_ != NULL) {
- stream_->Close();
+ stream_->CloseSync();
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 1dd138e..8f76c2b 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_.Open(
+ file_stream_.OpenSync(
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_.Close();
+ file_stream_.CloseSync();
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_.Close();
+ file_stream_.CloseSync();
result_->status = status;
event_.Signal();
}