Chromium Code Reviews| 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))); |