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

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

Issue 880763002: Reorganize Multiprocess and implement for Windows (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: . Created 5 years, 10 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 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 26 matching lines...) Expand all
37 // TODO(scottmg): Handle > DWORD sized writes if necessary. 37 // TODO(scottmg): Handle > DWORD sized writes if necessary.
38 38
39 ssize_t ReadFile(FileHandle file, void* buffer, size_t size) { 39 ssize_t ReadFile(FileHandle file, void* buffer, size_t size) {
40 DCHECK(!IsSocketHandle(file)); 40 DCHECK(!IsSocketHandle(file));
41 DWORD size_dword = base::checked_cast<DWORD>(size); 41 DWORD size_dword = base::checked_cast<DWORD>(size);
42 DWORD total_read = 0; 42 DWORD total_read = 0;
43 char* buffer_c = reinterpret_cast<char*>(buffer); 43 char* buffer_c = reinterpret_cast<char*>(buffer);
44 while (size_dword > 0) { 44 while (size_dword > 0) {
45 DWORD bytes_read; 45 DWORD bytes_read;
46 BOOL success = ::ReadFile(file, buffer_c, size_dword, &bytes_read, nullptr); 46 BOOL success = ::ReadFile(file, buffer_c, size_dword, &bytes_read, nullptr);
47 if (!success && GetLastError() != ERROR_MORE_DATA) { 47 if (!success && GetLastError() == ERROR_BROKEN_PIPE) {
Mark Mentovai 2015/01/28 19:58:27 A light restructuring to keep rechecking the same
scottmg 2015/01/28 22:14:57 Done.
48 // When reading a pipe and the write handle has been closed, ReadFile
49 // fails with ERROR_BROKEN_PIPE, but only once all pending data has been
50 // read.
51 break;
52 } else if (!success && GetLastError() != ERROR_MORE_DATA) {
48 return -1; 53 return -1;
49 } else if (success && bytes_read == 0 && 54 } else if (success && bytes_read == 0 &&
50 GetFileType(file) != FILE_TYPE_PIPE) { 55 GetFileType(file) != FILE_TYPE_PIPE) {
51 // Zero bytes read for a file indicates reaching EOF. Zero bytes read from 56 // Zero bytes read for a file indicates reaching EOF. Zero bytes read from
52 // a pipe indicates only that there was a zero byte WriteFile issued on 57 // a pipe indicates only that there was a zero byte WriteFile issued on
53 // the other end, so continue reading. 58 // the other end, so continue reading.
54 break; 59 break;
55 } 60 }
56 61
57 buffer_c += bytes_read; 62 buffer_c += bytes_read;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 return new_offset.QuadPart; 136 return new_offset.QuadPart;
132 } 137 }
133 138
134 bool LoggingCloseFile(FileHandle file) { 139 bool LoggingCloseFile(FileHandle file) {
135 BOOL rv = CloseHandle(file); 140 BOOL rv = CloseHandle(file);
136 PLOG_IF(ERROR, !rv) << "CloseHandle"; 141 PLOG_IF(ERROR, !rv) << "CloseHandle";
137 return rv; 142 return rv;
138 } 143 }
139 144
140 } // namespace crashpad 145 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698