Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Unified Diff: net/base/file_stream_context.h

Issue 189393002: net: Update FileStream to use base::File instead of PlatformFile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/base/file_stream_context.h
diff --git a/net/base/file_stream_context.h b/net/base/file_stream_context.h
index 3ce8a5b6cdc9cb7decd553e50aa4cb05f66eac69..78915d50b6cab7afa56dbdfa16d5a80a99525e58 100644
--- a/net/base/file_stream_context.h
+++ b/net/base/file_stream_context.h
@@ -27,8 +27,9 @@
#ifndef NET_BASE_FILE_STREAM_CONTEXT_H_
#define NET_BASE_FILE_STREAM_CONTEXT_H_
+#include "base/files/file.h"
#include "base/message_loop/message_loop.h"
-#include "base/platform_file.h"
+#include "base/move.h"
#include "base/task_runner.h"
#include "net/base/completion_callback.h"
#include "net/base/file_stream.h"
@@ -61,9 +62,15 @@ class FileStream::Context {
Context(const BoundNetLog& bound_net_log,
const scoped_refptr<base::TaskRunner>& task_runner);
- Context(base::PlatformFile file,
+ Context(base::File file,
+ const BoundNetLog& bound_net_log,
+ const scoped_refptr<base::TaskRunner>& task_runner);
+
+ // This is a deprecated constructor intended only to support callers that
+ // provide a PlatformFile. Such callers are to be updated to provide a File.
+ Context(base::File file,
+ int flags,
const BoundNetLog& bound_net_log,
- int open_flags,
const scoped_refptr<base::TaskRunner>& task_runner);
#if defined(OS_WIN)
virtual ~Context();
@@ -90,8 +97,9 @@ class FileStream::Context {
////////////////////////////////////////////////////////////////////////////
void set_record_uma(bool value) { record_uma_ = value; }
- base::PlatformFile file() const { return file_; }
+ const base::File& file() const { return file_; }
bool async_in_progress() const { return async_in_progress_; }
+ bool async() const { return async_in_progress_ || async_ || file_.async(); }
////////////////////////////////////////////////////////////////////////////
// Platform-independent methods implemented in file_stream_context.cc.
@@ -133,10 +141,16 @@ class FileStream::Context {
int os_error; // Set only when result < 0.
};
- struct OpenResult {
+ class OpenResult {
willchan no longer on Chromium 2014/03/18 20:36:56 I chatted with jyasskin (c++ committee member and
rvargas (doing something else) 2014/03/19 01:03:18 I guess it looks weird in any case. I mean, having
rvargas (doing something else) 2014/03/19 19:01:48 Tentatively back to struct
willchan no longer on Chromium 2014/03/19 22:36:35 It's just a minor preference. The reason is that t
+ MOVE_ONLY_TYPE_FOR_CPP_03(OpenResult, RValue)
+ public:
OpenResult();
- OpenResult(base::PlatformFile file, IOResult error_code);
- base::PlatformFile file;
+ OpenResult(base::File file, IOResult error_code);
+ // C++03 move emulation of this type.
+ OpenResult(RValue other);
+ OpenResult& operator=(RValue other);
+
+ base::File file;
IOResult error_code;
};
@@ -147,6 +161,8 @@ class FileStream::Context {
OpenResult OpenFileImpl(const base::FilePath& path, int open_flags);
+ IOResult CloseFileImpl();
+
void ProcessOpenError(const IOResult& result);
void OnOpenCompleted(const CompletionCallback& callback,
OpenResult open_result);
@@ -193,9 +209,6 @@ class FileStream::Context {
// Flushes all data written to the stream.
IOResult FlushFileImpl();
- // Closes the file.
- IOResult CloseFileImpl();
-
#if defined(OS_WIN)
void IOCompletionIsPending(const CompletionCallback& callback, IOBuffer* buf);
@@ -214,10 +227,11 @@ class FileStream::Context {
IOResult WriteFileImpl(scoped_refptr<IOBuffer> buf, int buf_len);
#endif
- base::PlatformFile file_;
+ base::File file_;
bool record_uma_;
bool async_in_progress_;
bool orphaned_;
+ bool async_; // To be removed when flags are removed from the constructor.
BoundNetLog bound_net_log_;
scoped_refptr<base::TaskRunner> task_runner_;

Powered by Google App Engine
This is Rietveld 408576698