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, |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
13 // limitations under the License. | 13 // limitations under the License. |
14 | 14 |
15 #include "util/net/http_transport.h" | 15 #include "util/net/http_transport.h" |
16 | 16 |
17 #include <CoreFoundation/CoreFoundation.h> | 17 #include <CoreFoundation/CoreFoundation.h> |
18 #import <Foundation/Foundation.h> | 18 #import <Foundation/Foundation.h> |
19 | 19 |
20 #include "base/mac/foundation_util.h" | 20 #include "base/mac/foundation_util.h" |
21 #import "base/mac/scoped_nsobject.h" | 21 #import "base/mac/scoped_nsobject.h" |
22 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
23 #include "base/strings/sys_string_conversions.h" | 23 #include "base/strings/sys_string_conversions.h" |
24 #include "third_party/apple_cf/CFStreamAbstract.h" | 24 #include "third_party/apple_cf/CFStreamAbstract.h" |
| 25 #include "util/file/file_io.h" |
25 #include "util/misc/implicit_cast.h" | 26 #include "util/misc/implicit_cast.h" |
26 #include "util/net/http_body.h" | 27 #include "util/net/http_body.h" |
27 | 28 |
28 namespace crashpad { | 29 namespace crashpad { |
29 | 30 |
30 namespace { | 31 namespace { |
31 | 32 |
32 // An implementation of CFReadStream. This implements the V0 callback | 33 // An implementation of CFReadStream. This implements the V0 callback |
33 // scheme. | 34 // scheme. |
34 class HTTPBodyStreamCFReadStream { | 35 class HTTPBodyStreamCFReadStream { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 UInt8* buffer, | 87 UInt8* buffer, |
87 CFIndex buffer_length, | 88 CFIndex buffer_length, |
88 CFStreamError* error, | 89 CFStreamError* error, |
89 Boolean* at_eof, | 90 Boolean* at_eof, |
90 void* info) { | 91 void* info) { |
91 if (buffer_length == 0) { | 92 if (buffer_length == 0) { |
92 *at_eof = FALSE; | 93 *at_eof = FALSE; |
93 return 0; | 94 return 0; |
94 } | 95 } |
95 | 96 |
96 ssize_t bytes_read = GetStream(info)->GetBytesBuffer(buffer, buffer_length); | 97 FileOperationResult bytes_read = |
| 98 GetStream(info)->GetBytesBuffer(buffer, buffer_length); |
97 if (bytes_read < 0) { | 99 if (bytes_read < 0) { |
98 error->error = -1; | 100 error->error = -1; |
99 error->domain = kCFStreamErrorDomainCustom; | 101 error->domain = kCFStreamErrorDomainCustom; |
100 } else { | 102 } else { |
101 *at_eof = bytes_read == 0; | 103 *at_eof = bytes_read == 0; |
102 } | 104 } |
103 | 105 |
104 return bytes_read; | 106 return bytes_read; |
105 } | 107 } |
106 | 108 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 } | 225 } |
224 | 226 |
225 } // namespace | 227 } // namespace |
226 | 228 |
227 // static | 229 // static |
228 scoped_ptr<HTTPTransport> HTTPTransport::Create() { | 230 scoped_ptr<HTTPTransport> HTTPTransport::Create() { |
229 return scoped_ptr<HTTPTransport>(new HTTPTransportMac()); | 231 return scoped_ptr<HTTPTransport>(new HTTPTransportMac()); |
230 } | 232 } |
231 | 233 |
232 } // namespace crashpad | 234 } // namespace crashpad |
OLD | NEW |