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

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

Issue 647883002: git cl format the final third of the net/base directory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
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"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 FileStream::Context::~Context() { 59 FileStream::Context::~Context() {
60 } 60 }
61 61
62 int FileStream::Context::Read(IOBuffer* buf, 62 int FileStream::Context::Read(IOBuffer* buf,
63 int buf_len, 63 int buf_len,
64 const CompletionCallback& callback) { 64 const CompletionCallback& callback) {
65 DCHECK(!async_in_progress_); 65 DCHECK(!async_in_progress_);
66 66
67 DWORD bytes_read; 67 DWORD bytes_read;
68 if (!ReadFile(file_.GetPlatformFile(), buf->data(), buf_len, 68 if (!ReadFile(file_.GetPlatformFile(),
69 &bytes_read, &io_context_.overlapped)) { 69 buf->data(),
70 buf_len,
71 &bytes_read,
72 &io_context_.overlapped)) {
70 IOResult error = IOResult::FromOSError(GetLastError()); 73 IOResult error = IOResult::FromOSError(GetLastError());
71 if (error.os_error == ERROR_IO_PENDING) { 74 if (error.os_error == ERROR_IO_PENDING) {
72 IOCompletionIsPending(callback, buf); 75 IOCompletionIsPending(callback, buf);
73 } else if (error.os_error == ERROR_HANDLE_EOF) { 76 } else if (error.os_error == ERROR_HANDLE_EOF) {
74 return 0; // Report EOF by returning 0 bytes read. 77 return 0; // Report EOF by returning 0 bytes read.
75 } else { 78 } else {
76 LOG(WARNING) << "ReadFile failed: " << error.os_error; 79 LOG(WARNING) << "ReadFile failed: " << error.os_error;
77 } 80 }
78 return error.result; 81 return error.result;
79 } 82 }
80 83
81 IOCompletionIsPending(callback, buf); 84 IOCompletionIsPending(callback, buf);
82 return ERR_IO_PENDING; 85 return ERR_IO_PENDING;
83 } 86 }
84 87
85 int FileStream::Context::Write(IOBuffer* buf, 88 int FileStream::Context::Write(IOBuffer* buf,
86 int buf_len, 89 int buf_len,
87 const CompletionCallback& callback) { 90 const CompletionCallback& callback) {
88 DWORD bytes_written = 0; 91 DWORD bytes_written = 0;
89 if (!WriteFile(file_.GetPlatformFile(), buf->data(), buf_len, 92 if (!WriteFile(file_.GetPlatformFile(),
90 &bytes_written, &io_context_.overlapped)) { 93 buf->data(),
94 buf_len,
95 &bytes_written,
96 &io_context_.overlapped)) {
91 IOResult error = IOResult::FromOSError(GetLastError()); 97 IOResult error = IOResult::FromOSError(GetLastError());
92 if (error.os_error == ERROR_IO_PENDING) { 98 if (error.os_error == ERROR_IO_PENDING) {
93 IOCompletionIsPending(callback, buf); 99 IOCompletionIsPending(callback, buf);
94 } else { 100 } else {
95 LOG(WARNING) << "WriteFile failed: " << error.os_error; 101 LOG(WARNING) << "WriteFile failed: " << error.os_error;
96 } 102 }
97 return error.result; 103 return error.result;
98 } 104 }
99 105
100 IOCompletionIsPending(callback, buf); 106 IOCompletionIsPending(callback, buf);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 } 162 }
157 163
158 CompletionCallback temp_callback = callback_; 164 CompletionCallback temp_callback = callback_;
159 callback_.Reset(); 165 callback_.Reset();
160 scoped_refptr<IOBuffer> temp_buf = in_flight_buf_; 166 scoped_refptr<IOBuffer> temp_buf = in_flight_buf_;
161 in_flight_buf_ = NULL; 167 in_flight_buf_ = NULL;
162 temp_callback.Run(result); 168 temp_callback.Run(result);
163 } 169 }
164 170
165 } // namespace net 171 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698