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

Unified Diff: content/browser/background_fetch/background_fetch_job_controller.cc

Issue 2829443002: Give Background Fetch downloads an explicit path on Android (Closed)
Patch Set: Created 3 years, 8 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/background_fetch/background_fetch_job_controller.cc
diff --git a/content/browser/background_fetch/background_fetch_job_controller.cc b/content/browser/background_fetch/background_fetch_job_controller.cc
index e4dd64716a049e5ff476cf5e3cbbde365f1d6605..3d4297ccb89ac22d978d9794a746fb87373d783c 100644
--- a/content/browser/background_fetch/background_fetch_job_controller.cc
+++ b/content/browser/background_fetch/background_fetch_job_controller.cc
@@ -18,8 +18,24 @@
#include "content/public/browser/download_manager.h"
#include "net/url_request/url_request_context_getter.h"
+#if defined(OS_ANDROID)
+#include "base/android/path_utils.h"
+#include "base/files/file_path.h"
+#include "base/guid.h"
+#endif
+
namespace content {
+#if defined(OS_ANDROID)
+namespace {
+
+// Prefix for files stored in the Chromium-internal download directory to
+// indicate files thta were fetched through Background Fetch.
shaktisahu 2017/04/18 20:16:56 nit: typo
+const char kBackgroundFetchFilePrefix[] = "BGFetch-";
+
+} // namespace
+#endif // defined(OS_ANDROID)
+
// Internal functionality of the BackgroundFetchJobController that lives on the
// UI thread, where all interaction with the download manager must happen.
class BackgroundFetchJobController::Core : public DownloadItem::Observer {
@@ -59,7 +75,20 @@ class BackgroundFetchJobController::Core : public DownloadItem::Observer {
// TODO(peter): The |download_parameters| should be populated with all the
// properties set in the |fetch_request| structure.
+ // TODO(peter): Background Fetch responses should not end up in the user's
+ // download folder on any platform. Find an appropriate solution for desktop
+ // too. The Android internal directory is not scoped to a profile.
+
download_parameters->set_transient(true);
+
+#if defined(OS_ANDROID)
+ base::FilePath download_directory;
+ if (base::android::GetDownloadInternalDirectory(&download_directory)) {
+ download_parameters->set_file_path(download_directory.Append(
+ std::string(kBackgroundFetchFilePrefix) + base::GenerateGUID()));
+ }
+#endif // defined(OS_ANDROID)
+
download_parameters->set_callback(base::Bind(&Core::DidStartRequest,
weak_ptr_factory_.GetWeakPtr(),
std::move(request)));
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698