| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/background_fetch/BackgroundFetchBridge.h" | 5 #include "modules/background_fetch/BackgroundFetchBridge.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include "modules/background_fetch/BackgroundFetchOptions.h" | 8 #include "modules/background_fetch/BackgroundFetchOptions.h" |
| 9 #include "modules/background_fetch/BackgroundFetchRegistration.h" | 9 #include "modules/background_fetch/BackgroundFetchRegistration.h" |
| 10 #include "modules/background_fetch/BackgroundFetchTypeConverters.h" | 10 #include "modules/background_fetch/BackgroundFetchTypeConverters.h" |
| 11 #include "modules/background_fetch/IconDefinition.h" | 11 #include "modules/background_fetch/IconDefinition.h" |
| 12 #include "public/platform/InterfaceProvider.h" | 12 #include "public/platform/InterfaceProvider.h" |
| 13 #include "public/platform/Platform.h" | 13 #include "public/platform/Platform.h" |
| 14 #include "public/platform/modules/serviceworker/WebServiceWorkerRegistration.h" | 14 #include "public/platform/modules/serviceworker/WebServiceWorkerRegistration.h" |
| 15 #include "public/platform/modules/serviceworker/WebServiceWorkerRequest.h" |
| 15 | 16 |
| 16 namespace blink { | 17 namespace blink { |
| 17 | 18 |
| 18 // static | 19 // static |
| 19 BackgroundFetchBridge* BackgroundFetchBridge::from( | 20 BackgroundFetchBridge* BackgroundFetchBridge::from( |
| 20 ServiceWorkerRegistration* serviceWorkerRegistration) { | 21 ServiceWorkerRegistration* serviceWorkerRegistration) { |
| 21 DCHECK(serviceWorkerRegistration); | 22 DCHECK(serviceWorkerRegistration); |
| 22 | 23 |
| 23 BackgroundFetchBridge* bridge = static_cast<BackgroundFetchBridge*>( | 24 BackgroundFetchBridge* bridge = static_cast<BackgroundFetchBridge*>( |
| 24 Supplement<ServiceWorkerRegistration>::from(serviceWorkerRegistration, | 25 Supplement<ServiceWorkerRegistration>::from(serviceWorkerRegistration, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 39 } | 40 } |
| 40 | 41 |
| 41 BackgroundFetchBridge::BackgroundFetchBridge( | 42 BackgroundFetchBridge::BackgroundFetchBridge( |
| 42 ServiceWorkerRegistration& registration) | 43 ServiceWorkerRegistration& registration) |
| 43 : Supplement<ServiceWorkerRegistration>(registration) {} | 44 : Supplement<ServiceWorkerRegistration>(registration) {} |
| 44 | 45 |
| 45 BackgroundFetchBridge::~BackgroundFetchBridge() = default; | 46 BackgroundFetchBridge::~BackgroundFetchBridge() = default; |
| 46 | 47 |
| 47 void BackgroundFetchBridge::fetch( | 48 void BackgroundFetchBridge::fetch( |
| 48 const String& tag, | 49 const String& tag, |
| 50 Vector<WebServiceWorkerRequest> requests, |
| 49 const BackgroundFetchOptions& options, | 51 const BackgroundFetchOptions& options, |
| 50 std::unique_ptr<RegistrationCallback> callback) { | 52 std::unique_ptr<RegistrationCallback> callback) { |
| 53 // TODO(peter): Include |requests| in the Mojo call. |
| 51 getService()->Fetch( | 54 getService()->Fetch( |
| 52 supplementable()->webRegistration()->registrationId(), tag, | 55 supplementable()->webRegistration()->registrationId(), tag, |
| 53 mojom::blink::BackgroundFetchOptions::From(options), | 56 mojom::blink::BackgroundFetchOptions::From(options), |
| 54 convertToBaseCallback( | 57 convertToBaseCallback( |
| 55 WTF::bind(&BackgroundFetchBridge::didGetRegistration, | 58 WTF::bind(&BackgroundFetchBridge::didGetRegistration, |
| 56 wrapPersistent(this), WTF::passed(std::move(callback))))); | 59 wrapPersistent(this), WTF::passed(std::move(callback))))); |
| 57 } | 60 } |
| 58 | 61 |
| 59 void BackgroundFetchBridge::abort(const String& tag, | 62 void BackgroundFetchBridge::abort(const String& tag, |
| 60 std::unique_ptr<AbortCallback> callback) { | 63 std::unique_ptr<AbortCallback> callback) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 106 |
| 104 mojom::blink::BackgroundFetchServicePtr& BackgroundFetchBridge::getService() { | 107 mojom::blink::BackgroundFetchServicePtr& BackgroundFetchBridge::getService() { |
| 105 if (!m_backgroundFetchService) { | 108 if (!m_backgroundFetchService) { |
| 106 Platform::current()->interfaceProvider()->getInterface( | 109 Platform::current()->interfaceProvider()->getInterface( |
| 107 mojo::MakeRequest(&m_backgroundFetchService)); | 110 mojo::MakeRequest(&m_backgroundFetchService)); |
| 108 } | 111 } |
| 109 return m_backgroundFetchService; | 112 return m_backgroundFetchService; |
| 110 } | 113 } |
| 111 | 114 |
| 112 } // namespace blink | 115 } // namespace blink |
| OLD | NEW |