Chromium Code Reviews| Index: content/browser/background_fetch/background_fetch_client_proxy.cc |
| diff --git a/content/browser/background_fetch/background_fetch_client_proxy.cc b/content/browser/background_fetch/background_fetch_client_proxy.cc |
| index d1dd0316d0a5ae19990435925806c1da42781e04..8f53efbd9e1828b7fb277e81df66ab69dfec25cb 100644 |
| --- a/content/browser/background_fetch/background_fetch_client_proxy.cc |
| +++ b/content/browser/background_fetch/background_fetch_client_proxy.cc |
| @@ -6,18 +6,44 @@ |
| #include "content/browser/background_fetch/background_fetch_context.h" |
| #include "content/browser/background_fetch/background_fetch_registration_id.h" |
| +#include "content/common/background_fetch/background_fetch_types.h" |
| +#include "content/public/browser/browser_context.h" |
| #include "content/public/browser/browser_thread.h" |
| namespace content { |
| BackgroundFetchClientProxy::BackgroundFetchClientProxy( |
| + BrowserContext* browser_context, |
| BackgroundFetchContext* background_fetch_context) |
| - : background_fetch_context_(background_fetch_context) { |
| + : background_fetch_context_(background_fetch_context), |
| + weak_ptr_factory_(this) { |
| DCHECK(background_fetch_context); |
| + DCHECK(browser_context); |
| + background_fetch_client_ = browser_context->GetBackgroundFetchClient(); |
| + DCHECK(background_fetch_client_); |
| } |
| BackgroundFetchClientProxy::~BackgroundFetchClientProxy() = default; |
| +void BackgroundFetchClientProxy::AddDownload( |
| + const GURL& url, |
| + const std::string& registration_id, |
| + const BackgroundFetchOptions& options) { |
| + BrowserThread::PostTask( |
|
Peter Beverloo
2017/04/24 14:39:15
DCHECK_CURRENTLY_ON() to both new methods.
AddDow
|
| + BrowserThread::IO, FROM_HERE, |
| + base::Bind(&BackgroundFetchClientProxy::AddDownloadOnIO, |
| + weak_ptr_factory_.GetWeakPtr(), url, registration_id, |
| + options)); |
| +} |
| + |
| +void BackgroundFetchClientProxy::AddDownloadOnIO( |
| + const GURL& url, |
| + const std::string& registration_id, |
| + const BackgroundFetchOptions& options) { |
| + background_fetch_client_->AddDownload(url, registration_id, options.title, |
| + options.total_download_size); |
| +} |
| + |
| void BackgroundFetchClientProxy::CleanupAllTasks() { |
| DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |