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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 IOCompletionIsPending(callback, buf); | 107 IOCompletionIsPending(callback, buf); |
108 else | 108 else |
109 LOG(WARNING) << "WriteFile failed: " << error.os_error; | 109 LOG(WARNING) << "WriteFile failed: " << error.os_error; |
110 return static_cast<int>(error.result); | 110 return static_cast<int>(error.result); |
111 } | 111 } |
112 | 112 |
113 IOCompletionIsPending(callback, buf); | 113 IOCompletionIsPending(callback, buf); |
114 return ERR_IO_PENDING; | 114 return ERR_IO_PENDING; |
115 } | 115 } |
116 | 116 |
117 FileStream::Context::IOResult FileStream::Context::SeekFileImpl( | 117 FileStream::Context::IOResult FileStream::Context::SeekFileImpl(int64 offset) { |
davidben
2015/05/21 17:22:12
If I'm understanding this correctly, not calling s
| |
118 base::File::Whence whence, | |
119 int64 offset) { | |
120 LARGE_INTEGER result; | 118 LARGE_INTEGER result; |
121 result.QuadPart = file_.Seek(whence, offset); | 119 result.QuadPart = offset; |
122 if (result.QuadPart >= 0) { | 120 SetOffset(&io_context_.overlapped, result); |
123 SetOffset(&io_context_.overlapped, result); | 121 return IOResult(result.QuadPart, 0); |
124 return IOResult(result.QuadPart, 0); | |
125 } | |
126 | |
127 return IOResult::FromOSError(GetLastError()); | |
128 } | 122 } |
129 | 123 |
130 void FileStream::Context::OnFileOpened() { | 124 void FileStream::Context::OnFileOpened() { |
131 base::MessageLoopForIO::current()->RegisterIOHandler(file_.GetPlatformFile(), | 125 base::MessageLoopForIO::current()->RegisterIOHandler(file_.GetPlatformFile(), |
132 this); | 126 this); |
133 } | 127 } |
134 | 128 |
135 void FileStream::Context::IOCompletionIsPending( | 129 void FileStream::Context::IOCompletionIsPending( |
136 const CompletionCallback& callback, | 130 const CompletionCallback& callback, |
137 IOBuffer* buf) { | 131 IOBuffer* buf) { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
241 | 235 |
242 IOResult error = IOResult::FromOSError(os_error); | 236 IOResult error = IOResult::FromOSError(os_error); |
243 if (error.os_error == ERROR_IO_PENDING) { | 237 if (error.os_error == ERROR_IO_PENDING) { |
244 InvokeUserCallback(); | 238 InvokeUserCallback(); |
245 } else { | 239 } else { |
246 OnIOCompleted(&io_context_, 0, error.os_error); | 240 OnIOCompleted(&io_context_, 0, error.os_error); |
247 } | 241 } |
248 } | 242 } |
249 | 243 |
250 } // namespace net | 244 } // namespace net |
OLD | NEW |