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 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_CREATE_INFO_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_CREATE_INFO_H_ |
6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_CREATE_INFO_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_CREATE_INFO_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "content/browser/download/download_file.h" | 16 #include "content/browser/download/download_file.h" |
17 #include "content/browser/download/download_request_handle.h" | 17 #include "content/browser/download/download_request_handle.h" |
18 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
| 19 #include "content/public/browser/download_interrupt_reasons.h" |
19 #include "content/public/browser/download_save_info.h" | 20 #include "content/public/browser/download_save_info.h" |
20 #include "net/log/net_log.h" | 21 #include "net/log/net_log.h" |
21 #include "ui/base/page_transition_types.h" | 22 #include "ui/base/page_transition_types.h" |
22 #include "url/gurl.h" | 23 #include "url/gurl.h" |
23 | 24 |
24 namespace content { | 25 namespace content { |
25 | 26 |
26 // Used for informing the download manager of a new download, since we don't | 27 // Used for informing the download manager of a new download, since we don't |
27 // want to pass |DownloadItem|s between threads. | 28 // want to pass |DownloadItem|s between threads. |
28 struct CONTENT_EXPORT DownloadCreateInfo { | 29 struct CONTENT_EXPORT DownloadCreateInfo { |
29 DownloadCreateInfo(const base::Time& start_time, | 30 DownloadCreateInfo(const base::Time& start_time, |
30 int64_t total_bytes, | |
31 const net::BoundNetLog& bound_net_log, | 31 const net::BoundNetLog& bound_net_log, |
32 scoped_ptr<DownloadSaveInfo> save_info); | 32 scoped_ptr<DownloadSaveInfo> save_info); |
33 DownloadCreateInfo(); | 33 DownloadCreateInfo(); |
34 ~DownloadCreateInfo(); | 34 ~DownloadCreateInfo(); |
35 | 35 |
36 std::string DebugString() const; | 36 std::string DebugString() const; |
37 | 37 |
38 // The URL from which we are downloading. This is the final URL after any | 38 // The URL from which we are downloading. This is the final URL after any |
39 // redirection by the server for |url_chain|. | 39 // redirection by the server for |url_chain|. |
40 const GURL& url() const; | 40 const GURL& url() const; |
41 | 41 |
| 42 // The ID of the download. |
| 43 uint32_t download_id; |
| 44 |
42 // The chain of redirects that leading up to and including the final URL. | 45 // The chain of redirects that leading up to and including the final URL. |
43 std::vector<GURL> url_chain; | 46 std::vector<GURL> url_chain; |
44 | 47 |
45 // The URL that referred us. | 48 // The URL that referred us. |
46 GURL referrer_url; | 49 GURL referrer_url; |
47 | 50 |
48 // The URL of the tab that started us. | 51 // The URL of the tab that started us. |
49 GURL tab_url; | 52 GURL tab_url; |
50 | 53 |
51 // The referrer URL of the tab that started us. | 54 // The referrer URL of the tab that started us. |
52 GURL tab_referrer_url; | 55 GURL tab_referrer_url; |
53 | 56 |
54 // The time when the download started. | 57 // The time when the download started. |
55 base::Time start_time; | 58 base::Time start_time; |
56 | 59 |
57 // The total download size. | |
58 int64_t total_bytes; | |
59 | |
60 // The ID of the download. | |
61 uint32_t download_id; | |
62 | |
63 // True if the download was initiated by user action. | 60 // True if the download was initiated by user action. |
64 bool has_user_gesture; | 61 bool has_user_gesture; |
65 | 62 |
66 ui::PageTransition transition_type; | 63 ui::PageTransition transition_type; |
67 | 64 |
| 65 // The remote IP address where the download was fetched from. Copied from |
| 66 // UrlRequest::GetSocketAddress(). |
| 67 std::string remote_address; |
| 68 |
| 69 // If the download is initially created in an interrupted state (because the |
| 70 // response was in error), then |result| would be something other than |
| 71 // INTERRUPT_REASON_NONE. |
| 72 DownloadInterruptReason result; |
| 73 |
| 74 // The download file save info. |
| 75 scoped_ptr<DownloadSaveInfo> save_info; |
| 76 |
| 77 // The handle to the URLRequest sourcing this download. |
| 78 scoped_ptr<DownloadRequestHandleInterface> request_handle; |
| 79 |
| 80 // The request's |BoundNetLog|, for "source_dependency" linking with the |
| 81 // download item's. |
| 82 const net::BoundNetLog request_bound_net_log; |
| 83 |
| 84 // --------------------------------------------------------------------------- |
| 85 // The remaining fields are Entity-body properties. These are only set if |
| 86 // |result| is DOWNLOAD_INTERRUPT_REASON_NONE. |
| 87 // --------------------------------------------------------------------------- |
| 88 |
| 89 // The total download size. |
| 90 int64_t total_bytes; |
| 91 |
68 // The content-disposition string from the response header. | 92 // The content-disposition string from the response header. |
69 std::string content_disposition; | 93 std::string content_disposition; |
70 | 94 |
71 // The mime type string from the response header (may be overridden). | 95 // The mime type string from the response header (may be overridden). |
72 std::string mime_type; | 96 std::string mime_type; |
73 | 97 |
74 // The value of the content type header sent with the downloaded item. It | 98 // The value of the content type header sent with the downloaded item. It |
75 // may be different from |mime_type|, which may be set based on heuristics | 99 // may be different from |mime_type|, which may be set based on heuristics |
76 // which may look at the file extension and first few bytes of the file. | 100 // which may look at the file extension and first few bytes of the file. |
77 std::string original_mime_type; | 101 std::string original_mime_type; |
78 | 102 |
79 // For continuing a download, the modification time of the file. | 103 // For continuing a download, the modification time of the file. |
80 // Storing as a string for exact match to server format on | 104 // Storing as a string for exact match to server format on |
81 // "If-Unmodified-Since" comparison. | 105 // "If-Unmodified-Since" comparison. |
82 std::string last_modified; | 106 std::string last_modified; |
83 | 107 |
84 // For continuing a download, the ETAG of the file. | 108 // For continuing a download, the ETag of the file. |
85 std::string etag; | 109 std::string etag; |
86 | 110 |
87 // The download file save info. | |
88 scoped_ptr<DownloadSaveInfo> save_info; | |
89 | |
90 // The remote IP address where the download was fetched from. Copied from | |
91 // UrlRequest::GetSocketAddress(). | |
92 std::string remote_address; | |
93 | |
94 // The handle to the URLRequest sourcing this download. | |
95 scoped_ptr<DownloadRequestHandleInterface> request_handle; | |
96 | |
97 // The request's |BoundNetLog|, for "source_dependency" linking with the | |
98 // download item's. | |
99 const net::BoundNetLog request_bound_net_log; | |
100 | |
101 private: | 111 private: |
102 DISALLOW_COPY_AND_ASSIGN(DownloadCreateInfo); | 112 DISALLOW_COPY_AND_ASSIGN(DownloadCreateInfo); |
103 }; | 113 }; |
104 | 114 |
105 } // namespace content | 115 } // namespace content |
106 | 116 |
107 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_CREATE_INFO_H_ | 117 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_CREATE_INFO_H_ |
OLD | NEW |