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

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

Issue 2777063008: Connect BackgroundFetch to the OfflineItemCollection
Patch Set: Fixed incognito check and added tests 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
new file mode 100644
index 0000000000000000000000000000000000000000..d1dd0316d0a5ae19990435925806c1da42781e04
--- /dev/null
+++ b/content/browser/background_fetch/background_fetch_client_proxy.cc
@@ -0,0 +1,76 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/background_fetch/background_fetch_client_proxy.h"
+
+#include "content/browser/background_fetch/background_fetch_context.h"
+#include "content/browser/background_fetch/background_fetch_registration_id.h"
+#include "content/public/browser/browser_thread.h"
+
+namespace content {
+
+BackgroundFetchClientProxy::BackgroundFetchClientProxy(
+ BackgroundFetchContext* background_fetch_context)
+ : background_fetch_context_(background_fetch_context) {
+ DCHECK(background_fetch_context);
+}
+
+BackgroundFetchClientProxy::~BackgroundFetchClientProxy() = default;
+
+void BackgroundFetchClientProxy::CleanupAllTasks() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
+ base::Bind(&BackgroundFetchContext::CleanupAllTasks,
+ background_fetch_context_));
+}
+
+void BackgroundFetchClientProxy::CancelDownload(
+ const std::string& registration_id) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ BackgroundFetchRegistrationId deserialized_id;
+ if (!BackgroundFetchRegistrationId::Deserialize(registration_id,
+ &deserialized_id)) {
+ LOG(ERROR) << "Unable to deserialize registration_id from embedder.";
+ return;
+ }
+
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&BackgroundFetchContext::CancelFetch,
+ background_fetch_context_, deserialized_id));
+}
+
+void BackgroundFetchClientProxy::PauseDownload(
+ const std::string& registration_id) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ BackgroundFetchRegistrationId deserialized_id;
+ if (!BackgroundFetchRegistrationId::Deserialize(registration_id,
+ &deserialized_id)) {
+ LOG(ERROR) << "Unable to deserialize registration_id from embedder.";
+ return;
+ }
+
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&BackgroundFetchContext::PauseFetch, background_fetch_context_,
+ deserialized_id));
+}
+
+void BackgroundFetchClientProxy::ResumeDownload(
+ const std::string& registration_id) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ BackgroundFetchRegistrationId deserialized_id;
+ if (!BackgroundFetchRegistrationId::Deserialize(registration_id,
+ &deserialized_id)) {
+ LOG(ERROR) << "Unable to deserialize registration_id from embedder.";
+ return;
+ }
+
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&BackgroundFetchContext::ResumeFetch,
+ background_fetch_context_, deserialized_id));
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698