| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/download/download_request_core.h" | 5 #include "content/browser/download/download_request_core.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 } | 129 } |
| 130 | 130 |
| 131 if (params->post_id() >= 0) { | 131 if (params->post_id() >= 0) { |
| 132 // The POST in this case does not have an actual body, and only works | 132 // The POST in this case does not have an actual body, and only works |
| 133 // when retrieving data from cache. This is done because we don't want | 133 // when retrieving data from cache. This is done because we don't want |
| 134 // to do a re-POST without user consent, and currently don't have a good | 134 // to do a re-POST without user consent, and currently don't have a good |
| 135 // plan on how to display the UI for that. | 135 // plan on how to display the UI for that. |
| 136 DCHECK(params->prefer_cache()); | 136 DCHECK(params->prefer_cache()); |
| 137 DCHECK_EQ("POST", params->method()); | 137 DCHECK_EQ("POST", params->method()); |
| 138 std::vector<std::unique_ptr<net::UploadElementReader>> element_readers; | 138 std::vector<std::unique_ptr<net::UploadElementReader>> element_readers; |
| 139 request->set_upload(base::WrapUnique(new net::ElementsUploadDataStream( | 139 request->set_upload(base::MakeUnique<net::ElementsUploadDataStream>( |
| 140 std::move(element_readers), params->post_id()))); | 140 std::move(element_readers), params->post_id())); |
| 141 } | 141 } |
| 142 | 142 |
| 143 int load_flags = request->load_flags(); | 143 int load_flags = request->load_flags(); |
| 144 if (params->prefer_cache()) { | 144 if (params->prefer_cache()) { |
| 145 // If there is upload data attached, only retrieve from cache because there | 145 // If there is upload data attached, only retrieve from cache because there |
| 146 // is no current mechanism to prompt the user for their consent for a | 146 // is no current mechanism to prompt the user for their consent for a |
| 147 // re-post. For GETs, try to retrieve data from the cache and skip | 147 // re-post. For GETs, try to retrieve data from the cache and skip |
| 148 // validating the entry if present. | 148 // validating the entry if present. |
| 149 if (request->get_upload()) | 149 if (request->get_upload()) |
| 150 load_flags |= net::LOAD_ONLY_FROM_CACHE; | 150 load_flags |= net::LOAD_ONLY_FROM_CACHE; |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 return DOWNLOAD_INTERRUPT_REASON_NONE; | 628 return DOWNLOAD_INTERRUPT_REASON_NONE; |
| 629 } | 629 } |
| 630 | 630 |
| 631 if (http_headers.response_code() == net::HTTP_PARTIAL_CONTENT) | 631 if (http_headers.response_code() == net::HTTP_PARTIAL_CONTENT) |
| 632 return DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT; | 632 return DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT; |
| 633 | 633 |
| 634 return DOWNLOAD_INTERRUPT_REASON_NONE; | 634 return DOWNLOAD_INTERRUPT_REASON_NONE; |
| 635 } | 635 } |
| 636 | 636 |
| 637 } // namespace content | 637 } // namespace content |
| OLD | NEW |