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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 DownloadUrlParameters::OnStartedCallback on_started_callback_; | 76 DownloadUrlParameters::OnStartedCallback on_started_callback_; |
77 }; | 77 }; |
78 | 78 |
79 // static | 79 // static |
80 const int DownloadRequestData::kKey = 0; | 80 const int DownloadRequestData::kKey = 0; |
81 | 81 |
82 // static | 82 // static |
83 void DownloadRequestData::Attach(net::URLRequest* request, | 83 void DownloadRequestData::Attach(net::URLRequest* request, |
84 DownloadUrlParameters* parameters, | 84 DownloadUrlParameters* parameters, |
85 uint32_t download_id) { | 85 uint32_t download_id) { |
86 DownloadRequestData* request_data = new DownloadRequestData; | 86 auto request_data = base::MakeUnique<DownloadRequestData>(); |
87 request_data->save_info_.reset( | 87 request_data->save_info_.reset( |
88 new DownloadSaveInfo(parameters->GetSaveInfo())); | 88 new DownloadSaveInfo(parameters->GetSaveInfo())); |
89 request_data->download_id_ = download_id; | 89 request_data->download_id_ = download_id; |
90 request_data->transient_ = parameters->is_transient(); | 90 request_data->transient_ = parameters->is_transient(); |
91 request_data->on_started_callback_ = parameters->callback(); | 91 request_data->on_started_callback_ = parameters->callback(); |
92 request->SetUserData(&kKey, request_data); | 92 request->SetUserData(&kKey, std::move(request_data)); |
93 } | 93 } |
94 | 94 |
95 // static | 95 // static |
96 DownloadRequestData* DownloadRequestData::Get(net::URLRequest* request) { | 96 DownloadRequestData* DownloadRequestData::Get(net::URLRequest* request) { |
97 return static_cast<DownloadRequestData*>(request->GetUserData(&kKey)); | 97 return static_cast<DownloadRequestData*>(request->GetUserData(&kKey)); |
98 } | 98 } |
99 | 99 |
100 // static | 100 // static |
101 void DownloadRequestData::Detach(net::URLRequest* request) { | 101 void DownloadRequestData::Detach(net::URLRequest* request) { |
102 request->RemoveUserData(&kKey); | 102 request->RemoveUserData(&kKey); |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 // old servers that didn't implement "If-Match" and must be ignored when | 676 // old servers that didn't implement "If-Match" and must be ignored when |
677 // "If-Match" presents. | 677 // "If-Match" presents. |
678 if (has_last_modified) { | 678 if (has_last_modified) { |
679 request->SetExtraRequestHeaderByName( | 679 request->SetExtraRequestHeaderByName( |
680 net::HttpRequestHeaders::kIfUnmodifiedSince, params->last_modified(), | 680 net::HttpRequestHeaders::kIfUnmodifiedSince, params->last_modified(), |
681 true); | 681 true); |
682 } | 682 } |
683 } | 683 } |
684 | 684 |
685 } // namespace content | 685 } // namespace content |
OLD | NEW |