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