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

Side by Side Diff: chrome/browser/android/download/download_controller.cc

Issue 2860593003: Refactoring DownloadManager::DownloadURL to add proper annotation. (Closed)
Patch Set: Comment addressed. Created 3 years, 6 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
« no previous file with comments | « no previous file | chrome/browser/android/offline_pages/downloads/offline_page_download_bridge.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "chrome/browser/android/download/download_controller.h" 5 #include "chrome/browser/android/download/download_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
(...skipping 12 matching lines...) Expand all
23 #include "chrome/grit/chromium_strings.h" 23 #include "chrome/grit/chromium_strings.h"
24 #include "content/public/browser/browser_context.h" 24 #include "content/public/browser/browser_context.h"
25 #include "content/public/browser/browser_thread.h" 25 #include "content/public/browser/browser_thread.h"
26 #include "content/public/browser/download_manager.h" 26 #include "content/public/browser/download_manager.h"
27 #include "content/public/browser/download_url_parameters.h" 27 #include "content/public/browser/download_url_parameters.h"
28 #include "content/public/browser/render_process_host.h" 28 #include "content/public/browser/render_process_host.h"
29 #include "content/public/browser/render_view_host.h" 29 #include "content/public/browser/render_view_host.h"
30 #include "content/public/common/referrer.h" 30 #include "content/public/common/referrer.h"
31 #include "jni/DownloadController_jni.h" 31 #include "jni/DownloadController_jni.h"
32 #include "net/base/filename_util.h" 32 #include "net/base/filename_util.h"
33 #include "net/traffic_annotation/network_traffic_annotation.h"
33 #include "ui/android/view_android.h" 34 #include "ui/android/view_android.h"
34 #include "ui/android/window_android.h" 35 #include "ui/android/window_android.h"
35 #include "ui/base/page_transition_types.h" 36 #include "ui/base/page_transition_types.h"
36 37
37 using base::android::ConvertUTF8ToJavaString; 38 using base::android::ConvertUTF8ToJavaString;
38 using base::android::JavaParamRef; 39 using base::android::JavaParamRef;
39 using base::android::ScopedJavaLocalRef; 40 using base::android::ScopedJavaLocalRef;
40 using content::BrowserContext; 41 using content::BrowserContext;
41 using content::BrowserThread; 42 using content::BrowserThread;
42 using content::ContextMenuParams; 43 using content::ContextMenuParams;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 dl_params->set_referrer(referrer); 85 dl_params->set_referrer(referrer);
85 if (is_link) 86 if (is_link)
86 dl_params->set_referrer_encoding(params.frame_charset); 87 dl_params->set_referrer_encoding(params.frame_charset);
87 net::HttpRequestHeaders headers; 88 net::HttpRequestHeaders headers;
88 headers.AddHeadersFromString(extra_headers); 89 headers.AddHeadersFromString(extra_headers);
89 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();) 90 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();)
90 dl_params->add_request_header(it.name(), it.value()); 91 dl_params->add_request_header(it.name(), it.value());
91 if (!is_link && extra_headers.empty()) 92 if (!is_link && extra_headers.empty())
92 dl_params->set_prefer_cache(true); 93 dl_params->set_prefer_cache(true);
93 dl_params->set_prompt(false); 94 dl_params->set_prompt(false);
94 dlm->DownloadUrl(std::move(dl_params)); 95 dlm->DownloadUrl(std::move(dl_params), NO_TRAFFIC_ANNOTATION_YET);
95 } 96 }
96 97
97 // Check if an interrupted download item can be auto resumed. 98 // Check if an interrupted download item can be auto resumed.
98 bool IsInterruptedDownloadAutoResumable(content::DownloadItem* download_item) { 99 bool IsInterruptedDownloadAutoResumable(content::DownloadItem* download_item) {
99 int interrupt_reason = download_item->GetLastReason(); 100 int interrupt_reason = download_item->GetLastReason();
100 DCHECK_NE(interrupt_reason, content::DOWNLOAD_INTERRUPT_REASON_NONE); 101 DCHECK_NE(interrupt_reason, content::DOWNLOAD_INTERRUPT_REASON_NONE);
101 return 102 return
102 interrupt_reason == content::DOWNLOAD_INTERRUPT_REASON_NETWORK_TIMEOUT || 103 interrupt_reason == content::DOWNLOAD_INTERRUPT_REASON_NETWORK_TIMEOUT ||
103 interrupt_reason == content::DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED || 104 interrupt_reason == content::DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED ||
104 interrupt_reason == 105 interrupt_reason ==
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 int routing_id = web_contents->GetRenderViewHost()->GetRoutingID(); 362 int routing_id = web_contents->GetRenderViewHost()->GetRoutingID();
362 363
363 const content::ResourceRequestInfo::WebContentsGetter& wc_getter( 364 const content::ResourceRequestInfo::WebContentsGetter& wc_getter(
364 base::Bind(&GetWebContents, process_id, routing_id)); 365 base::Bind(&GetWebContents, process_id, routing_id));
365 366
366 AcquireFileAccessPermission( 367 AcquireFileAccessPermission(
367 wc_getter, base::Bind(&CreateContextMenuDownload, wc_getter, params, 368 wc_getter, base::Bind(&CreateContextMenuDownload, wc_getter, params,
368 is_link, extra_headers)); 369 is_link, extra_headers));
369 } 370 }
370 371
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/offline_pages/downloads/offline_page_download_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698