Chromium Code Reviews| 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 // Download creation struct used for querying the history service. | 5 // Download creation struct used for querying the history service. |
| 6 | 6 |
| 7 #ifndef CHROME_BROWSER_HISTORY_DOWNLOAD_CREATE_INFO_H_ | 7 #ifndef CHROME_BROWSER_HISTORY_DOWNLOAD_CREATE_INFO_H_ |
| 8 #define CHROME_BROWSER_HISTORY_DOWNLOAD_CREATE_INFO_H_ | 8 #define CHROME_BROWSER_HISTORY_DOWNLOAD_CREATE_INFO_H_ |
| 9 #pragma once | 9 #pragma once |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 15 #include "base/file_path.h" | 15 #include "base/file_path.h" |
| 16 #include "base/time.h" | 16 #include "base/time.h" |
| 17 #include "chrome/browser/download/download_file.h" | 17 #include "chrome/browser/download/download_file.h" |
| 18 #include "chrome/browser/download/download_process_handle.h" | 18 #include "chrome/browser/download/download_process_handle.h" |
| 19 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
| 20 | 20 |
| 21 class DownloadItem; | |
| 22 | |
| 23 // Contains the information that is stored in the History database (or refers | |
| 24 // to it). | |
| 25 struct DownloadHistoryInfo { | |
|
Paweł Hajdan Jr.
2011/05/18 20:20:33
Could you extract this to its own header file? The
ahendrickson
2011/05/19 13:51:38
Done.
| |
| 26 DownloadHistoryInfo(); | |
| 27 explicit DownloadHistoryInfo(const DownloadItem& item); | |
| 28 DownloadHistoryInfo(const std::vector<GURL>& url, | |
| 29 const GURL& referrer, | |
| 30 int64 total_bytes); | |
| 31 DownloadHistoryInfo(const FilePath& path, | |
| 32 const GURL& url, | |
| 33 const base::Time& start, | |
| 34 int64 received, | |
| 35 int64 total, | |
| 36 int32 download_state); | |
| 37 DownloadHistoryInfo(const FilePath& path, | |
| 38 const std::vector<GURL>& url, | |
| 39 const GURL& referrer, | |
| 40 const base::Time& start, | |
| 41 int64 received, | |
| 42 int64 total, | |
| 43 int32 download_state, | |
| 44 int64 handle, | |
| 45 int32 id); | |
| 46 | |
| 47 // The URL from which we are downloading. This is the final URL after any | |
| 48 // redirection by the server for |url_chain|. | |
| 49 const GURL& url() const; | |
| 50 | |
| 51 // Download ID assigned by DownloadResourceHandler. | |
| 52 // Used by the history back end, to return in a callback. | |
| 53 int32 download_id; | |
| 54 | |
| 55 // The final path where the download is saved. | |
| 56 FilePath path; | |
| 57 | |
| 58 // The chain of redirects that leading up to and including the final URL. | |
| 59 std::vector<GURL> url_chain; | |
| 60 | |
| 61 // The URL that referred us. | |
| 62 GURL referrer_url; | |
| 63 | |
| 64 base::Time start_time; | |
| 65 | |
| 66 int64 received_bytes; | |
| 67 | |
| 68 int64 total_bytes; | |
| 69 | |
| 70 int32 state; | |
| 71 | |
| 72 int64 db_handle; | |
| 73 }; | |
| 74 | |
| 21 // Used for informing the download database of a new download, where we don't | 75 // Used for informing the download database of a new download, where we don't |
| 22 // want to pass DownloadItems between threads. The history service also uses a | 76 // want to pass DownloadItems between threads. The history service also uses a |
| 23 // vector of these structs for passing us the state of all downloads at | 77 // vector of these structs for passing us the state of all downloads at |
| 24 // initialization time (see DownloadQueryInfo below). | 78 // initialization time (see DownloadQueryInfo below). |
| 25 struct DownloadCreateInfo { | 79 struct DownloadCreateInfo { |
| 26 DownloadCreateInfo(const FilePath& path, | 80 DownloadCreateInfo(const FilePath& path, |
| 27 const GURL& url, | 81 const GURL& url, |
| 28 base::Time start_time, | 82 base::Time start_time, |
| 29 int64 received_bytes, | 83 int64 received_bytes, |
| 30 int64 total_bytes, | 84 int64 total_bytes, |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 51 FilePath suggested_path; | 105 FilePath suggested_path; |
| 52 // A number that should be added to the suggested path to make it unique. | 106 // A number that should be added to the suggested path to make it unique. |
| 53 // 0 means no number should be appended. Not actually stored in the db. | 107 // 0 means no number should be appended. Not actually stored in the db. |
| 54 int path_uniquifier; | 108 int path_uniquifier; |
| 55 base::Time start_time; | 109 base::Time start_time; |
| 56 int64 received_bytes; | 110 int64 received_bytes; |
| 57 int64 total_bytes; | 111 int64 total_bytes; |
| 58 int32 state; | 112 int32 state; |
| 59 int32 download_id; | 113 int32 download_id; |
| 60 bool has_user_gesture; | 114 bool has_user_gesture; |
| 115 // The handle to the process information. Used for operations outside the | |
| 116 // download system. | |
| 61 DownloadProcessHandle process_handle; | 117 DownloadProcessHandle process_handle; |
| 62 int64 db_handle; | 118 int64 db_handle; |
| 63 std::string content_disposition; | 119 std::string content_disposition; |
| 64 std::string mime_type; | 120 std::string mime_type; |
| 65 // The value of the content type header sent with the downloaded item. It | 121 // The value of the content type header sent with the downloaded item. It |
| 66 // may be different from |mime_type|, which may be set based on heuristics | 122 // may be different from |mime_type|, which may be set based on heuristics |
| 67 // which may look at the file extension and first few bytes of the file. | 123 // which may look at the file extension and first few bytes of the file. |
| 68 std::string original_mime_type; | 124 std::string original_mime_type; |
| 69 | 125 |
| 70 // True if we should display the 'save as...' UI and prompt the user | 126 // True if we should display the 'save as...' UI and prompt the user |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 81 // Whether this download is for extension install or not. | 137 // Whether this download is for extension install or not. |
| 82 bool is_extension_install; | 138 bool is_extension_install; |
| 83 // The charset of the referring page where the download request comes from. | 139 // The charset of the referring page where the download request comes from. |
| 84 // It's used to construct a suggested filename. | 140 // It's used to construct a suggested filename. |
| 85 std::string referrer_charset; | 141 std::string referrer_charset; |
| 86 // The download file save info. | 142 // The download file save info. |
| 87 DownloadSaveInfo save_info; | 143 DownloadSaveInfo save_info; |
| 88 }; | 144 }; |
| 89 | 145 |
| 90 #endif // CHROME_BROWSER_HISTORY_DOWNLOAD_CREATE_INFO_H_ | 146 #endif // CHROME_BROWSER_HISTORY_DOWNLOAD_CREATE_INFO_H_ |
| OLD | NEW |