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

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: fixes 2 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
« no previous file with comments | « snapshot/mac/process_reader_test.cc ('k') | util/mach/exception_ports_test.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 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) {
48 return -1; 48 if (GetLastError() == ERROR_BROKEN_PIPE) {
49 } else if (success && bytes_read == 0 && 49 // When reading a pipe and the write handle has been closed, ReadFile
50 GetFileType(file) != FILE_TYPE_PIPE) { 50 // fails with ERROR_BROKEN_PIPE, but only once all pending data has been
51 // read.
52 break;
53 } else if (GetLastError() != ERROR_MORE_DATA) {
54 return -1;
55 }
56 } else if (bytes_read == 0 && GetFileType(file) != FILE_TYPE_PIPE) {
51 // Zero bytes read for a file indicates reaching EOF. Zero bytes read from 57 // 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 58 // a pipe indicates only that there was a zero byte WriteFile issued on
53 // the other end, so continue reading. 59 // the other end, so continue reading.
54 break; 60 break;
55 } 61 }
56 62
57 buffer_c += bytes_read; 63 buffer_c += bytes_read;
58 size_dword -= bytes_read; 64 size_dword -= bytes_read;
59 total_read += bytes_read; 65 total_read += bytes_read;
60 } 66 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 return new_offset.QuadPart; 137 return new_offset.QuadPart;
132 } 138 }
133 139
134 bool LoggingCloseFile(FileHandle file) { 140 bool LoggingCloseFile(FileHandle file) {
135 BOOL rv = CloseHandle(file); 141 BOOL rv = CloseHandle(file);
136 PLOG_IF(ERROR, !rv) << "CloseHandle"; 142 PLOG_IF(ERROR, !rv) << "CloseHandle";
137 return rv; 143 return rv;
138 } 144 }
139 145
140 } // namespace crashpad 146 } // namespace crashpad
OLDNEW
« no previous file with comments | « snapshot/mac/process_reader_test.cc ('k') | util/mach/exception_ports_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698