Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(624)

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

Issue 114193009: [Download] Return DownloadInterruptReason from OnStartedCallback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months 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
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "content/public/browser/download_interrupt_reasons.h"
13 #include "content/public/browser/download_save_info.h" 14 #include "content/public/browser/download_save_info.h"
14 #include "content/public/common/referrer.h" 15 #include "content/public/common/referrer.h"
15 #include "net/base/net_errors.h"
16 #include "url/gurl.h" 16 #include "url/gurl.h"
17 17
18 namespace content { 18 namespace content {
19 19
20 class DownloadItem; 20 class DownloadItem;
21 class ResourceContext; 21 class ResourceContext;
22 class ResourceDispatcherHost; 22 class ResourceDispatcherHost;
23 class WebContents; 23 class WebContents;
24 24
25 // Pass an instance of DownloadUrlParameters to DownloadManager::DownloadUrl() 25 // Pass an instance of DownloadUrlParameters to DownloadManager::DownloadUrl()
26 // to download the content at |url|. All parameters with setters are optional. 26 // to download the content at |url|. All parameters with setters are optional.
27 // |referrer| and |referrer_encoding| are the referrer for the download. If 27 // |referrer| and |referrer_encoding| are the referrer for the download. If
28 // |prefer_cache| is true, then if the response to |url| is in the HTTP cache it 28 // |prefer_cache| is true, then if the response to |url| is in the HTTP cache it
29 // will be used without revalidation. If |post_id| is non-negative, then it 29 // will be used without revalidation. If |post_id| is non-negative, then it
30 // identifies the post transaction used to originally retrieve the |url| 30 // identifies the post transaction used to originally retrieve the |url|
31 // resource - it also requires |prefer_cache| to be |true| since re-post'ing is 31 // resource - it also requires |prefer_cache| to be |true| since re-post'ing is
32 // not done. |save_info| specifies where the downloaded file should be saved, 32 // not done. |save_info| specifies where the downloaded file should be saved,
33 // and whether the user should be prompted about the download. If not null, 33 // and whether the user should be prompted about the download. If not null,
34 // |callback| will be called when the download starts, or if an error occurs 34 // |callback| will be called when the download starts, or if an error occurs
35 // that prevents a download item from being created. We send a pointer to 35 // that prevents a download item from being created. We send a pointer to
36 // content::ResourceContext instead of the usual reference so that a copy of the 36 // content::ResourceContext instead of the usual reference so that a copy of the
37 // object isn't made. 37 // object isn't made.
38 38
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*, DownloadInterruptReason)>
43 OnStartedCallback;
43 44
44 typedef std::pair<std::string, std::string> RequestHeadersNameValuePair; 45 typedef std::pair<std::string, std::string> RequestHeadersNameValuePair;
45 typedef std::vector<RequestHeadersNameValuePair> RequestHeadersType; 46 typedef std::vector<RequestHeadersNameValuePair> RequestHeadersType;
46 47
47 static DownloadUrlParameters* FromWebContents( 48 static DownloadUrlParameters* FromWebContents(
48 WebContents* web_contents, 49 WebContents* web_contents,
49 const GURL& url); 50 const GURL& url);
50 51
51 DownloadUrlParameters( 52 DownloadUrlParameters(
52 const GURL& url, 53 const GURL& url,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 save_info_.hash_state = hash_state; 98 save_info_.hash_state = hash_state;
98 } 99 }
99 void set_prompt(bool prompt) { save_info_.prompt_for_save_location = prompt; } 100 void set_prompt(bool prompt) { save_info_.prompt_for_save_location = prompt; }
100 void set_file_stream(scoped_ptr<net::FileStream> file_stream) { 101 void set_file_stream(scoped_ptr<net::FileStream> file_stream) {
101 save_info_.file_stream = file_stream.Pass(); 102 save_info_.file_stream = file_stream.Pass();
102 } 103 }
103 104
104 const OnStartedCallback& callback() const { return callback_; } 105 const OnStartedCallback& callback() const { return callback_; }
105 bool content_initiated() const { return content_initiated_; } 106 bool content_initiated() const { return content_initiated_; }
106 int load_flags() const { return load_flags_; } 107 int load_flags() const { return load_flags_; }
107 const std::string& last_modified() { return last_modified_; } 108 const std::string& last_modified() const { return last_modified_; }
108 const std::string& etag() { return etag_; } 109 const std::string& etag() const { return etag_; }
109 const std::string& method() const { return method_; } 110 const std::string& method() const { return method_; }
110 const std::string& post_body() const { return post_body_; } 111 const std::string& post_body() const { return post_body_; }
111 int64 post_id() const { return post_id_; } 112 int64 post_id() const { return post_id_; }
112 bool prefer_cache() const { return prefer_cache_; } 113 bool prefer_cache() const { return prefer_cache_; }
113 const Referrer& referrer() const { return referrer_; } 114 const Referrer& referrer() const { return referrer_; }
114 const std::string& referrer_encoding() const { return referrer_encoding_; } 115 const std::string& referrer_encoding() const { return referrer_encoding_; }
115 int render_process_host_id() const { return render_process_host_id_; } 116 int render_process_host_id() const { return render_process_host_id_; }
116 int render_view_host_routing_id() const { 117 int render_view_host_routing_id() const {
117 return render_view_host_routing_id_; 118 return render_view_host_routing_id_;
118 } 119 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 ResourceContext* resource_context_; 159 ResourceContext* resource_context_;
159 DownloadSaveInfo save_info_; 160 DownloadSaveInfo save_info_;
160 GURL url_; 161 GURL url_;
161 162
162 DISALLOW_COPY_AND_ASSIGN(DownloadUrlParameters); 163 DISALLOW_COPY_AND_ASSIGN(DownloadUrlParameters);
163 }; 164 };
164 165
165 } // namespace content 166 } // namespace content
166 167
167 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_URL_PARAMETERS_H_ 168 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_URL_PARAMETERS_H_
OLDNEW
« no previous file with comments | « content/public/browser/download_interrupt_reasons.h ('k') | content/public/browser/resource_dispatcher_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698