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

Side by Side Diff: net/base/file_stream_context_win.cc

Issue 1841863002: Update monet. (Closed) Base URL: https://github.com/domokit/monet.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « net/base/file_stream_context.cc ('k') | net/base/file_stream_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/message_loop/message_loop_proxy.h"
13 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
14 #include "base/task_runner.h" 13 #include "base/task_runner.h"
15 #include "base/threading/worker_pool.h" 14 #include "base/threading/worker_pool.h"
16 #include "net/base/io_buffer.h" 15 #include "net/base/io_buffer.h"
17 #include "net/base/net_errors.h" 16 #include "net/base/net_errors.h"
18 17
19 namespace net { 18 namespace net {
20 19
21 namespace { 20 namespace {
22 21
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 IOCompletionIsPending(callback, buf); 80 IOCompletionIsPending(callback, buf);
82 81
83 async_read_initiated_ = true; 82 async_read_initiated_ = true;
84 result_ = 0; 83 result_ = 0;
85 84
86 task_runner_->PostTask( 85 task_runner_->PostTask(
87 FROM_HERE, 86 FROM_HERE,
88 base::Bind(&FileStream::Context::ReadAsync, base::Unretained(this), 87 base::Bind(&FileStream::Context::ReadAsync, base::Unretained(this),
89 file_.GetPlatformFile(), make_scoped_refptr(buf), buf_len, 88 file_.GetPlatformFile(), make_scoped_refptr(buf), buf_len,
90 &io_context_.overlapped, 89 &io_context_.overlapped,
91 base::MessageLoop::current()->message_loop_proxy())); 90 base::MessageLoop::current()->task_runner()));
92 return ERR_IO_PENDING; 91 return ERR_IO_PENDING;
93 } 92 }
94 93
95 int FileStream::Context::Write(IOBuffer* buf, 94 int FileStream::Context::Write(IOBuffer* buf,
96 int buf_len, 95 int buf_len,
97 const CompletionCallback& callback) { 96 const CompletionCallback& callback) {
98 CHECK(!async_in_progress_); 97 CHECK(!async_in_progress_);
99 98
100 result_ = 0; 99 result_ = 0;
101 100
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 CloseAndDelete(); 205 CloseAndDelete();
207 } 206 }
208 207
209 // static 208 // static
210 void FileStream::Context::ReadAsync( 209 void FileStream::Context::ReadAsync(
211 FileStream::Context* context, 210 FileStream::Context* context,
212 HANDLE file, 211 HANDLE file,
213 scoped_refptr<IOBuffer> buf, 212 scoped_refptr<IOBuffer> buf,
214 int buf_len, 213 int buf_len,
215 OVERLAPPED* overlapped, 214 OVERLAPPED* overlapped,
216 scoped_refptr<base::MessageLoopProxy> origin_thread_loop) { 215 scoped_refptr<base::SingleThreadTaskRunner> origin_thread_loop) {
217 DWORD bytes_read = 0; 216 DWORD bytes_read = 0;
218 BOOL ret = ::ReadFile(file, buf->data(), buf_len, &bytes_read, overlapped); 217 BOOL ret = ::ReadFile(file, buf->data(), buf_len, &bytes_read, overlapped);
219 origin_thread_loop->PostTask( 218 origin_thread_loop->PostTask(
220 FROM_HERE, 219 FROM_HERE,
221 base::Bind(&FileStream::Context::ReadAsyncResult, 220 base::Bind(&FileStream::Context::ReadAsyncResult,
222 base::Unretained(context), ret, bytes_read, ::GetLastError())); 221 base::Unretained(context), ret, bytes_read, ::GetLastError()));
223 } 222 }
224 223
225 void FileStream::Context::ReadAsyncResult(BOOL read_file_ret, 224 void FileStream::Context::ReadAsyncResult(BOOL read_file_ret,
226 DWORD bytes_read, 225 DWORD bytes_read,
(...skipping 14 matching lines...) Expand all
241 240
242 IOResult error = IOResult::FromOSError(os_error); 241 IOResult error = IOResult::FromOSError(os_error);
243 if (error.os_error == ERROR_IO_PENDING) { 242 if (error.os_error == ERROR_IO_PENDING) {
244 InvokeUserCallback(); 243 InvokeUserCallback();
245 } else { 244 } else {
246 OnIOCompleted(&io_context_, 0, error.os_error); 245 OnIOCompleted(&io_context_, 0, error.os_error);
247 } 246 }
248 } 247 }
249 248
250 } // namespace net 249 } // namespace net
OLDNEW
« no previous file with comments | « net/base/file_stream_context.cc ('k') | net/base/file_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698