diff options
-rw-r--r-- | chrome/browser/chromeos/drive/local_file_reader.cc | 2 | ||||
-rw-r--r-- | chrome/browser/extensions/api/messaging/native_message_process_host.cc | 4 | ||||
-rw-r--r-- | chromeos/dbus/pipe_reader.cc | 3 | ||||
-rw-r--r-- | content/browser/loader/resource_loader_unittest.cc | 2 | ||||
-rw-r--r-- | content/browser/loader/temporary_file_stream.cc | 3 | ||||
-rw-r--r-- | net/base/file_stream.cc | 37 | ||||
-rw-r--r-- | net/base/file_stream.h | 19 | ||||
-rw-r--r-- | net/base/file_stream_context.cc | 94 | ||||
-rw-r--r-- | net/base/file_stream_context.h | 37 | ||||
-rw-r--r-- | net/base/file_stream_context_posix.cc | 16 | ||||
-rw-r--r-- | net/base/file_stream_context_win.cc | 14 | ||||
-rw-r--r-- | net/base/file_stream_unittest.cc | 40 | ||||
-rw-r--r-- | net/base/mock_file_stream.cc | 11 | ||||
-rw-r--r-- | net/base/mock_file_stream.h | 6 | ||||
-rw-r--r-- | net/base/upload_file_element_reader.cc | 2 | ||||
-rw-r--r-- | net/url_request/url_fetcher_response_writer.cc | 2 | ||||
-rw-r--r-- | net/url_request/url_request_file_job.cc | 2 | ||||
-rw-r--r-- | webkit/browser/blob/local_file_stream_reader.cc | 2 | ||||
-rw-r--r-- | webkit/browser/fileapi/local_file_stream_writer.cc | 2 |
19 files changed, 74 insertions, 224 deletions
diff --git a/chrome/browser/chromeos/drive/local_file_reader.cc b/chrome/browser/chromeos/drive/local_file_reader.cc index 062bbb8..e6bacc1 100644 --- a/chrome/browser/chromeos/drive/local_file_reader.cc +++ b/chrome/browser/chromeos/drive/local_file_reader.cc @@ -16,7 +16,7 @@ namespace util { LocalFileReader::LocalFileReader( base::SequencedTaskRunner* sequenced_task_runner) - : file_stream_(NULL, sequenced_task_runner), + : file_stream_(sequenced_task_runner), weak_ptr_factory_(this) { } diff --git a/chrome/browser/extensions/api/messaging/native_message_process_host.cc b/chrome/browser/extensions/api/messaging/native_message_process_host.cc index 8d3352a..73af519 100644 --- a/chrome/browser/extensions/api/messaging/native_message_process_host.cc +++ b/chrome/browser/extensions/api/messaging/native_message_process_host.cc @@ -200,11 +200,11 @@ void NativeMessageProcessHost::OnHostProcessLaunched( read_stream_.reset(new net::FileStream( read_file.TakePlatformFile(), - base::PLATFORM_FILE_READ | base::PLATFORM_FILE_ASYNC, NULL, + base::PLATFORM_FILE_READ | base::PLATFORM_FILE_ASYNC, task_runner)); write_stream_.reset(new net::FileStream( write_file.TakePlatformFile(), - base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_ASYNC, NULL, + base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_ASYNC, task_runner)); WaitRead(); diff --git a/chromeos/dbus/pipe_reader.cc b/chromeos/dbus/pipe_reader.cc index 8d857ea..547a974 100644 --- a/chromeos/dbus/pipe_reader.cc +++ b/chromeos/dbus/pipe_reader.cc @@ -42,8 +42,7 @@ bool PipeReader::StartIO() { // Pass ownership of pipe_fds[0] to data_stream_, which will will close it. data_stream_.reset(new net::FileStream( data_file_, - base::PLATFORM_FILE_READ | base::PLATFORM_FILE_ASYNC, - NULL)); + base::PLATFORM_FILE_READ | base::PLATFORM_FILE_ASYNC)); // Post an initial async read to setup data collection int rv = data_stream_->Read( diff --git a/content/browser/loader/resource_loader_unittest.cc b/content/browser/loader/resource_loader_unittest.cc index dc5d027..0d2629d 100644 --- a/content/browser/loader/resource_loader_unittest.cc +++ b/content/browser/loader/resource_loader_unittest.cc @@ -515,7 +515,7 @@ class ResourceLoaderRedirectToFileTest : public ResourceLoaderTest { // Create mock file streams and a ShareableFileReference. scoped_ptr<net::testing::MockFileStream> file_stream( - new net::testing::MockFileStream(file.Pass(), NULL, + new net::testing::MockFileStream(file.Pass(), base::MessageLoopProxy::current())); file_stream_ = file_stream.get(); deletable_file_ = ShareableFileReference::GetOrCreate( diff --git a/content/browser/loader/temporary_file_stream.cc b/content/browser/loader/temporary_file_stream.cc index 1d23ae9..5979bd9 100644 --- a/content/browser/loader/temporary_file_stream.cc +++ b/content/browser/loader/temporary_file_stream.cc @@ -40,8 +40,7 @@ void DidCreateTemporaryFile( scoped_ptr<net::FileStream> file_stream(new net::FileStream( file_handle.ReleaseValue(), - base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_ASYNC, - NULL)); + base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_ASYNC)); callback.Run(error_code, file_stream.Pass(), deletable_file); } diff --git a/net/base/file_stream.cc b/net/base/file_stream.cc index a0939eb..6c3741a 100644 --- a/net/base/file_stream.cc +++ b/net/base/file_stream.cc @@ -14,54 +14,37 @@ namespace net { -FileStream::FileStream(NetLog* net_log, - const scoped_refptr<base::TaskRunner>& task_runner) - : bound_net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_FILESTREAM)), - context_(new Context(bound_net_log_, task_runner)) { - bound_net_log_.BeginEvent(NetLog::TYPE_FILE_STREAM_ALIVE); +FileStream::FileStream(const scoped_refptr<base::TaskRunner>& task_runner) + : context_(new Context(task_runner)) { } -FileStream::FileStream(NetLog* net_log) - : bound_net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_FILESTREAM)), - context_(new Context(bound_net_log_, - base::WorkerPool::GetTaskRunner(true /* slow */))) { - bound_net_log_.BeginEvent(NetLog::TYPE_FILE_STREAM_ALIVE); +FileStream::FileStream() + : context_(new Context(base::WorkerPool::GetTaskRunner(true /* slow */))) { } FileStream::FileStream(base::PlatformFile file, int flags, - NetLog* net_log, const scoped_refptr<base::TaskRunner>& task_runner) - : bound_net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_FILESTREAM)), - context_(new Context(base::File(file), bound_net_log_, task_runner)) { - bound_net_log_.BeginEvent(NetLog::TYPE_FILE_STREAM_ALIVE); + : context_(new Context(base::File(file), task_runner)) { } -FileStream::FileStream(base::PlatformFile file, int flags, NetLog* net_log) - : bound_net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_FILESTREAM)), - context_(new Context(base::File(file), bound_net_log_, +FileStream::FileStream(base::PlatformFile file, int flags) + : context_(new Context(base::File(file), base::WorkerPool::GetTaskRunner(true /* slow */))) { - bound_net_log_.BeginEvent(NetLog::TYPE_FILE_STREAM_ALIVE); } FileStream::FileStream(base::File file, - net::NetLog* net_log, const scoped_refptr<base::TaskRunner>& task_runner) - : bound_net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_FILESTREAM)), - context_(new Context(file.Pass(), bound_net_log_, task_runner)) { - bound_net_log_.BeginEvent(NetLog::TYPE_FILE_STREAM_ALIVE); + : context_(new Context(file.Pass(), task_runner)) { } -FileStream::FileStream(base::File file, net::NetLog* net_log) - : bound_net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_FILESTREAM)), - context_(new Context(file.Pass(), bound_net_log_, +FileStream::FileStream(base::File file) + : context_(new Context(file.Pass(), base::WorkerPool::GetTaskRunner(true /* slow */))) { - bound_net_log_.BeginEvent(NetLog::TYPE_FILE_STREAM_ALIVE); } FileStream::~FileStream() { context_.release()->Orphan(); - bound_net_log_.EndEvent(NetLog::TYPE_FILE_STREAM_ALIVE); } int FileStream::Open(const base::FilePath& path, int open_flags, diff --git a/net/base/file_stream.h b/net/base/file_stream.h index a903fec..4638ad0 100644 --- a/net/base/file_stream.h +++ b/net/base/file_stream.h @@ -16,7 +16,6 @@ #include "net/base/completion_callback.h" #include "net/base/file_stream_whence.h" #include "net/base/net_export.h" -#include "net/base/net_log.h" namespace base { class FilePath; @@ -28,21 +27,17 @@ class IOBuffer; class NET_EXPORT FileStream { public: - // Creates a |FileStream| with a new |BoundNetLog| (based on |net_log|) - // attached. |net_log| may be NULL if no logging is needed. + // Creates a FileStream. // Uses |task_runner| for asynchronous operations. - FileStream(net::NetLog* net_log, - const scoped_refptr<base::TaskRunner>& task_runner); + explicit FileStream(const scoped_refptr<base::TaskRunner>& task_runner); // Same as above, but runs async tasks in base::WorkerPool. - explicit FileStream(net::NetLog* net_log); + FileStream(); // Construct a FileStream with an existing file handle and opening flags. // |file| is valid file handle. // |flags| is a bitfield of base::PlatformFileFlags when the file handle was // opened. - // |net_log| is the net log pointer to use to create a |BoundNetLog|. May be - // NULL if logging is not needed. // Uses |task_runner| for asynchronous operations. // Note: the new FileStream object takes ownership of the PlatformFile and // will close it on destruction. @@ -50,18 +45,16 @@ class NET_EXPORT FileStream { // TODO(rvargas): remove all references to PlatformFile. FileStream(base::PlatformFile file, int flags, - net::NetLog* net_log, const scoped_refptr<base::TaskRunner>& task_runner); // Same as above, but runs async tasks in base::WorkerPool. // This constructor is deprecated. - FileStream(base::PlatformFile file, int flags, net::NetLog* net_log); + FileStream(base::PlatformFile file, int flags); // Non-deprecated versions of the previous two constructors. FileStream(base::File file, - net::NetLog* net_log, const scoped_refptr<base::TaskRunner>& task_runner); - FileStream(base::File file, net::NetLog* net_log); + explicit FileStream(base::File file); // The underlying file is closed automatically. virtual ~FileStream(); @@ -175,8 +168,6 @@ class NET_EXPORT FileStream { private: class Context; - net::BoundNetLog bound_net_log_; - // Context performing I/O operations. It was extracted into a separate class // to perform asynchronous operations because FileStream can be destroyed // before completion of an async operation. Also if a FileStream is destroyed diff --git a/net/base/file_stream_context.cc b/net/base/file_stream_context.cc index 1d7e493..13467ec 100644 --- a/net/base/file_stream_context.cc +++ b/net/base/file_stream_context.cc @@ -23,37 +23,6 @@ void CallInt64ToInt(const CompletionCallback& callback, int64 result) { callback.Run(static_cast<int>(result)); } -const char* FileErrorSourceStrings[] = { - "OPEN", - "WRITE", - "READ", - "SEEK", - "FLUSH", - "SET_EOF", - "GET_SIZE", - "CLOSE" -}; - -COMPILE_ASSERT(ARRAYSIZE_UNSAFE(FileErrorSourceStrings) == - FILE_ERROR_SOURCE_COUNT, - file_error_source_enum_has_changed); - -// Creates NetLog parameters when a FileStream has an error. -base::Value* NetLogFileStreamErrorCallback( - FileErrorSource source, - int os_error, - Error net_error, - NetLog::LogLevel /* log_level */) { - base::DictionaryValue* dict = new base::DictionaryValue(); - - DCHECK_NE(FILE_ERROR_SOURCE_COUNT, source); - dict->SetString("operation", FileErrorSourceStrings[source]); - dict->SetInteger("os_error", os_error); - dict->SetInteger("net_error", net_error); - - return dict; -} - } // namespace FileStream::Context::IOResult::IOResult() @@ -103,8 +72,6 @@ void FileStream::Context::Orphan() { DCHECK(!orphaned_); orphaned_ = true; - if (file_.IsValid()) - bound_net_log_.EndEvent(NetLog::TYPE_FILE_STREAM_OPEN); if (!async_in_progress_) { CloseAndDelete(); @@ -117,7 +84,6 @@ void FileStream::Context::OpenAsync(const base::FilePath& path, int open_flags, const CompletionCallback& callback) { DCHECK(!async_in_progress_); - BeginOpenEvent(path); bool posted = base::PostTaskAndReplyWithResult( task_runner_.get(), @@ -136,10 +102,9 @@ void FileStream::Context::CloseAsync(const CompletionCallback& callback) { task_runner_.get(), FROM_HERE, base::Bind(&Context::CloseFileImpl, base::Unretained(this)), - base::Bind(&Context::ProcessAsyncResult, + base::Bind(&Context::OnAsyncCompleted, base::Unretained(this), - IntToInt64(callback), - FILE_ERROR_SOURCE_CLOSE)); + IntToInt64(callback))); DCHECK(posted); async_in_progress_ = true; @@ -155,10 +120,9 @@ void FileStream::Context::SeekAsync(Whence whence, FROM_HERE, base::Bind( &Context::SeekFileImpl, base::Unretained(this), whence, offset), - base::Bind(&Context::ProcessAsyncResult, + base::Bind(&Context::OnAsyncCompleted, base::Unretained(this), - callback, - FILE_ERROR_SOURCE_SEEK)); + callback)); DCHECK(posted); async_in_progress_ = true; @@ -171,37 +135,14 @@ void FileStream::Context::FlushAsync(const CompletionCallback& callback) { task_runner_.get(), FROM_HERE, base::Bind(&Context::FlushFileImpl, base::Unretained(this)), - base::Bind(&Context::ProcessAsyncResult, + base::Bind(&Context::OnAsyncCompleted, base::Unretained(this), - IntToInt64(callback), - FILE_ERROR_SOURCE_FLUSH)); + IntToInt64(callback))); DCHECK(posted); async_in_progress_ = true; } -void FileStream::Context::RecordError(const IOResult& result, - FileErrorSource source) const { - if (result.result >= 0) { - // |result| is not an error. - return; - } - - if (!orphaned_) { - bound_net_log_.AddEvent( - NetLog::TYPE_FILE_STREAM_ERROR, - base::Bind(&NetLogFileStreamErrorCallback, - source, result.os_error, - static_cast<net::Error>(result.result))); - } -} - -void FileStream::Context::BeginOpenEvent(const base::FilePath& path) { - std::string file_name = path.AsUTF8Unsafe(); - bound_net_log_.BeginEvent(NetLog::TYPE_FILE_STREAM_OPEN, - NetLog::StringCallback("file_name", &file_name)); -} - FileStream::Context::OpenResult FileStream::Context::OpenFileImpl( const base::FilePath& path, int open_flags) { #if defined(OS_POSIX) @@ -239,20 +180,13 @@ FileStream::Context::IOResult FileStream::Context::CloseFileImpl() { return IOResult(OK, 0); } -void FileStream::Context::ProcessOpenError(const IOResult& error_code) { - bound_net_log_.EndEvent(NetLog::TYPE_FILE_STREAM_OPEN); - RecordError(error_code, FILE_ERROR_SOURCE_OPEN); -} - void FileStream::Context::OnOpenCompleted(const CompletionCallback& callback, OpenResult open_result) { - if (!open_result.file.IsValid()) { - ProcessOpenError(open_result.error_code); - } else if (!orphaned_) { + if (open_result.file.IsValid() && !orphaned_) { file_ = open_result.file.Pass(); OnAsyncFileOpened(); } - OnAsyncCompleted(IntToInt64(callback), open_result.error_code.result); + OnAsyncCompleted(IntToInt64(callback), open_result.error_code); } void FileStream::Context::CloseAndDelete() { @@ -274,17 +208,9 @@ Int64CompletionCallback FileStream::Context::IntToInt64( return base::Bind(&CallInt64ToInt, callback); } -void FileStream::Context::ProcessAsyncResult( - const Int64CompletionCallback& callback, - FileErrorSource source, - const IOResult& result) { - RecordError(result, source); - OnAsyncCompleted(callback, result.result); -} - void FileStream::Context::OnAsyncCompleted( const Int64CompletionCallback& callback, - int64 result) { + const IOResult& result) { // Reset this before Run() as Run() may issue a new async operation. Also it // should be reset before CloseAsync() because it shouldn't run if any async // operation is in progress. @@ -292,7 +218,7 @@ void FileStream::Context::OnAsyncCompleted( if (orphaned_) CloseAndDelete(); else - callback.Run(result); + callback.Run(result.result); } } // namespace net diff --git a/net/base/file_stream_context.h b/net/base/file_stream_context.h index 92a6beb..c4a06ee 100644 --- a/net/base/file_stream_context.h +++ b/net/base/file_stream_context.h @@ -34,7 +34,6 @@ #include "net/base/completion_callback.h" #include "net/base/file_stream.h" #include "net/base/file_stream_whence.h" -#include "net/base/net_log.h" #if defined(OS_POSIX) #include <errno.h> @@ -48,18 +47,6 @@ namespace net { class IOBuffer; -enum FileErrorSource { - FILE_ERROR_SOURCE_OPEN = 0, - FILE_ERROR_SOURCE_WRITE, - FILE_ERROR_SOURCE_READ, - FILE_ERROR_SOURCE_SEEK, - FILE_ERROR_SOURCE_FLUSH, - FILE_ERROR_SOURCE_SET_EOF, - FILE_ERROR_SOURCE_GET_SIZE, - FILE_ERROR_SOURCE_CLOSE, - FILE_ERROR_SOURCE_COUNT, -}; - #if defined(OS_WIN) class FileStream::Context : public base::MessageLoopForIO::IOHandler { #elif defined(OS_POSIX) @@ -71,11 +58,8 @@ class FileStream::Context { // file_stream_context_{win,posix}.cc. //////////////////////////////////////////////////////////////////////////// - Context(const BoundNetLog& bound_net_log, - const scoped_refptr<base::TaskRunner>& task_runner); - Context(base::File file, - const BoundNetLog& bound_net_log, - const scoped_refptr<base::TaskRunner>& task_runner); + explicit Context(const scoped_refptr<base::TaskRunner>& task_runner); + Context(base::File file, const scoped_refptr<base::TaskRunner>& task_runner); #if defined(OS_WIN) virtual ~Context(); #elif defined(OS_POSIX) @@ -145,16 +129,10 @@ class FileStream::Context { IOResult error_code; }; - // Log the error from |result| to |bound_net_log_|. - void RecordError(const IOResult& result, FileErrorSource source) const; - - void BeginOpenEvent(const base::FilePath& path); - OpenResult OpenFileImpl(const base::FilePath& path, int open_flags); IOResult CloseFileImpl(); - void ProcessOpenError(const IOResult& result); void OnOpenCompleted(const CompletionCallback& callback, OpenResult open_result); @@ -162,15 +140,10 @@ class FileStream::Context { Int64CompletionCallback IntToInt64(const CompletionCallback& callback); - // Called when asynchronous Seek() is completed. - // Reports error if needed and calls callback. - void ProcessAsyncResult(const Int64CompletionCallback& callback, - FileErrorSource source, - const IOResult& result); - // Called when asynchronous Open() or Seek() // is completed. |result| contains the result or a network error code. - void OnAsyncCompleted(const Int64CompletionCallback& callback, int64 result); + void OnAsyncCompleted(const Int64CompletionCallback& callback, + const IOResult& result); //////////////////////////////////////////////////////////////////////////// // Helper stuff which is platform-dependent but is used in the platform- @@ -220,14 +193,12 @@ class FileStream::Context { base::File file_; bool async_in_progress_; bool orphaned_; - BoundNetLog bound_net_log_; scoped_refptr<base::TaskRunner> task_runner_; #if defined(OS_WIN) base::MessageLoopForIO::IOContext io_context_; CompletionCallback callback_; scoped_refptr<IOBuffer> in_flight_buf_; - FileErrorSource error_source_; #endif DISALLOW_COPY_AND_ASSIGN(Context); diff --git a/net/base/file_stream_context_posix.cc b/net/base/file_stream_context_posix.cc index f72b374..ecf9285 100644 --- a/net/base/file_stream_context_posix.cc +++ b/net/base/file_stream_context_posix.cc @@ -44,21 +44,17 @@ COMPILE_ASSERT(FROM_BEGIN == SEEK_SET && FROM_CURRENT == SEEK_CUR && FROM_END == SEEK_END, whence_matches_system); -FileStream::Context::Context(const BoundNetLog& bound_net_log, - const scoped_refptr<base::TaskRunner>& task_runner) +FileStream::Context::Context(const scoped_refptr<base::TaskRunner>& task_runner) : async_in_progress_(false), orphaned_(false), - bound_net_log_(bound_net_log), task_runner_(task_runner) { } FileStream::Context::Context(base::File file, - const BoundNetLog& bound_net_log, const scoped_refptr<base::TaskRunner>& task_runner) : file_(file.Pass()), async_in_progress_(false), orphaned_(false), - bound_net_log_(bound_net_log), task_runner_(task_runner) { } @@ -75,10 +71,9 @@ int FileStream::Context::ReadAsync(IOBuffer* in_buf, task_runner_.get(), FROM_HERE, base::Bind(&Context::ReadFileImpl, base::Unretained(this), buf, buf_len), - base::Bind(&Context::ProcessAsyncResult, + base::Bind(&Context::OnAsyncCompleted, base::Unretained(this), - IntToInt64(callback), - FILE_ERROR_SOURCE_READ)); + IntToInt64(callback))); DCHECK(posted); async_in_progress_ = true; @@ -95,10 +90,9 @@ int FileStream::Context::WriteAsync(IOBuffer* in_buf, task_runner_.get(), FROM_HERE, base::Bind(&Context::WriteFileImpl, base::Unretained(this), buf, buf_len), - base::Bind(&Context::ProcessAsyncResult, + base::Bind(&Context::OnAsyncCompleted, base::Unretained(this), - IntToInt64(callback), - FILE_ERROR_SOURCE_WRITE)); + IntToInt64(callback))); DCHECK(posted); async_in_progress_ = true; diff --git a/net/base/file_stream_context_win.cc b/net/base/file_stream_context_win.cc index fe97263..2477535 100644 --- a/net/base/file_stream_context_win.cc +++ b/net/base/file_stream_context_win.cc @@ -37,27 +37,21 @@ void IncrementOffset(OVERLAPPED* overlapped, DWORD count) { } // namespace -FileStream::Context::Context(const BoundNetLog& bound_net_log, - const scoped_refptr<base::TaskRunner>& task_runner) +FileStream::Context::Context(const scoped_refptr<base::TaskRunner>& task_runner) : io_context_(), async_in_progress_(false), orphaned_(false), - bound_net_log_(bound_net_log), - error_source_(FILE_ERROR_SOURCE_COUNT), task_runner_(task_runner) { io_context_.handler = this; memset(&io_context_.overlapped, 0, sizeof(io_context_.overlapped)); } FileStream::Context::Context(base::File file, - const BoundNetLog& bound_net_log, const scoped_refptr<base::TaskRunner>& task_runner) : io_context_(), file_(file.Pass()), async_in_progress_(false), orphaned_(false), - bound_net_log_(bound_net_log), - error_source_(FILE_ERROR_SOURCE_COUNT), task_runner_(task_runner) { io_context_.handler = this; memset(&io_context_.overlapped, 0, sizeof(io_context_.overlapped)); @@ -74,7 +68,6 @@ int FileStream::Context::ReadAsync(IOBuffer* buf, int buf_len, const CompletionCallback& callback) { DCHECK(!async_in_progress_); - error_source_ = FILE_ERROR_SOURCE_READ; DWORD bytes_read; if (!ReadFile(file_.GetPlatformFile(), buf->data(), buf_len, @@ -86,7 +79,6 @@ int FileStream::Context::ReadAsync(IOBuffer* buf, return 0; // Report EOF by returning 0 bytes read. } else { LOG(WARNING) << "ReadFile failed: " << error.os_error; - RecordError(error, FILE_ERROR_SOURCE_READ); } return error.result; } @@ -98,8 +90,6 @@ int FileStream::Context::ReadAsync(IOBuffer* buf, int FileStream::Context::WriteAsync(IOBuffer* buf, int buf_len, const CompletionCallback& callback) { - error_source_ = FILE_ERROR_SOURCE_WRITE; - DWORD bytes_written = 0; if (!WriteFile(file_.GetPlatformFile(), buf->data(), buf_len, &bytes_written, &io_context_.overlapped)) { @@ -108,7 +98,6 @@ int FileStream::Context::WriteAsync(IOBuffer* buf, IOCompletionIsPending(callback, buf); } else { LOG(WARNING) << "WriteFile failed: " << error.os_error; - RecordError(error, FILE_ERROR_SOURCE_WRITE); } return error.result; } @@ -172,7 +161,6 @@ void FileStream::Context::OnIOCompleted( result = 0; } else if (error) { IOResult error_result = IOResult::FromOSError(error); - RecordError(error_result, error_source_); result = error_result.result; } else { result = bytes_read; diff --git a/net/base/file_stream_unittest.cc b/net/base/file_stream_unittest.cc index 5a8c279..75379e8 100644 --- a/net/base/file_stream_unittest.cc +++ b/net/base/file_stream_unittest.cc @@ -68,7 +68,7 @@ namespace { TEST_F(FileStreamTest, AsyncOpenExplicitClose) { TestCompletionCallback callback; - FileStream stream(NULL); + FileStream stream; int flags = base::File::FLAG_OPEN | base::File::FLAG_READ | base::File::FLAG_ASYNC; @@ -86,7 +86,7 @@ TEST_F(FileStreamTest, AsyncOpenExplicitClose) { TEST_F(FileStreamTest, AsyncOpenExplicitCloseOrphaned) { TestCompletionCallback callback; scoped_ptr<FileStream> stream(new FileStream( - NULL, base::MessageLoopProxy::current())); + base::MessageLoopProxy::current())); int flags = base::File::FLAG_OPEN | base::File::FLAG_READ | base::File::FLAG_ASYNC; int rv = stream->Open(temp_file_path(), flags, callback.callback()); @@ -116,7 +116,7 @@ TEST_F(FileStreamTest, UseFileHandle) { // Seek to the beginning of the file and read. scoped_ptr<FileStream> read_stream( - new FileStream(file.Pass(), NULL, base::MessageLoopProxy::current())); + new FileStream(file.Pass(), base::MessageLoopProxy::current())); ASSERT_EQ(ERR_IO_PENDING, read_stream->Seek(FROM_BEGIN, 0, callback64.callback())); ASSERT_EQ(0, callback64.WaitForResult()); @@ -135,7 +135,7 @@ TEST_F(FileStreamTest, UseFileHandle) { file.Initialize(temp_file_path(), flags); scoped_ptr<FileStream> write_stream( - new FileStream(file.Pass(), NULL, base::MessageLoopProxy::current())); + new FileStream(file.Pass(), base::MessageLoopProxy::current())); ASSERT_EQ(ERR_IO_PENDING, write_stream->Seek(FROM_BEGIN, 0, callback64.callback())); ASSERT_EQ(0, callback64.WaitForResult()); @@ -157,7 +157,7 @@ TEST_F(FileStreamTest, UseClosedStream) { TestCompletionCallback callback; TestInt64CompletionCallback callback64; - FileStream stream(NULL, base::MessageLoopProxy::current()); + FileStream stream(base::MessageLoopProxy::current()); EXPECT_FALSE(stream.IsOpen()); @@ -175,7 +175,7 @@ TEST_F(FileStreamTest, AsyncRead) { int64 file_size; EXPECT_TRUE(base::GetFileSize(temp_file_path(), &file_size)); - FileStream stream(NULL, base::MessageLoopProxy::current()); + FileStream stream(base::MessageLoopProxy::current()); int flags = base::File::FLAG_OPEN | base::File::FLAG_READ | base::File::FLAG_ASYNC; TestCompletionCallback callback; @@ -206,7 +206,7 @@ TEST_F(FileStreamTest, AsyncRead_EarlyDelete) { EXPECT_TRUE(base::GetFileSize(temp_file_path(), &file_size)); scoped_ptr<FileStream> stream( - new FileStream(NULL, base::MessageLoopProxy::current())); + new FileStream(base::MessageLoopProxy::current())); int flags = base::File::FLAG_OPEN | base::File::FLAG_READ | base::File::FLAG_ASYNC; TestCompletionCallback callback; @@ -231,7 +231,7 @@ TEST_F(FileStreamTest, AsyncRead_FromOffset) { int64 file_size; EXPECT_TRUE(base::GetFileSize(temp_file_path(), &file_size)); - FileStream stream(NULL, base::MessageLoopProxy::current()); + FileStream stream(base::MessageLoopProxy::current()); int flags = base::File::FLAG_OPEN | base::File::FLAG_READ | base::File::FLAG_ASYNC; TestCompletionCallback callback; @@ -265,7 +265,7 @@ TEST_F(FileStreamTest, AsyncRead_FromOffset) { } TEST_F(FileStreamTest, AsyncSeekAround) { - FileStream stream(NULL, base::MessageLoopProxy::current()); + FileStream stream(base::MessageLoopProxy::current()); int flags = base::File::FLAG_OPEN | base::File::FLAG_ASYNC | base::File::FLAG_READ; TestCompletionCallback callback; @@ -300,7 +300,7 @@ TEST_F(FileStreamTest, AsyncSeekAround) { } TEST_F(FileStreamTest, AsyncWrite) { - FileStream stream(NULL, base::MessageLoopProxy::current()); + FileStream stream(base::MessageLoopProxy::current()); int flags = base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE | base::File::FLAG_ASYNC; TestCompletionCallback callback; @@ -334,7 +334,7 @@ TEST_F(FileStreamTest, AsyncWrite) { TEST_F(FileStreamTest, AsyncWrite_EarlyDelete) { scoped_ptr<FileStream> stream( - new FileStream(NULL, base::MessageLoopProxy::current())); + new FileStream(base::MessageLoopProxy::current())); int flags = base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE | base::File::FLAG_ASYNC; TestCompletionCallback callback; @@ -364,7 +364,7 @@ TEST_F(FileStreamTest, AsyncWrite_FromOffset) { int64 file_size; EXPECT_TRUE(base::GetFileSize(temp_file_path(), &file_size)); - FileStream stream(NULL, base::MessageLoopProxy::current()); + FileStream stream(base::MessageLoopProxy::current()); int flags = base::File::FLAG_OPEN | base::File::FLAG_WRITE | base::File::FLAG_ASYNC; TestCompletionCallback callback; @@ -404,7 +404,7 @@ TEST_F(FileStreamTest, BasicAsyncReadWrite) { EXPECT_TRUE(base::GetFileSize(temp_file_path(), &file_size)); scoped_ptr<FileStream> stream( - new FileStream(NULL, base::MessageLoopProxy::current())); + new FileStream(base::MessageLoopProxy::current())); int flags = base::File::FLAG_OPEN | base::File::FLAG_READ | base::File::FLAG_WRITE | base::File::FLAG_ASYNC; TestCompletionCallback callback; @@ -457,7 +457,7 @@ TEST_F(FileStreamTest, BasicAsyncWriteRead) { EXPECT_TRUE(base::GetFileSize(temp_file_path(), &file_size)); scoped_ptr<FileStream> stream( - new FileStream(NULL, base::MessageLoopProxy::current())); + new FileStream(base::MessageLoopProxy::current())); int flags = base::File::FLAG_OPEN | base::File::FLAG_READ | base::File::FLAG_WRITE | base::File::FLAG_ASYNC; TestCompletionCallback callback; @@ -624,7 +624,7 @@ TEST_F(FileStreamTest, AsyncWriteRead) { EXPECT_TRUE(base::GetFileSize(temp_file_path(), &file_size)); scoped_ptr<FileStream> stream( - new FileStream(NULL, base::MessageLoopProxy::current())); + new FileStream(base::MessageLoopProxy::current())); int flags = base::File::FLAG_OPEN | base::File::FLAG_READ | base::File::FLAG_WRITE | base::File::FLAG_ASYNC; TestCompletionCallback open_callback; @@ -728,7 +728,7 @@ TEST_F(FileStreamTest, AsyncWriteClose) { EXPECT_TRUE(base::GetFileSize(temp_file_path(), &file_size)); scoped_ptr<FileStream> stream( - new FileStream(NULL, base::MessageLoopProxy::current())); + new FileStream(base::MessageLoopProxy::current())); int flags = base::File::FLAG_OPEN | base::File::FLAG_READ | base::File::FLAG_WRITE | base::File::FLAG_ASYNC; TestCompletionCallback open_callback; @@ -758,7 +758,7 @@ TEST_F(FileStreamTest, AsyncWriteClose) { TEST_F(FileStreamTest, AsyncOpenAndDelete) { scoped_ptr<FileStream> stream( - new FileStream(NULL, base::MessageLoopProxy::current())); + new FileStream(base::MessageLoopProxy::current())); int flags = base::File::FLAG_OPEN | base::File::FLAG_WRITE | base::File::FLAG_ASYNC; TestCompletionCallback open_callback; @@ -783,7 +783,7 @@ TEST_F(FileStreamTest, AsyncWriteError) { ASSERT_TRUE(file.IsValid()); scoped_ptr<FileStream> stream( - new FileStream(file.Pass(), NULL, base::MessageLoopProxy::current())); + new FileStream(file.Pass(), base::MessageLoopProxy::current())); scoped_refptr<IOBuffer> buf = new IOBuffer(1); buf->data()[0] = 0; @@ -808,7 +808,7 @@ TEST_F(FileStreamTest, AsyncReadError) { ASSERT_TRUE(file.IsValid()); scoped_ptr<FileStream> stream( - new FileStream(file.Pass(), NULL, base::MessageLoopProxy::current())); + new FileStream(file.Pass(), base::MessageLoopProxy::current())); scoped_refptr<IOBuffer> buf = new IOBuffer(1); TestCompletionCallback callback; @@ -840,7 +840,7 @@ TEST_F(FileStreamTest, ContentUriAsyncRead) { EXPECT_TRUE(base::GetFileSize(path, &file_size)); EXPECT_LT(0, file_size); - FileStream stream(NULL, base::MessageLoopProxy::current()); + FileStream stream(base::MessageLoopProxy::current()); int flags = base::File::FLAG_OPEN | base::File::FLAG_READ | base::File::FLAG_ASYNC; TestCompletionCallback callback; diff --git a/net/base/mock_file_stream.cc b/net/base/mock_file_stream.cc index 3d95994..3338fc5 100644 --- a/net/base/mock_file_stream.cc +++ b/net/base/mock_file_stream.cc @@ -11,16 +11,16 @@ namespace net { namespace testing { -MockFileStream::MockFileStream(net::NetLog* net_log) - : net::FileStream(net_log), +MockFileStream::MockFileStream() + : net::FileStream(), forced_error_(net::OK), async_error_(false), throttled_(false), weak_factory_(this) { } -MockFileStream::MockFileStream(base::File file, net::NetLog* net_log) - : net::FileStream(file.Pass(), net_log), +MockFileStream::MockFileStream(base::File file) + : net::FileStream(file.Pass()), forced_error_(net::OK), async_error_(false), throttled_(false), @@ -29,9 +29,8 @@ MockFileStream::MockFileStream(base::File file, net::NetLog* net_log) MockFileStream::MockFileStream( base::File file, - net::NetLog* net_log, const scoped_refptr<base::TaskRunner>& task_runner) - : net::FileStream(file.Pass(), net_log, task_runner), + : net::FileStream(file.Pass(), task_runner), forced_error_(net::OK), async_error_(false), throttled_(false), diff --git a/net/base/mock_file_stream.h b/net/base/mock_file_stream.h index aa44d2f..77af3fa 100644 --- a/net/base/mock_file_stream.h +++ b/net/base/mock_file_stream.h @@ -22,9 +22,9 @@ namespace testing { class MockFileStream : public net::FileStream { public: - explicit MockFileStream(net::NetLog* net_log); - MockFileStream(base::File file, net::NetLog* net_log); - MockFileStream(base::File file, net::NetLog* net_log, + MockFileStream(); + explicit MockFileStream(base::File file); + MockFileStream(base::File file, const scoped_refptr<base::TaskRunner>& task_runner); virtual ~MockFileStream(); diff --git a/net/base/upload_file_element_reader.cc b/net/base/upload_file_element_reader.cc index 75dd422..f8775ee 100644 --- a/net/base/upload_file_element_reader.cc +++ b/net/base/upload_file_element_reader.cc @@ -50,7 +50,7 @@ int UploadFileElementReader::Init(const CompletionCallback& callback) { DCHECK(!callback.is_null()); Reset(); - file_stream_.reset(new FileStream(NULL, task_runner_.get())); + file_stream_.reset(new FileStream(task_runner_.get())); int result = file_stream_->Open( path_, base::File::FLAG_OPEN | base::File::FLAG_READ | diff --git a/net/url_request/url_fetcher_response_writer.cc b/net/url_request/url_fetcher_response_writer.cc index 7db614f..76c73df0 100644 --- a/net/url_request/url_fetcher_response_writer.cc +++ b/net/url_request/url_fetcher_response_writer.cc @@ -64,7 +64,7 @@ URLFetcherFileWriter::~URLFetcherFileWriter() { } int URLFetcherFileWriter::Initialize(const CompletionCallback& callback) { - file_stream_.reset(new FileStream(NULL)); + file_stream_.reset(new FileStream()); int result = ERR_IO_PENDING; if (file_path_.empty()) { diff --git a/net/url_request/url_request_file_job.cc b/net/url_request/url_request_file_job.cc index fbff75a..011a0da 100644 --- a/net/url_request/url_request_file_job.cc +++ b/net/url_request/url_request_file_job.cc @@ -60,7 +60,7 @@ URLRequestFileJob::URLRequestFileJob( const scoped_refptr<base::TaskRunner>& file_task_runner) : URLRequestJob(request, network_delegate), file_path_(file_path), - stream_(new FileStream(NULL, file_task_runner)), + stream_(new FileStream(file_task_runner)), file_task_runner_(file_task_runner), remaining_bytes_(0), weak_ptr_factory_(this) {} diff --git a/webkit/browser/blob/local_file_stream_reader.cc b/webkit/browser/blob/local_file_stream_reader.cc index 31c4f8c..e5f35a6 100644 --- a/webkit/browser/blob/local_file_stream_reader.cc +++ b/webkit/browser/blob/local_file_stream_reader.cc @@ -89,7 +89,7 @@ void LocalFileStreamReader::DidVerifyForOpen( return; } - stream_impl_.reset(new net::FileStream(NULL, task_runner_)); + stream_impl_.reset(new net::FileStream(task_runner_)); const int result = stream_impl_->Open( file_path_, kOpenFlagsForRead, base::Bind(&LocalFileStreamReader::DidOpenFileStream, diff --git a/webkit/browser/fileapi/local_file_stream_writer.cc b/webkit/browser/fileapi/local_file_stream_writer.cc index 45e358a..a6c6a51 100644 --- a/webkit/browser/fileapi/local_file_stream_writer.cc +++ b/webkit/browser/fileapi/local_file_stream_writer.cc @@ -101,7 +101,7 @@ int LocalFileStreamWriter::InitiateOpen( DCHECK(has_pending_operation_); DCHECK(!stream_impl_.get()); - stream_impl_.reset(new net::FileStream(NULL, task_runner_)); + stream_impl_.reset(new net::FileStream(task_runner_)); int open_flags = 0; switch (open_or_create_) { |