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

Unified Diff: net/base/file_stream_posix.cc

Issue 6649012: Add ThreadRestrictions to FileStream. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address nit. Created 9 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
« no previous file with comments | « no previous file | net/base/file_stream_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/file_stream_posix.cc
diff --git a/net/base/file_stream_posix.cc b/net/base/file_stream_posix.cc
index ecf064eaa2a56e726d9a59edcb8dc728684d462f..4ea3db838a0ebf4e71abec56c35c8be3e699e1a8 100644
--- a/net/base/file_stream_posix.cc
+++ b/net/base/file_stream_posix.cc
@@ -21,6 +21,7 @@
#include "base/message_loop.h"
#include "base/metrics/histogram.h"
#include "base/string_util.h"
+#include "base/threading/thread_restrictions.h"
#include "base/threading/worker_pool.h"
#include "base/synchronization/waitable_event.h"
#include "net/base/net_errors.h"
@@ -52,6 +53,7 @@ int64 MapErrorCode(int err) {
// ReadFile() is a simple wrapper around read() that handles EINTR signals and
// calls MapErrorCode() to map errno to net error codes.
int ReadFile(base::PlatformFile file, char* buf, int buf_len) {
+ base::ThreadRestrictions::AssertIOAllowed();
// read(..., 0) returns 0 to indicate end-of-file.
// Loop in the case of getting interrupted by a signal.
@@ -65,6 +67,7 @@ int ReadFile(base::PlatformFile file, char* buf, int buf_len) {
// calls MapErrorCode() to map errno to net error codes. It tries to write to
// completion.
int WriteFile(base::PlatformFile file, const char* buf, int buf_len) {
+ base::ThreadRestrictions::AssertIOAllowed();
ssize_t res = HANDLE_EINTR(write(file, buf, buf_len));
if (res == -1)
return MapErrorCode(errno);
@@ -75,6 +78,7 @@ int WriteFile(base::PlatformFile file, const char* buf, int buf_len) {
// calls MapErrorCode() to map errno to net error codes. It tries to flush to
// completion.
int FlushFile(base::PlatformFile file) {
+ base::ThreadRestrictions::AssertIOAllowed();
ssize_t res = HANDLE_EINTR(fsync(file));
if (res == -1)
return MapErrorCode(errno);
@@ -362,6 +366,8 @@ bool FileStream::IsOpen() const {
}
int64 FileStream::Seek(Whence whence, int64 offset) {
+ base::ThreadRestrictions::AssertIOAllowed();
+
if (!IsOpen())
return ERR_UNEXPECTED;
@@ -377,6 +383,8 @@ int64 FileStream::Seek(Whence whence, int64 offset) {
}
int64 FileStream::Available() {
+ base::ThreadRestrictions::AssertIOAllowed();
+
if (!IsOpen())
return ERR_UNEXPECTED;
@@ -438,7 +446,7 @@ int FileStream::ReadUntilComplete(char *buf, int buf_len) {
int FileStream::Write(
const char* buf, int buf_len, CompletionCallback* callback) {
// write(..., 0) will return 0, which indicates end-of-file.
- DCHECK(buf_len > 0);
+ DCHECK_GT(buf_len, 0);
if (!IsOpen())
return ERR_UNEXPECTED;
@@ -455,6 +463,8 @@ int FileStream::Write(
}
int64 FileStream::Truncate(int64 bytes) {
+ base::ThreadRestrictions::AssertIOAllowed();
+
if (!IsOpen())
return ERR_UNEXPECTED;
« no previous file with comments | « no previous file | net/base/file_stream_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698