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

Unified Diff: content/browser/renderer_host/resource_dispatcher_host.cc

Issue 7192016: chrome.experimental.downloads (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: merged db_handle, id; onCreated, onErased Created 9 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/renderer_host/resource_dispatcher_host.h ('k') | net/url_request/url_request.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/resource_dispatcher_host.cc
diff --git a/content/browser/renderer_host/resource_dispatcher_host.cc b/content/browser/renderer_host/resource_dispatcher_host.cc
index 314be906f6ca31d2c79d251bf518bc7bc024ab5f..622cf73457f05d799a5120261f054ed432c9e5ef 100644
--- a/content/browser/renderer_host/resource_dispatcher_host.cc
+++ b/content/browser/renderer_host/resource_dispatcher_host.cc
@@ -7,6 +7,7 @@
#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include <set>
+#include <string>
#include <vector>
#include "base/bind.h"
@@ -18,6 +19,7 @@
#include "base/shared_memory.h"
#include "base/stl_util-inl.h"
#include "base/time.h"
+#include "base/values.h"
#include "chrome/browser/download/download_file_manager.h"
#include "chrome/browser/download/download_manager.h"
#include "chrome/browser/download/download_request_limiter.h"
@@ -679,8 +681,34 @@ void ResourceDispatcherHost::BeginDownload(
int child_id,
int route_id,
const content::ResourceContext& context) {
- if (is_shutdown_)
+ net::URLRequest* request = new net::URLRequest(url, this);
+ request->set_method("GET");
+ request->set_referrer(MaybeStripReferrer(referrer).spec());
+ BeginDownload(
+ request,
+ save_info,
+ prompt_for_save_location,
+ DownloadResourceHandler::OnStartedCallback(),
+ child_id,
+ route_id,
+ context);
+}
+
+void ResourceDispatcherHost::BeginDownload(
+ net::URLRequest* request,
+ const DownloadSaveInfo& save_info,
+ bool prompt_for_save_location,
+ DownloadResourceHandler::OnStartedCallback started_cb,
+ int child_id,
+ int route_id,
+ const content::ResourceContext& context) {
+ CHECK(request);
+ scoped_ptr<net::URLRequest> delete_request(request);
+ if (is_shutdown_) {
return;
+ }
+ const GURL& url = request->original_url();
+ request->set_referrer(MaybeStripReferrer(GURL(request->referrer())).spec());
// Check if the renderer is permitted to request the requested URL.
if (!ChildProcessSecurityPolicy::GetInstance()->
@@ -690,12 +718,8 @@ void ResourceDispatcherHost::BeginDownload(
return;
}
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- NewRunnableFunction(&download_util::NotifyDownloadInitiated,
- child_id, route_id));
-
- net::URLRequest* request = new net::URLRequest(url, this);
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, NewRunnableFunction(
+ &download_util::NotifyDownloadInitiated, child_id, route_id));
request_id_--;
@@ -706,30 +730,29 @@ void ResourceDispatcherHost::BeginDownload(
request_id_,
url,
download_file_manager_.get(),
- request,
+ delete_request.release(),
prompt_for_save_location,
+ started_cb,
save_info));
- if (delegate_)
+ if (delegate_) {
handler = delegate_->DownloadStarting(handler, child_id, route_id);
+ }
const net::URLRequestContext* request_context = context.request_context();
-
if (!request_context->job_factory()->IsHandledURL(url)) {
VLOG(1) << "Download request for unsupported protocol: "
<< url.possibly_invalid_spec();
return;
}
- request->set_method("GET");
- request->set_referrer(MaybeStripReferrer(referrer).spec());
request->set_context(context.request_context());
request->set_load_flags(request->load_flags() |
net::LOAD_IS_DOWNLOAD);
ResourceDispatcherHostRequestInfo* extra_info =
CreateRequestInfoForBrowserRequest(
- handler, child_id, route_id, true, context);
+ handler, child_id, route_id, true/*download*/, context);
SetRequestInfo(request, extra_info); // Request takes ownership.
BeginRequestInternal(request);
« no previous file with comments | « content/browser/renderer_host/resource_dispatcher_host.h ('k') | net/url_request/url_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698