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
3 // found in the LICENSE file.
4 
5 #include "components/download/public/common/download_create_info.h"
6 
7 #include <memory>
8 #include <string>
9 
10 #include "base/format_macros.h"
11 #include "base/strings/stringprintf.h"
12 #include "net/http/http_response_headers.h"
13 
14 namespace download {
15 
DownloadCreateInfo(const base::Time & start_time,std::unique_ptr<DownloadSaveInfo> save_info)16 DownloadCreateInfo::DownloadCreateInfo(
17     const base::Time& start_time,
18     std::unique_ptr<DownloadSaveInfo> save_info)
19     : is_new_download(true),
20       referrer_policy(net::URLRequest::
21                           CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE),
22       start_time(start_time),
23       total_bytes(0),
24       offset(0),
25       has_user_gesture(false),
26       transient(false),
27       result(DOWNLOAD_INTERRUPT_REASON_NONE),
28       save_info(std::move(save_info)),
29       render_process_id(-1),
30       render_frame_id(-1),
31       accept_range(RangeRequestSupportType::kNoSupport),
32       connection_info(net::HttpResponseInfo::CONNECTION_INFO_UNKNOWN),
33       method("GET"),
34       ukm_source_id(ukm::kInvalidSourceId),
35       is_content_initiated(false) {}
36 
DownloadCreateInfo()37 DownloadCreateInfo::DownloadCreateInfo()
38     : DownloadCreateInfo(base::Time(), std::make_unique<DownloadSaveInfo>()) {}
39 
~DownloadCreateInfo()40 DownloadCreateInfo::~DownloadCreateInfo() {}
41 
url() const42 const GURL& DownloadCreateInfo::url() const {
43   return url_chain.empty() ? GURL::EmptyGURL() : url_chain.back();
44 }
45 
46 }  // namespace download
47