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..6523053efafb3340569b8004a350858515fb3230 |
--- /dev/null |
+++ b/content/browser/background_fetch/background_fetch_client_proxy.cc |
@@ -0,0 +1,63 @@ |
+// 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::CancelDownload( |
+ const std::string& registration_id) { |
+ DCHECK_CURRENTLY_ON(BrowserThread::UI); |
+ BackgroundFetchRegistrationId deserialized_id; |
+ if (!BackgroundFetchRegistrationId::Deserialize(registration_id, |
+ deserialized_id)) |
+ return; |
Peter Beverloo
2017/03/31 01:32:23
nit: {} (condition is multiple lines, elsewhere to
Peter Beverloo
2017/03/31 01:32:23
LOG(ERROR)? This shouldn't crash, but it also shou
harkness
2017/03/31 10:11:43
I added a log without printing the string. I wasn'
harkness
2017/03/31 10:11:44
Ah git cl format, you fail me!
|
+ |
+ BrowserThread::PostTask( |
+ BrowserThread::IO, FROM_HERE, |
+ base::Bind(&BackgroundFetchContext::CancelFetch, |
+ background_fetch_context_, deserialized_id)); |
Peter Beverloo
2017/03/31 01:32:23
I guess we're getting scoped_refptr lifetime seman
harkness
2017/03/31 10:11:43
That's what I was counting on. Do you want me to m
|
+} |
+ |
+void BackgroundFetchClientProxy::PauseDownload( |
+ const std::string& registration_id) { |
+ DCHECK_CURRENTLY_ON(BrowserThread::UI); |
+ BackgroundFetchRegistrationId deserialized_id; |
+ if (!BackgroundFetchRegistrationId::Deserialize(registration_id, |
+ deserialized_id)) |
+ 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)) |
+ return; |
+ |
+ BrowserThread::PostTask( |
+ BrowserThread::IO, FROM_HERE, |
+ base::Bind(&BackgroundFetchContext::ResumeFetch, |
+ background_fetch_context_, deserialized_id)); |
+} |
+ |
+} // namespace content |