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

Side by Side Diff: util/file/file_io_win.cc

Issue 1419673007: Remove usage of compat from client (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 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
« no previous file with comments | « util/file/file_io_posix.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 nullptr, 65 nullptr,
66 disposition, 66 disposition,
67 FILE_ATTRIBUTE_NORMAL, 67 FILE_ATTRIBUTE_NORMAL,
68 nullptr); 68 nullptr);
69 } 69 }
70 70
71 } // namespace 71 } // namespace
72 72
73 // TODO(scottmg): Handle > DWORD sized writes if necessary. 73 // TODO(scottmg): Handle > DWORD sized writes if necessary.
74 74
75 ssize_t ReadFile(FileHandle file, void* buffer, size_t size) { 75 FileOperationResult ReadFile(FileHandle file, void* buffer, size_t size) {
76 DCHECK(!IsSocketHandle(file)); 76 DCHECK(!IsSocketHandle(file));
77 DWORD size_dword = base::checked_cast<DWORD>(size); 77 DWORD size_dword = base::checked_cast<DWORD>(size);
78 DWORD total_read = 0; 78 DWORD total_read = 0;
79 char* buffer_c = reinterpret_cast<char*>(buffer); 79 char* buffer_c = reinterpret_cast<char*>(buffer);
80 while (size_dword > 0) { 80 while (size_dword > 0) {
81 DWORD bytes_read; 81 DWORD bytes_read;
82 BOOL success = ::ReadFile(file, buffer_c, size_dword, &bytes_read, nullptr); 82 BOOL success = ::ReadFile(file, buffer_c, size_dword, &bytes_read, nullptr);
83 if (!success) { 83 if (!success) {
84 if (GetLastError() == ERROR_BROKEN_PIPE) { 84 if (GetLastError() == ERROR_BROKEN_PIPE) {
85 // When reading a pipe and the write handle has been closed, ReadFile 85 // When reading a pipe and the write handle has been closed, ReadFile
(...skipping 10 matching lines...) Expand all
96 break; 96 break;
97 } 97 }
98 98
99 buffer_c += bytes_read; 99 buffer_c += bytes_read;
100 size_dword -= bytes_read; 100 size_dword -= bytes_read;
101 total_read += bytes_read; 101 total_read += bytes_read;
102 } 102 }
103 return total_read; 103 return total_read;
104 } 104 }
105 105
106 ssize_t WriteFile(FileHandle file, const void* buffer, size_t size) { 106 FileOperationResult WriteFile(FileHandle file,
107 const void* buffer,
108 size_t size) {
107 // TODO(scottmg): This might need to handle the limit for pipes across a 109 // TODO(scottmg): This might need to handle the limit for pipes across a
108 // network in the future. 110 // network in the future.
109 DWORD size_dword = base::checked_cast<DWORD>(size); 111 DWORD size_dword = base::checked_cast<DWORD>(size);
110 DWORD bytes_written; 112 DWORD bytes_written;
111 BOOL rv = ::WriteFile(file, buffer, size_dword, &bytes_written, nullptr); 113 BOOL rv = ::WriteFile(file, buffer, size_dword, &bytes_written, nullptr);
112 if (!rv) 114 if (!rv)
113 return -1; 115 return -1;
114 CHECK_EQ(bytes_written, size_dword); 116 CHECK_EQ(bytes_written, size_dword);
115 return bytes_written; 117 return bytes_written;
116 } 118 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 return true; 230 return true;
229 } 231 }
230 232
231 bool LoggingCloseFile(FileHandle file) { 233 bool LoggingCloseFile(FileHandle file) {
232 BOOL rv = CloseHandle(file); 234 BOOL rv = CloseHandle(file);
233 PLOG_IF(ERROR, !rv) << "CloseHandle"; 235 PLOG_IF(ERROR, !rv) << "CloseHandle";
234 return rv; 236 return rv;
235 } 237 }
236 238
237 } // namespace crashpad 239 } // namespace crashpad
OLDNEW
« no previous file with comments | « util/file/file_io_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698