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

Side by Side Diff: util/net/http_body.cc

Issue 700383007: Use implicit_cast<> instead of static_cast<> whenever possible (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 6 years, 1 month 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 25 matching lines...) Expand all
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698