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

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

Issue 2833793002: Added AddDownload communication path and observers
Patch Set: Addressed comments and moved thrad jumps into the client proxy. 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
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,

Powered by Google App Engine
This is Rietveld 408576698