summaryrefslogtreecommitdiffstats
path: root/net/base
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-08 22:32:07 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-08 22:32:07 +0000
commit5ab2191f4bf80656bdec435141531f18c07859c4 (patch)
tree3f458c1f9cbba24a530cf2f1d4965c7e65517376 /net/base
parent2098fc80beaf21ef93d7fe3e886d185ce871b423 (diff)
downloadchromium_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
Diffstat (limited to 'net/base')
-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
8 files changed, 54 insertions, 59 deletions
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();
}
}