| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/base/file_stream.h" | 5 #include "net/base/file_stream.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 // make sure we will perform asynchronous File IO to it. | 162 // make sure we will perform asynchronous File IO to it. |
| 163 if (flags & base::PLATFORM_FILE_ASYNC) { | 163 if (flags & base::PLATFORM_FILE_ASYNC) { |
| 164 async_context_.reset(new AsyncContext(bound_net_log_)); | 164 async_context_.reset(new AsyncContext(bound_net_log_)); |
| 165 MessageLoopForIO::current()->RegisterIOHandler(file_, | 165 MessageLoopForIO::current()->RegisterIOHandler(file_, |
| 166 async_context_.get()); | 166 async_context_.get()); |
| 167 } | 167 } |
| 168 } | 168 } |
| 169 | 169 |
| 170 FileStream::~FileStream() { | 170 FileStream::~FileStream() { |
| 171 if (auto_closed_) | 171 if (auto_closed_) |
| 172 Close(); | 172 CloseSync(); |
| 173 | 173 |
| 174 bound_net_log_.EndEvent(net::NetLog::TYPE_FILE_STREAM_ALIVE, NULL); | 174 bound_net_log_.EndEvent(net::NetLog::TYPE_FILE_STREAM_ALIVE, NULL); |
| 175 } | 175 } |
| 176 | 176 |
| 177 void FileStream::Close() { | 177 void FileStream::CloseSync() { |
| 178 bound_net_log_.AddEvent(net::NetLog::TYPE_FILE_STREAM_CLOSE, NULL); | 178 bound_net_log_.AddEvent(net::NetLog::TYPE_FILE_STREAM_CLOSE, NULL); |
| 179 if (file_ != INVALID_HANDLE_VALUE) | 179 if (file_ != INVALID_HANDLE_VALUE) |
| 180 CancelIo(file_); | 180 CancelIo(file_); |
| 181 | 181 |
| 182 async_context_.reset(); | 182 async_context_.reset(); |
| 183 if (file_ != INVALID_HANDLE_VALUE) { | 183 if (file_ != INVALID_HANDLE_VALUE) { |
| 184 if (!base::ClosePlatformFile(file_)) | 184 if (!base::ClosePlatformFile(file_)) |
| 185 NOTREACHED(); | 185 NOTREACHED(); |
| 186 file_ = INVALID_HANDLE_VALUE; | 186 file_ = INVALID_HANDLE_VALUE; |
| 187 | 187 |
| 188 bound_net_log_.EndEvent(net::NetLog::TYPE_FILE_STREAM_OPEN, NULL); | 188 bound_net_log_.EndEvent(net::NetLog::TYPE_FILE_STREAM_OPEN, NULL); |
| 189 } | 189 } |
| 190 } | 190 } |
| 191 | 191 |
| 192 int FileStream::Open(const FilePath& path, int open_flags) { | 192 int FileStream::OpenSync(const FilePath& path, int open_flags) { |
| 193 if (IsOpen()) { | 193 if (IsOpen()) { |
| 194 DLOG(FATAL) << "File is already open!"; | 194 DLOG(FATAL) << "File is already open!"; |
| 195 return ERR_UNEXPECTED; | 195 return ERR_UNEXPECTED; |
| 196 } | 196 } |
| 197 | 197 |
| 198 bound_net_log_.BeginEvent( | 198 bound_net_log_.BeginEvent( |
| 199 net::NetLog::TYPE_FILE_STREAM_OPEN, | 199 net::NetLog::TYPE_FILE_STREAM_OPEN, |
| 200 make_scoped_refptr( | 200 make_scoped_refptr( |
| 201 new net::NetLogStringParameter("file_name", | 201 new net::NetLogStringParameter("file_name", |
| 202 path.AsUTF8Unsafe()))); | 202 path.AsUTF8Unsafe()))); |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 owner_bound_net_log.source()))); | 453 owner_bound_net_log.source()))); |
| 454 | 454 |
| 455 owner_bound_net_log.AddEvent( | 455 owner_bound_net_log.AddEvent( |
| 456 net::NetLog::TYPE_FILE_STREAM_SOURCE, | 456 net::NetLog::TYPE_FILE_STREAM_SOURCE, |
| 457 make_scoped_refptr( | 457 make_scoped_refptr( |
| 458 new net::NetLogSourceParameter("source_dependency", | 458 new net::NetLogSourceParameter("source_dependency", |
| 459 bound_net_log_.source()))); | 459 bound_net_log_.source()))); |
| 460 } | 460 } |
| 461 | 461 |
| 462 } // namespace net | 462 } // namespace net |
| OLD | NEW |