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 "content/browser/download/download_create_info.h" | 5 #include "content/browser/download/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 | 11 |
12 DownloadCreateInfo::DownloadCreateInfo(const FilePath& path, | 12 DownloadCreateInfo::DownloadCreateInfo(const FilePath& path, |
13 const GURL& url, | 13 const GURL& url, |
14 const base::Time& start_time, | 14 const base::Time& start_time, |
15 int64 received_bytes, | 15 int64 received_bytes, |
16 int64 total_bytes, | 16 int64 total_bytes, |
17 int32 state, | 17 int32 state, |
18 int32 download_id, | 18 int32 download_id, |
19 bool has_user_gesture) | 19 bool has_user_gesture, |
| 20 PageTransition::Type transition_type) |
20 : path(path), | 21 : path(path), |
21 url_chain(1, url), | 22 url_chain(1, url), |
22 path_uniquifier(0), | 23 path_uniquifier(0), |
23 start_time(start_time), | 24 start_time(start_time), |
24 received_bytes(received_bytes), | 25 received_bytes(received_bytes), |
25 total_bytes(total_bytes), | 26 total_bytes(total_bytes), |
26 state(state), | 27 state(state), |
27 download_id(download_id), | 28 download_id(download_id), |
28 has_user_gesture(has_user_gesture), | 29 has_user_gesture(has_user_gesture), |
| 30 transition_type(transition_type), |
29 db_handle(0), | 31 db_handle(0), |
30 prompt_user_for_save_location(false) { | 32 prompt_user_for_save_location(false) { |
31 } | 33 } |
32 | 34 |
33 DownloadCreateInfo::DownloadCreateInfo() | 35 DownloadCreateInfo::DownloadCreateInfo() |
34 : path_uniquifier(0), | 36 : path_uniquifier(0), |
35 received_bytes(0), | 37 received_bytes(0), |
36 total_bytes(0), | 38 total_bytes(0), |
37 state(-1), | 39 state(-1), |
38 download_id(-1), | 40 download_id(-1), |
39 has_user_gesture(false), | 41 has_user_gesture(false), |
| 42 transition_type(PageTransition::LINK), |
40 db_handle(0), | 43 db_handle(0), |
41 prompt_user_for_save_location(false) { | 44 prompt_user_for_save_location(false) { |
42 } | 45 } |
43 | 46 |
44 DownloadCreateInfo::~DownloadCreateInfo() { | 47 DownloadCreateInfo::~DownloadCreateInfo() { |
45 } | 48 } |
46 | 49 |
47 std::string DownloadCreateInfo::DebugString() const { | 50 std::string DownloadCreateInfo::DebugString() const { |
48 return base::StringPrintf("{" | 51 return base::StringPrintf("{" |
49 " download_id = %d" | 52 " download_id = %d" |
50 " url = \"%s\"" | 53 " url = \"%s\"" |
51 " path = \"%" PRFilePath "\"" | 54 " path = \"%" PRFilePath "\"" |
52 " received_bytes = %" PRId64 | 55 " received_bytes = %" PRId64 |
53 " total_bytes = %" PRId64 | 56 " total_bytes = %" PRId64 |
54 " request_handle = %s" | 57 " request_handle = %s" |
55 " prompt_user_for_save_location = %c" | 58 " prompt_user_for_save_location = %c" |
56 " }", | 59 " }", |
57 download_id, | 60 download_id, |
58 url().spec().c_str(), | 61 url().spec().c_str(), |
59 path.value().c_str(), | 62 path.value().c_str(), |
60 received_bytes, | 63 received_bytes, |
61 total_bytes, | 64 total_bytes, |
62 request_handle.DebugString().c_str(), | 65 request_handle.DebugString().c_str(), |
63 prompt_user_for_save_location ? 'T' : 'F'); | 66 prompt_user_for_save_location ? 'T' : 'F'); |
64 } | 67 } |
65 | 68 |
66 const GURL& DownloadCreateInfo::url() const { | 69 const GURL& DownloadCreateInfo::url() const { |
67 return url_chain.empty() ? GURL::EmptyGURL() : url_chain.back(); | 70 return url_chain.empty() ? GURL::EmptyGURL() : url_chain.back(); |
68 } | 71 } |
OLD | NEW |