Chromium Code Reviews
[email protected] (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Side by Side Diff: content/public/browser/download_url_parameters.h

Issue 11338045: Merge most instances of DownloadSaveInfo into DownloadUrlParams. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged to LKGR (r165692) Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_PUBLIC_BROWSER_DOWNLOAD_URL_PARAMETERS_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_DOWNLOAD_URL_PARAMETERS_H_
6 #define CONTENT_PUBLIC_BROWSER_DOWNLOAD_URL_PARAMETERS_H_ 6 #define CONTENT_PUBLIC_BROWSER_DOWNLOAD_URL_PARAMETERS_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 28 matching lines...) Expand all
39 class CONTENT_EXPORT DownloadUrlParameters { 39 class CONTENT_EXPORT DownloadUrlParameters {
40 public: 40 public:
41 // If there is an error, then |item| will be NULL. 41 // If there is an error, then |item| will be NULL.
42 typedef base::Callback<void(DownloadItem*, net::Error)> OnStartedCallback; 42 typedef base::Callback<void(DownloadItem*, net::Error)> OnStartedCallback;
43 43
44 typedef std::pair<std::string, std::string> RequestHeadersNameValuePair; 44 typedef std::pair<std::string, std::string> RequestHeadersNameValuePair;
45 typedef std::vector<RequestHeadersNameValuePair> RequestHeadersType; 45 typedef std::vector<RequestHeadersNameValuePair> RequestHeadersType;
46 46
47 static DownloadUrlParameters* FromWebContents( 47 static DownloadUrlParameters* FromWebContents(
48 WebContents* web_contents, 48 WebContents* web_contents,
49 const GURL& url, 49 const GURL& url);
50 scoped_ptr<DownloadSaveInfo> save_info);
51 50
52 DownloadUrlParameters( 51 DownloadUrlParameters(
53 const GURL& url, 52 const GURL& url,
54 int render_process_host_id, 53 int render_process_host_id,
55 int render_view_host_routing_id, 54 int render_view_host_routing_id,
56 content::ResourceContext* resource_context, 55 content::ResourceContext* resource_context);
57 scoped_ptr<DownloadSaveInfo> save_info);
58 56
59 ~DownloadUrlParameters(); 57 ~DownloadUrlParameters();
60 58
61 void set_content_initiated(bool content_initiated) { 59 void set_content_initiated(bool content_initiated) {
62 content_initiated_ = content_initiated; 60 content_initiated_ = content_initiated;
63 } 61 }
64 void add_request_header(const std::string& name, const std::string& value) { 62 void add_request_header(const std::string& name, const std::string& value) {
65 request_headers_.push_back(make_pair(name, value)); 63 request_headers_.push_back(make_pair(name, value));
66 } 64 }
67 void set_referrer(const Referrer& referrer) { referrer_ = referrer; } 65 void set_referrer(const Referrer& referrer) { referrer_ = referrer; }
68 void set_referrer_encoding(const std::string& referrer_encoding) { 66 void set_referrer_encoding(const std::string& referrer_encoding) {
69 referrer_encoding_ = referrer_encoding; 67 referrer_encoding_ = referrer_encoding;
70 } 68 }
71 void set_load_flags(int load_flags) { load_flags_ |= load_flags; } 69 void set_load_flags(int load_flags) { load_flags_ |= load_flags; }
72 void set_method(const std::string& method) { 70 void set_method(const std::string& method) {
73 method_ = method; 71 method_ = method;
74 } 72 }
75 void set_post_body(const std::string& post_body) { 73 void set_post_body(const std::string& post_body) {
76 post_body_ = post_body; 74 post_body_ = post_body;
77 } 75 }
78 void set_prefer_cache(bool prefer_cache) { 76 void set_prefer_cache(bool prefer_cache) {
79 prefer_cache_ = prefer_cache; 77 prefer_cache_ = prefer_cache;
80 } 78 }
81 void set_post_id(int64 post_id) { post_id_ = post_id; } 79 void set_post_id(int64 post_id) { post_id_ = post_id; }
82 void set_callback(const OnStartedCallback& callback) { 80 void set_callback(const OnStartedCallback& callback) {
83 callback_ = callback; 81 callback_ = callback;
84 } 82 }
85 83 void set_file_path(const FilePath& file_path) {
86 // Note that this nulls the internal copy of the DownloadSaveInfo! 84 save_info_.file_path = file_path;
87 scoped_ptr<DownloadSaveInfo> GetSaveInfo(); 85 }
86 void set_suggested_name(const string16& suggested_name) {
87 save_info_.suggested_name = suggested_name;
88 }
89 void set_offset(int64 offset) { save_info_.offset = offset; }
90 void set_hash_state(std::string hash_state) {
91 save_info_.hash_state = hash_state;
92 }
93 void set_prompt(bool prompt) { save_info_.prompt_for_save_location = prompt; }
94 void set_file_stream(scoped_ptr<net::FileStream> file_stream) {
95 save_info_.file_stream = file_stream.Pass();
96 }
88 97
89 const OnStartedCallback& callback() const { return callback_; } 98 const OnStartedCallback& callback() const { return callback_; }
90 bool content_initiated() const { return content_initiated_; } 99 bool content_initiated() const { return content_initiated_; }
91 int load_flags() const { return load_flags_; } 100 int load_flags() const { return load_flags_; }
92 const std::string& method() const { return method_; } 101 const std::string& method() const { return method_; }
93 const std::string& post_body() const { return post_body_; } 102 const std::string& post_body() const { return post_body_; }
94 int64 post_id() const { return post_id_; } 103 int64 post_id() const { return post_id_; }
95 bool prefer_cache() const { return prefer_cache_; } 104 bool prefer_cache() const { return prefer_cache_; }
96 const Referrer& referrer() const { return referrer_; } 105 const Referrer& referrer() const { return referrer_; }
97 const std::string& referrer_encoding() const { return referrer_encoding_; } 106 const std::string& referrer_encoding() const { return referrer_encoding_; }
98 int render_process_host_id() const { return render_process_host_id_; } 107 int render_process_host_id() const { return render_process_host_id_; }
99 int render_view_host_routing_id() const { 108 int render_view_host_routing_id() const {
100 return render_view_host_routing_id_; 109 return render_view_host_routing_id_;
101 } 110 }
102 RequestHeadersType::const_iterator request_headers_begin() const { 111 RequestHeadersType::const_iterator request_headers_begin() const {
103 return request_headers_.begin(); 112 return request_headers_.begin();
104 } 113 }
105 RequestHeadersType::const_iterator request_headers_end() const { 114 RequestHeadersType::const_iterator request_headers_end() const {
106 return request_headers_.end(); 115 return request_headers_.end();
107 } 116 }
108 content::ResourceContext* resource_context() const { 117 content::ResourceContext* resource_context() const {
109 return resource_context_; 118 return resource_context_;
110 } 119 }
111 ResourceDispatcherHost* resource_dispatcher_host() const { 120 ResourceDispatcherHost* resource_dispatcher_host() const {
112 return resource_dispatcher_host_; 121 return resource_dispatcher_host_;
113 } 122 }
123 const FilePath& file_path() const { return save_info_.file_path; }
124 const string16& suggested_name() const { return save_info_.suggested_name; }
125 int64 offset() const { return save_info_.offset; }
126 const std::string& hash_state() const { return save_info_.hash_state; }
127 bool prompt() const { return save_info_.prompt_for_save_location; }
114 const GURL& url() const { return url_; } 128 const GURL& url() const { return url_; }
115 129
130 // Note that this is state changing--the DownloadUrlParameters object
131 // will not have a file_stream attached to it after this call.
132 scoped_ptr<net::FileStream> GetFileStream() {
133 return save_info_.file_stream.Pass();
134 }
135
116 private: 136 private:
117 OnStartedCallback callback_; 137 OnStartedCallback callback_;
118 bool content_initiated_; 138 bool content_initiated_;
119 RequestHeadersType request_headers_; 139 RequestHeadersType request_headers_;
120 int load_flags_; 140 int load_flags_;
121 std::string method_; 141 std::string method_;
122 std::string post_body_; 142 std::string post_body_;
123 int64 post_id_; 143 int64 post_id_;
124 bool prefer_cache_; 144 bool prefer_cache_;
125 Referrer referrer_; 145 Referrer referrer_;
126 std::string referrer_encoding_; 146 std::string referrer_encoding_;
127 int render_process_host_id_; 147 int render_process_host_id_;
128 int render_view_host_routing_id_; 148 int render_view_host_routing_id_;
129 ResourceContext* resource_context_; 149 ResourceContext* resource_context_;
130 ResourceDispatcherHost* resource_dispatcher_host_; 150 ResourceDispatcherHost* resource_dispatcher_host_;
131 scoped_ptr<DownloadSaveInfo> save_info_; 151 DownloadSaveInfo save_info_;
132 GURL url_; 152 GURL url_;
133 153
134 DISALLOW_COPY_AND_ASSIGN(DownloadUrlParameters); 154 DISALLOW_COPY_AND_ASSIGN(DownloadUrlParameters);
135 }; 155 };
136 156
137 } // namespace content 157 } // namespace content
138 158
139 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_URL_PARAMETERS_H_ 159 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_URL_PARAMETERS_H_
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | content/public/browser/download_url_parameters.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698