| Index: third_party/WebKit/Source/modules/background_fetch/BackgroundFetchBridge.cpp
|
| diff --git a/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchBridge.cpp b/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchBridge.cpp
|
| index 1c1b63f929da9c6481fc3dbb6befd7b1013401b0..c65ff59ec9c440ae743fe50a027ee5407b8f2f07 100644
|
| --- a/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchBridge.cpp
|
| +++ b/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchBridge.cpp
|
| @@ -7,6 +7,7 @@
|
| #include <utility>
|
| #include "modules/background_fetch/BackgroundFetchOptions.h"
|
| #include "modules/background_fetch/BackgroundFetchRegistration.h"
|
| +#include "modules/background_fetch/BackgroundFetchTypeConverters.h"
|
| #include "modules/background_fetch/IconDefinition.h"
|
| #include "public/platform/InterfaceProvider.h"
|
| #include "public/platform/Platform.h"
|
| @@ -14,31 +15,6 @@
|
|
|
| namespace blink {
|
|
|
| -namespace {
|
| -
|
| -// Creates a new BackgroundFetchRegistration instance given a Service Worker
|
| -// Registration and a Mojo BackgroundFetchRegistrationPtr instance.
|
| -BackgroundFetchRegistration* CreateBackgroundFetchRegistration(
|
| - ServiceWorkerRegistration* serviceWorkerRegistration,
|
| - mojom::blink::BackgroundFetchRegistrationPtr registrationPtr) {
|
| - HeapVector<IconDefinition> icons;
|
| -
|
| - for (const auto& iconPtr : registrationPtr->icons) {
|
| - IconDefinition icon;
|
| - icon.setSrc(iconPtr->src);
|
| - icon.setSizes(iconPtr->sizes);
|
| - icon.setType(iconPtr->type);
|
| -
|
| - icons.push_back(icon);
|
| - }
|
| -
|
| - return new BackgroundFetchRegistration(
|
| - serviceWorkerRegistration, registrationPtr->tag, std::move(icons),
|
| - registrationPtr->total_download_size, registrationPtr->title);
|
| -}
|
| -
|
| -} // namespace
|
| -
|
| // static
|
| BackgroundFetchBridge* BackgroundFetchBridge::from(
|
| ServiceWorkerRegistration* serviceWorkerRegistration) {
|
| @@ -68,6 +44,18 @@ BackgroundFetchBridge::BackgroundFetchBridge(
|
|
|
| BackgroundFetchBridge::~BackgroundFetchBridge() = default;
|
|
|
| +void BackgroundFetchBridge::fetch(
|
| + const String& tag,
|
| + const BackgroundFetchOptions& options,
|
| + std::unique_ptr<RegistrationCallback> callback) {
|
| + getService()->Fetch(
|
| + supplementable()->webRegistration()->registrationId(), tag,
|
| + mojom::blink::BackgroundFetchOptions::From(options),
|
| + convertToBaseCallback(
|
| + WTF::bind(&BackgroundFetchBridge::didGetRegistration,
|
| + wrapPersistent(this), WTF::passed(std::move(callback)))));
|
| +}
|
| +
|
| void BackgroundFetchBridge::abort(const String& tag,
|
| std::unique_ptr<AbortCallback> callback) {
|
| getService()->Abort(supplementable()->webRegistration()->registrationId(),
|
| @@ -85,7 +73,7 @@ void BackgroundFetchBridge::updateUI(
|
|
|
| void BackgroundFetchBridge::getRegistration(
|
| const String& tag,
|
| - std::unique_ptr<GetRegistrationCallback> callback) {
|
| + std::unique_ptr<RegistrationCallback> callback) {
|
| getService()->GetRegistration(
|
| supplementable()->webRegistration()->registrationId(), tag,
|
| convertToBaseCallback(
|
| @@ -94,15 +82,15 @@ void BackgroundFetchBridge::getRegistration(
|
| }
|
|
|
| void BackgroundFetchBridge::didGetRegistration(
|
| - std::unique_ptr<GetRegistrationCallback> callback,
|
| + std::unique_ptr<RegistrationCallback> callback,
|
| mojom::blink::BackgroundFetchError error,
|
| mojom::blink::BackgroundFetchRegistrationPtr registrationPtr) {
|
| - BackgroundFetchRegistration* registration = nullptr;
|
| + BackgroundFetchRegistration* registration =
|
| + registrationPtr.To<BackgroundFetchRegistration*>();
|
|
|
| - if (registrationPtr) {
|
| + if (registration) {
|
| DCHECK_EQ(error, mojom::blink::BackgroundFetchError::NONE);
|
| - registration = CreateBackgroundFetchRegistration(
|
| - supplementable(), std::move(registrationPtr));
|
| + registration->setServiceWorkerRegistration(supplementable());
|
| }
|
|
|
| (*callback)(error, registration);
|
|
|