| 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 25 matching lines...) Expand all Loading... |
| 36 } | 36 } |
| 37 | 37 |
| 38 ssize_t StringHTTPBodyStream::GetBytesBuffer(uint8_t* buffer, size_t max_len) { | 38 ssize_t StringHTTPBodyStream::GetBytesBuffer(uint8_t* buffer, size_t max_len) { |
| 39 size_t num_bytes_remaining = string_.length() - bytes_read_; | 39 size_t num_bytes_remaining = string_.length() - bytes_read_; |
| 40 if (num_bytes_remaining == 0) { | 40 if (num_bytes_remaining == 0) { |
| 41 return num_bytes_remaining; | 41 return num_bytes_remaining; |
| 42 } | 42 } |
| 43 | 43 |
| 44 size_t num_bytes_returned = | 44 size_t num_bytes_returned = |
| 45 std::min(std::min(num_bytes_remaining, max_len), | 45 std::min(std::min(num_bytes_remaining, max_len), |
| 46 static_cast<size_t>(std::numeric_limits<ssize_t>::max())); | 46 implicit_cast<size_t>(std::numeric_limits<ssize_t>::max())); |
| 47 memcpy(buffer, &string_[bytes_read_], num_bytes_returned); | 47 memcpy(buffer, &string_[bytes_read_], num_bytes_returned); |
| 48 bytes_read_ += num_bytes_returned; | 48 bytes_read_ += num_bytes_returned; |
| 49 return num_bytes_returned; | 49 return num_bytes_returned; |
| 50 } | 50 } |
| 51 | 51 |
| 52 FileHTTPBodyStream::FileHTTPBodyStream(const base::FilePath& path) | 52 FileHTTPBodyStream::FileHTTPBodyStream(const base::FilePath& path) |
| 53 : HTTPBodyStream(), path_(path), fd_(kUnopenedFile) { | 53 : HTTPBodyStream(), path_(path), fd_(kUnopenedFile) { |
| 54 } | 54 } |
| 55 | 55 |
| 56 FileHTTPBodyStream::~FileHTTPBodyStream() { | 56 FileHTTPBodyStream::~FileHTTPBodyStream() { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 // If the current part has returned 0 indicating EOF, advance the current | 107 // If the current part has returned 0 indicating EOF, advance the current |
| 108 // part and call recursively to try again. | 108 // part and call recursively to try again. |
| 109 ++current_part_; | 109 ++current_part_; |
| 110 return GetBytesBuffer(buffer, max_len); | 110 return GetBytesBuffer(buffer, max_len); |
| 111 } | 111 } |
| 112 | 112 |
| 113 return rv; | 113 return rv; |
| 114 } | 114 } |
| 115 | 115 |
| 116 } // namespace crashpad | 116 } // namespace crashpad |
| OLD | NEW |