Chromium Code Reviews| Index: google_apis/drive/base_requests.cc |
| diff --git a/google_apis/drive/base_requests.cc b/google_apis/drive/base_requests.cc |
| index 3e5b0d1d4c75754b0ddc52eeed4fb6cd51e0aa94..359339ad8853d5b24aac35d6e7eb7802917344c8 100644 |
| --- a/google_apis/drive/base_requests.cc |
| +++ b/google_apis/drive/base_requests.cc |
| @@ -27,6 +27,7 @@ |
| #include "net/base/elements_upload_data_stream.h" |
| #include "net/base/io_buffer.h" |
| #include "net/base/load_flags.h" |
| +#include "net/base/mime_util.h" |
| #include "net/base/net_errors.h" |
| #include "net/base/upload_bytes_element_reader.h" |
| #include "net/base/upload_data_stream.h" |
| @@ -76,13 +77,6 @@ const char kMultipartItemHeaderFormat[] = "--%s\nContent-Type: %s\n\n"; |
| // Footer for whole multipart message. |
| const char kMultipartFooterFormat[] = "--%s--"; |
| -// Characters to be used for multipart/related boundary. |
| -const char kBoundaryCharacters[] = |
| - "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; |
| - |
| -// Size of multipart/related's boundary. |
| -const char kBoundarySize = 70; |
| - |
| // Parses JSON passed in |json| on |blocking_task_runner|. Runs |callback| on |
| // the calling thread when finished with either success or failure. |
| // The callback must not be null. |
| @@ -226,24 +220,7 @@ void GenerateMultipartBody(MultipartType multipart_type, |
| std::string boundary; |
| // Generate random boundary. |
| if (predetermined_boundary.empty()) { |
| - while (true) { |
| - boundary.resize(kBoundarySize); |
| - for (int i = 0; i < kBoundarySize; ++i) { |
| - // Subtract 2 from the array size to exclude '\0', and to turn the size |
| - // into the last index. |
| - const int last_char_index = arraysize(kBoundaryCharacters) - 2; |
| - boundary[i] = kBoundaryCharacters[base::RandInt(0, last_char_index)]; |
| - } |
| - bool conflict_with_content = false; |
|
hashimoto
2016/01/05 07:16:09
The new implementation generates much less variety
Łukasz Anforowicz
2016/01/05 19:16:49
The new implementation is generating 256^30 string
hashimoto
2016/01/07 05:15:48
lgtm
Łukasz Anforowicz
2016/01/07 19:04:13
Thank you very much for pointing this out. This d
|
| - for (auto& part : parts) { |
| - if (part.data.find(boundary, 0) != std::string::npos) { |
| - conflict_with_content = true; |
| - break; |
| - } |
| - } |
| - if (!conflict_with_content) |
| - break; |
| - } |
| + boundary = net::GenerateMimeMultipartBoundary(); |
| } else { |
| boundary = predetermined_boundary; |
| } |