Save errno for logging before potentially overwriting it.
[chromium-blink-merge.git] / content / browser / download / download_create_info.h
blob9f88da1d5eea87945eebf3232cd26b76c17ff601
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_CREATE_INFO_H_
6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_CREATE_INFO_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/files/file_path.h"
13 #include "base/time.h"
14 #include "content/browser/download/download_file.h"
15 #include "content/browser/download/download_request_handle.h"
16 #include "content/common/content_export.h"
17 #include "content/public/browser/download_id.h"
18 #include "content/public/browser/download_save_info.h"
19 #include "content/public/common/page_transition_types.h"
20 #include "googleurl/src/gurl.h"
21 #include "net/base/net_log.h"
23 namespace content {
25 // Used for informing the download manager of a new download, since we don't
26 // want to pass |DownloadItem|s between threads.
27 struct CONTENT_EXPORT DownloadCreateInfo {
28 DownloadCreateInfo(const base::Time& start_time,
29 int64 total_bytes,
30 const net::BoundNetLog& bound_net_log,
31 bool has_user_gesture,
32 PageTransition transition_type);
33 DownloadCreateInfo();
34 ~DownloadCreateInfo();
36 std::string DebugString() const;
38 // The URL from which we are downloading. This is the final URL after any
39 // redirection by the server for |url_chain|.
40 const GURL& url() const;
42 // The chain of redirects that leading up to and including the final URL.
43 std::vector<GURL> url_chain;
45 // The URL that referred us.
46 GURL referrer_url;
48 // The time when the download started.
49 base::Time start_time;
51 // The total download size.
52 int64 total_bytes;
54 // The (per-session) ID of the download.
55 DownloadId download_id;
57 // True if the download was initiated by user action.
58 bool has_user_gesture;
60 PageTransition transition_type;
62 // The content-disposition string from the response header.
63 std::string content_disposition;
65 // The mime type string from the response header (may be overridden).
66 std::string mime_type;
68 // The value of the content type header sent with the downloaded item. It
69 // may be different from |mime_type|, which may be set based on heuristics
70 // which may look at the file extension and first few bytes of the file.
71 std::string original_mime_type;
73 // For continuing a download, the modification time of the file.
74 // Storing as a string for exact match to server format on
75 // "If-Unmodified-Since" comparison.
76 std::string last_modified;
78 // For continuing a download, the ETAG of the file.
79 std::string etag;
81 // The download file save info.
82 scoped_ptr<DownloadSaveInfo> save_info;
84 // The remote IP address where the download was fetched from. Copied from
85 // UrlRequest::GetSocketAddress().
86 std::string remote_address;
88 // The handle to the URLRequest sourcing this download.
89 DownloadRequestHandle request_handle;
91 // The request's |BoundNetLog|, for "source_dependency" linking with the
92 // download item's.
93 const net::BoundNetLog request_bound_net_log;
95 private:
96 DISALLOW_COPY_AND_ASSIGN(DownloadCreateInfo);
99 } // namespace content
101 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_CREATE_INFO_H_