OLD | NEW |
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 void* info) { | 80 void* info) { |
81 return TRUE; | 81 return TRUE; |
82 } | 82 } |
83 | 83 |
84 static CFIndex Read(CFReadStreamRef stream, | 84 static CFIndex Read(CFReadStreamRef stream, |
85 UInt8* buffer, | 85 UInt8* buffer, |
86 CFIndex buffer_length, | 86 CFIndex buffer_length, |
87 CFStreamError* error, | 87 CFStreamError* error, |
88 Boolean* at_eof, | 88 Boolean* at_eof, |
89 void* info) { | 89 void* info) { |
90 if (buffer_length == 0) | 90 if (buffer_length == 0) { |
| 91 *at_eof = FALSE; |
91 return 0; | 92 return 0; |
| 93 } |
92 | 94 |
93 ssize_t bytes_read = GetStream(info)->GetBytesBuffer(buffer, buffer_length); | 95 ssize_t bytes_read = GetStream(info)->GetBytesBuffer(buffer, buffer_length); |
94 if (bytes_read == 0) { | 96 if (bytes_read < 0) { |
95 *at_eof = TRUE; | |
96 } else if (bytes_read < 0) { | |
97 error->error = -1; | 97 error->error = -1; |
98 error->domain = kCFStreamErrorDomainCustom; | 98 error->domain = kCFStreamErrorDomainCustom; |
| 99 } else { |
| 100 *at_eof = bytes_read == 0; |
99 } | 101 } |
100 | 102 |
101 return bytes_read; | 103 return bytes_read; |
102 } | 104 } |
103 | 105 |
104 static const UInt8* GetBuffer(CFReadStreamRef stream, | 106 static const UInt8* GetBuffer(CFReadStreamRef stream, |
105 CFIndex max_bytes_to_read, | 107 CFIndex max_bytes_to_read, |
106 CFIndex* num_bytes_read, | 108 CFIndex* num_bytes_read, |
107 CFStreamError* error, | 109 CFStreamError* error, |
108 Boolean* at_eof, | 110 Boolean* at_eof, |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 } | 216 } |
215 | 217 |
216 } // namespace | 218 } // namespace |
217 | 219 |
218 // static | 220 // static |
219 scoped_ptr<HTTPTransport> HTTPTransport::Create() { | 221 scoped_ptr<HTTPTransport> HTTPTransport::Create() { |
220 return scoped_ptr<HTTPTransport>(new HTTPTransportMac()); | 222 return scoped_ptr<HTTPTransport>(new HTTPTransportMac()); |
221 } | 223 } |
222 | 224 |
223 } // namespace crashpad | 225 } // namespace crashpad |
OLD | NEW |