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

Side by Side Diff: content/browser/download/download_item_impl.cc

Issue 1545243002: Convert Pass()→std::move() in //content/browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months 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 (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 // File method ordering: Methods in this file are in the same order as 5 // File method ordering: Methods in this file are in the same order as
6 // in download_item_impl.h, with the following exception: The public 6 // in download_item_impl.h, with the following exception: The public
7 // interface Start is placed in chronological order with the other 7 // interface Start is placed in chronological order with the other
8 // (private) routines that together define a DownloadItem's state 8 // (private) routines that together define a DownloadItem's state
9 // transitions as the download progresses. See "Download progression 9 // transitions as the download progresses. See "Download progression
10 // cascade" later in this file. 10 // cascade" later in this file.
11 11
12 // A regular DownloadItem (created for a download in this session of the 12 // A regular DownloadItem (created for a download in this session of the
13 // browser) normally goes through the following states: 13 // browser) normally goes through the following states:
14 // * Created (when download starts) 14 // * Created (when download starts)
15 // * Destination filename determined 15 // * Destination filename determined
16 // * Entered into the history database. 16 // * Entered into the history database.
17 // * Made visible in the download shelf. 17 // * Made visible in the download shelf.
18 // * All the data is saved. Note that the actual data download occurs 18 // * All the data is saved. Note that the actual data download occurs
19 // in parallel with the above steps, but until those steps are 19 // in parallel with the above steps, but until those steps are
20 // complete, the state of the data save will be ignored. 20 // complete, the state of the data save will be ignored.
21 // * Download file is renamed to its final name, and possibly 21 // * Download file is renamed to its final name, and possibly
22 // auto-opened. 22 // auto-opened.
23 23
24 #include "content/browser/download/download_item_impl.h" 24 #include "content/browser/download/download_item_impl.h"
25 25
26 #include <utility>
26 #include <vector> 27 #include <vector>
27 28
28 #include "base/bind.h" 29 #include "base/bind.h"
29 #include "base/files/file_util.h" 30 #include "base/files/file_util.h"
30 #include "base/format_macros.h" 31 #include "base/format_macros.h"
31 #include "base/logging.h" 32 #include "base/logging.h"
32 #include "base/metrics/histogram.h" 33 #include "base/metrics/histogram.h"
33 #include "base/stl_util.h" 34 #include "base/stl_util.h"
34 #include "base/strings/stringprintf.h" 35 #include "base/strings/stringprintf.h"
35 #include "base/strings/utf_string_conversions.h" 36 #include "base/strings/utf_string_conversions.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 // Constructing for the "Save Page As..." feature: 225 // Constructing for the "Save Page As..." feature:
225 DownloadItemImpl::DownloadItemImpl( 226 DownloadItemImpl::DownloadItemImpl(
226 DownloadItemImplDelegate* delegate, 227 DownloadItemImplDelegate* delegate,
227 uint32_t download_id, 228 uint32_t download_id,
228 const base::FilePath& path, 229 const base::FilePath& path,
229 const GURL& url, 230 const GURL& url,
230 const std::string& mime_type, 231 const std::string& mime_type,
231 scoped_ptr<DownloadRequestHandleInterface> request_handle, 232 scoped_ptr<DownloadRequestHandleInterface> request_handle,
232 const net::BoundNetLog& bound_net_log) 233 const net::BoundNetLog& bound_net_log)
233 : is_save_package_download_(true), 234 : is_save_package_download_(true),
234 request_handle_(request_handle.Pass()), 235 request_handle_(std::move(request_handle)),
235 download_id_(download_id), 236 download_id_(download_id),
236 current_path_(path), 237 current_path_(path),
237 target_path_(path), 238 target_path_(path),
238 target_disposition_(TARGET_DISPOSITION_OVERWRITE), 239 target_disposition_(TARGET_DISPOSITION_OVERWRITE),
239 url_chain_(1, url), 240 url_chain_(1, url),
240 referrer_url_(GURL()), 241 referrer_url_(GURL()),
241 transition_type_(ui::PAGE_TRANSITION_LINK), 242 transition_type_(ui::PAGE_TRANSITION_LINK),
242 has_user_gesture_(false), 243 has_user_gesture_(false),
243 mime_type_(mime_type), 244 mime_type_(mime_type),
244 original_mime_type_(mime_type), 245 original_mime_type_(mime_type),
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 1110
1110 // We're starting the download. 1111 // We're starting the download.
1111 void DownloadItemImpl::Start( 1112 void DownloadItemImpl::Start(
1112 scoped_ptr<DownloadFile> file, 1113 scoped_ptr<DownloadFile> file,
1113 scoped_ptr<DownloadRequestHandleInterface> req_handle) { 1114 scoped_ptr<DownloadRequestHandleInterface> req_handle) {
1114 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1115 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1115 DCHECK(!download_file_.get()); 1116 DCHECK(!download_file_.get());
1116 DCHECK(file.get()); 1117 DCHECK(file.get());
1117 DCHECK(req_handle.get()); 1118 DCHECK(req_handle.get());
1118 1119
1119 download_file_ = file.Pass(); 1120 download_file_ = std::move(file);
1120 request_handle_ = req_handle.Pass(); 1121 request_handle_ = std::move(req_handle);
1121 1122
1122 if (GetState() == CANCELLED) { 1123 if (GetState() == CANCELLED) {
1123 // The download was in the process of resuming when it was cancelled. Don't 1124 // The download was in the process of resuming when it was cancelled. Don't
1124 // proceed. 1125 // proceed.
1125 ReleaseDownloadFile(true); 1126 ReleaseDownloadFile(true);
1126 request_handle_->CancelRequest(); 1127 request_handle_->CancelRequest();
1127 return; 1128 return;
1128 } 1129 }
1129 1130
1130 TransitionTo(IN_PROGRESS_INTERNAL, UPDATE_OBSERVERS); 1131 TransitionTo(IN_PROGRESS_INTERNAL, UPDATE_OBSERVERS);
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
1696 1697
1697 download_params->set_file_path(GetFullPath()); 1698 download_params->set_file_path(GetFullPath());
1698 download_params->set_offset(GetReceivedBytes()); 1699 download_params->set_offset(GetReceivedBytes());
1699 download_params->set_hash_state(GetHashState()); 1700 download_params->set_hash_state(GetHashState());
1700 download_params->set_last_modified(GetLastModifiedTime()); 1701 download_params->set_last_modified(GetLastModifiedTime());
1701 download_params->set_etag(GetETag()); 1702 download_params->set_etag(GetETag());
1702 download_params->set_callback( 1703 download_params->set_callback(
1703 base::Bind(&DownloadItemImpl::OnResumeRequestStarted, 1704 base::Bind(&DownloadItemImpl::OnResumeRequestStarted,
1704 weak_ptr_factory_.GetWeakPtr())); 1705 weak_ptr_factory_.GetWeakPtr()));
1705 1706
1706 delegate_->ResumeInterruptedDownload(download_params.Pass(), GetId()); 1707 delegate_->ResumeInterruptedDownload(std::move(download_params), GetId());
1707 // Just in case we were interrupted while paused. 1708 // Just in case we were interrupted while paused.
1708 is_paused_ = false; 1709 is_paused_ = false;
1709 1710
1710 TransitionTo(RESUMING_INTERNAL, DONT_UPDATE_OBSERVERS); 1711 TransitionTo(RESUMING_INTERNAL, DONT_UPDATE_OBSERVERS);
1711 } 1712 }
1712 1713
1713 // static 1714 // static
1714 DownloadItem::DownloadState DownloadItemImpl::InternalToExternalState( 1715 DownloadItem::DownloadState DownloadItemImpl::InternalToExternalState(
1715 DownloadInternalState internal_state) { 1716 DownloadInternalState internal_state) {
1716 switch (internal_state) { 1717 switch (internal_state) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1785 case RESUME_MODE_USER_CONTINUE: 1786 case RESUME_MODE_USER_CONTINUE:
1786 return "USER_CONTINUE"; 1787 return "USER_CONTINUE";
1787 case RESUME_MODE_USER_RESTART: 1788 case RESUME_MODE_USER_RESTART:
1788 return "USER_RESTART"; 1789 return "USER_RESTART";
1789 } 1790 }
1790 NOTREACHED() << "Unknown resume mode " << mode; 1791 NOTREACHED() << "Unknown resume mode " << mode;
1791 return "unknown"; 1792 return "unknown";
1792 } 1793 }
1793 1794
1794 } // namespace content 1795 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/download_file_unittest.cc ('k') | content/browser/download/download_item_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698