OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/history/download_create_info.h" | 5 #include "chrome/browser/history/download_create_info.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| 11 #include "chrome/browser/download/download_item.h" |
| 12 |
| 13 DownloadHistoryInfo::DownloadHistoryInfo() |
| 14 : download_id(-1), |
| 15 received_bytes(0), |
| 16 total_bytes(0), |
| 17 state(0), |
| 18 db_handle(0) { |
| 19 } |
| 20 |
| 21 DownloadHistoryInfo::DownloadHistoryInfo(const DownloadItem& item) |
| 22 : download_id(item.id()), |
| 23 path(item.full_path()), |
| 24 url_chain(item.url_chain()), |
| 25 referrer_url(item.referrer_url()), |
| 26 start_time(item.start_time()), |
| 27 received_bytes(item.received_bytes()), |
| 28 total_bytes(item.total_bytes()), |
| 29 state(item.state()), |
| 30 db_handle(item.db_handle()) { |
| 31 } |
| 32 |
| 33 DownloadHistoryInfo::DownloadHistoryInfo(const std::vector<GURL>& urls, |
| 34 const GURL& referrer, |
| 35 int64 total_bytes) |
| 36 : download_id(-1), |
| 37 url_chain(urls), |
| 38 referrer_url(referrer), |
| 39 start_time(base::Time::Now()), |
| 40 received_bytes(0), |
| 41 total_bytes(total_bytes), |
| 42 state(0), |
| 43 db_handle(0) { |
| 44 } |
| 45 |
| 46 DownloadHistoryInfo::DownloadHistoryInfo(const FilePath& path, |
| 47 const GURL& url, |
| 48 const base::Time& start, |
| 49 int64 received, |
| 50 int64 total, |
| 51 int32 download_state) |
| 52 : download_id(1), |
| 53 path(path), |
| 54 url_chain(1, url), |
| 55 start_time(start), |
| 56 received_bytes(received), |
| 57 total_bytes(total), |
| 58 state(download_state), |
| 59 db_handle(0) { |
| 60 } |
| 61 |
| 62 DownloadHistoryInfo::DownloadHistoryInfo(const FilePath& path, |
| 63 const std::vector<GURL>& url, |
| 64 const GURL& referrer, |
| 65 const base::Time& start, |
| 66 int64 received, |
| 67 int64 total, |
| 68 int32 download_state, |
| 69 int64 handle, |
| 70 int32 id) |
| 71 : download_id(id), |
| 72 path(path), |
| 73 url_chain(url), |
| 74 referrer_url(referrer), |
| 75 start_time(start), |
| 76 received_bytes(received), |
| 77 total_bytes(total), |
| 78 state(download_state), |
| 79 db_handle(handle) { |
| 80 } |
| 81 |
| 82 const GURL& DownloadHistoryInfo::url() const { |
| 83 return url_chain.empty() ? GURL::EmptyGURL() : url_chain.back(); |
| 84 } |
11 | 85 |
12 DownloadCreateInfo::DownloadCreateInfo(const FilePath& path, | 86 DownloadCreateInfo::DownloadCreateInfo(const FilePath& path, |
13 const GURL& url, | 87 const GURL& url, |
14 base::Time start_time, | 88 base::Time start_time, |
15 int64 received_bytes, | 89 int64 received_bytes, |
16 int64 total_bytes, | 90 int64 total_bytes, |
17 int32 state, | 91 int32 state, |
18 int32 download_id, | 92 int32 download_id, |
19 bool has_user_gesture) | 93 bool has_user_gesture) |
20 : path(path), | 94 : path(path), |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 total_bytes, | 147 total_bytes, |
74 process_handle.child_id(), | 148 process_handle.child_id(), |
75 process_handle.render_view_id(), | 149 process_handle.render_view_id(), |
76 process_handle.request_id(), | 150 process_handle.request_id(), |
77 prompt_user_for_save_location ? 'T' : 'F'); | 151 prompt_user_for_save_location ? 'T' : 'F'); |
78 } | 152 } |
79 | 153 |
80 const GURL& DownloadCreateInfo::url() const { | 154 const GURL& DownloadCreateInfo::url() const { |
81 return url_chain.empty() ? GURL::EmptyGURL() : url_chain.back(); | 155 return url_chain.empty() ? GURL::EmptyGURL() : url_chain.back(); |
82 } | 156 } |
OLD | NEW |