| 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_context.h" | 5 #include "net/base/file_stream_context.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 return IOResult::FromOSError(GetLastError()); | 189 return IOResult::FromOSError(GetLastError()); |
| 190 } | 190 } |
| 191 | 191 |
| 192 FileStream::Context::IOResult FileStream::Context::FlushFileImpl() { | 192 FileStream::Context::IOResult FileStream::Context::FlushFileImpl() { |
| 193 if (FlushFileBuffers(file_)) | 193 if (FlushFileBuffers(file_)) |
| 194 return IOResult(OK, 0); | 194 return IOResult(OK, 0); |
| 195 | 195 |
| 196 return IOResult::FromOSError(GetLastError()); | 196 return IOResult::FromOSError(GetLastError()); |
| 197 } | 197 } |
| 198 | 198 |
| 199 FileStream::Context::IOResult FileStream::Context::CloseFileImpl() { |
| 200 bool success = base::ClosePlatformFile(file_); |
| 201 file_ = base::kInvalidPlatformFileValue; |
| 202 if (success) |
| 203 return IOResult(OK, 0); |
| 204 |
| 205 return IOResult::FromOSError(GetLastError()); |
| 206 } |
| 207 |
| 199 void FileStream::Context::IOCompletionIsPending( | 208 void FileStream::Context::IOCompletionIsPending( |
| 200 const CompletionCallback& callback, | 209 const CompletionCallback& callback, |
| 201 IOBuffer* buf) { | 210 IOBuffer* buf) { |
| 202 DCHECK(callback_.is_null()); | 211 DCHECK(callback_.is_null()); |
| 203 callback_ = callback; | 212 callback_ = callback; |
| 204 in_flight_buf_ = buf; // Hold until the async operation ends. | 213 in_flight_buf_ = buf; // Hold until the async operation ends. |
| 205 async_in_progress_ = true; | 214 async_in_progress_ = true; |
| 206 } | 215 } |
| 207 | 216 |
| 208 void FileStream::Context::OnIOCompleted( | 217 void FileStream::Context::OnIOCompleted( |
| (...skipping 25 matching lines...) Expand all Loading... |
| 234 } | 243 } |
| 235 | 244 |
| 236 CompletionCallback temp_callback = callback_; | 245 CompletionCallback temp_callback = callback_; |
| 237 callback_.Reset(); | 246 callback_.Reset(); |
| 238 scoped_refptr<IOBuffer> temp_buf = in_flight_buf_; | 247 scoped_refptr<IOBuffer> temp_buf = in_flight_buf_; |
| 239 in_flight_buf_ = NULL; | 248 in_flight_buf_ = NULL; |
| 240 temp_callback.Run(result); | 249 temp_callback.Run(result); |
| 241 } | 250 } |
| 242 | 251 |
| 243 } // namespace net | 252 } // namespace net |
| OLD | NEW |