Commit f7206154 authored by Rayan Kanso's avatar Rayan Kanso Committed by Commit Bot

[Background Fetch] Delete the unused FetchedEvent files.

TBR=jbroman@chromium.org

Bug: 822765
Change-Id: I03fa9efc6fa80814f252593a0582ff25b633580b
Reviewed-on: https://chromium-review.googlesource.com/1142154
Commit-Queue: Rayan Kanso <rayankans@chromium.org>
Reviewed-by: default avatarMugdha Lakhani <nator@chromium.org>
Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577271}
parent e514dd71
......@@ -64,11 +64,6 @@ interface BackgroundFetchUpdateEvent : BackgroundFetchSettledEvent
attribute @@toStringTag
method constructor
method updateUI
interface BackgroundFetchedEvent : BackgroundFetchEvent
attribute @@toStringTag
getter fetches
method constructor
method updateUI
interface BarcodeDetector
attribute @@toStringTag
method constructor
......
......@@ -22,7 +22,6 @@ generate_event_interfaces("modules_bindings_generated_event_interfaces") {
"//third_party/blink/renderer/modules/background_fetch/background_fetch_click_event.idl",
"//third_party/blink/renderer/modules/background_fetch/background_fetch_event.idl",
"//third_party/blink/renderer/modules/background_fetch/background_fetch_fail_event.idl",
"//third_party/blink/renderer/modules/background_fetch/background_fetched_event.idl",
"//third_party/blink/renderer/modules/background_sync/sync_event.idl",
"//third_party/blink/renderer/modules/cookie_store/cookie_change_event.idl",
"//third_party/blink/renderer/modules/cookie_store/extendable_cookie_change_event.idl",
......
......@@ -32,8 +32,6 @@ blink_modules_sources("background_fetch") {
"background_fetch_type_converters.h",
"background_fetch_update_event.cc",
"background_fetch_update_event.h",
"background_fetched_event.cc",
"background_fetched_event.h",
"service_worker_global_scope_background_fetch.h",
"service_worker_registration_background_fetch.cc",
"service_worker_registration_background_fetch.h",
......
// 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 "third_party/blink/renderer/modules/background_fetch/background_fetched_event.h"
#include "third_party/blink/public/platform/modules/background_fetch/web_background_fetch_settled_fetch.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/fetch/request.h"
#include "third_party/blink/renderer/core/fetch/response.h"
#include "third_party/blink/renderer/modules/background_fetch/background_fetch_bridge.h"
#include "third_party/blink/renderer/modules/background_fetch/background_fetch_settled_fetch.h"
#include "third_party/blink/renderer/modules/background_fetch/background_fetched_event_init.h"
#include "third_party/blink/renderer/modules/event_modules_names.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
namespace blink {
BackgroundFetchedEvent::BackgroundFetchedEvent(
const AtomicString& type,
const BackgroundFetchedEventInit& initializer)
: BackgroundFetchEvent(type, initializer, nullptr /* observer */),
fetches_(initializer.fetches()) {}
BackgroundFetchedEvent::BackgroundFetchedEvent(
const AtomicString& type,
const BackgroundFetchedEventInit& initializer,
const String& unique_id,
const WebVector<WebBackgroundFetchSettledFetch>& fetches,
ScriptState* script_state,
WaitUntilObserver* observer,
ServiceWorkerRegistration* registration)
: BackgroundFetchEvent(type, initializer, observer),
unique_id_(unique_id),
registration_(registration) {
fetches_.ReserveInitialCapacity(fetches.size());
for (const WebBackgroundFetchSettledFetch& fetch : fetches) {
auto* settled_fetch = BackgroundFetchSettledFetch::Create(
Request::Create(script_state, fetch.request),
Response::Create(script_state, fetch.response));
fetches_.push_back(settled_fetch);
}
}
BackgroundFetchedEvent::~BackgroundFetchedEvent() = default;
HeapVector<Member<BackgroundFetchSettledFetch>>
BackgroundFetchedEvent::fetches() const {
return fetches_;
}
ScriptPromise BackgroundFetchedEvent::updateUI(ScriptState* script_state,
const String& title) {
if (!registration_) {
// Return a Promise that will never settle when a developer calls this
// method on a BackgroundFetchedEvent instance they created themselves.
return ScriptPromise();
}
DCHECK(!unique_id_.IsEmpty());
ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state);
ScriptPromise promise = resolver->Promise();
BackgroundFetchBridge::From(registration_)
->UpdateUI(id(), unique_id_, title,
WTF::Bind(&BackgroundFetchedEvent::DidUpdateUI,
WrapPersistent(this), WrapPersistent(resolver)));
return promise;
}
void BackgroundFetchedEvent::DidUpdateUI(
ScriptPromiseResolver* resolver,
mojom::blink::BackgroundFetchError error) {
switch (error) {
case mojom::blink::BackgroundFetchError::NONE:
case mojom::blink::BackgroundFetchError::INVALID_ID:
resolver->Resolve();
return;
case mojom::blink::BackgroundFetchError::STORAGE_ERROR:
resolver->Reject(
DOMException::Create(DOMExceptionCode::kAbortError,
"Failed to update UI due to I/O error."));
return;
case mojom::blink::BackgroundFetchError::SERVICE_WORKER_UNAVAILABLE:
case mojom::blink::BackgroundFetchError::DUPLICATED_DEVELOPER_ID:
case mojom::blink::BackgroundFetchError::INVALID_ARGUMENT:
// Not applicable for this callback.
break;
}
NOTREACHED();
}
const AtomicString& BackgroundFetchedEvent::InterfaceName() const {
return EventNames::BackgroundFetchedEvent;
}
void BackgroundFetchedEvent::Trace(blink::Visitor* visitor) {
visitor->Trace(fetches_);
visitor->Trace(registration_);
BackgroundFetchEvent::Trace(visitor);
}
} // namespace blink
// 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.
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_BACKGROUND_FETCH_BACKGROUND_FETCHED_EVENT_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_BACKGROUND_FETCH_BACKGROUND_FETCHED_EVENT_H_
#include "third_party/blink/public/platform/modules/background_fetch/background_fetch.mojom-blink.h"
#include "third_party/blink/public/platform/web_vector.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
#include "third_party/blink/renderer/modules/background_fetch/background_fetch_event.h"
#include "third_party/blink/renderer/modules/modules_export.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/wtf/text/atomic_string.h"
namespace blink {
class BackgroundFetchSettledFetch;
class BackgroundFetchedEventInit;
class ScriptPromiseResolver;
class ScriptState;
class ServiceWorkerRegistration;
struct WebBackgroundFetchSettledFetch;
class MODULES_EXPORT BackgroundFetchedEvent final
: public BackgroundFetchEvent {
DEFINE_WRAPPERTYPEINFO();
public:
static BackgroundFetchedEvent* Create(
const AtomicString& type,
const BackgroundFetchedEventInit& initializer) {
return new BackgroundFetchedEvent(type, initializer);
}
static BackgroundFetchedEvent* Create(
const AtomicString& type,
const BackgroundFetchedEventInit& initializer,
const String& unique_id,
const WebVector<WebBackgroundFetchSettledFetch>& fetches,
ScriptState* script_state,
WaitUntilObserver* observer,
ServiceWorkerRegistration* registration) {
return new BackgroundFetchedEvent(type, initializer, unique_id, fetches,
script_state, observer, registration);
}
~BackgroundFetchedEvent() override;
// Web Exposed attribute defined in the IDL file.
HeapVector<Member<BackgroundFetchSettledFetch>> fetches() const;
// Web Exposed method defined in the IDL file.
ScriptPromise updateUI(ScriptState* script_state, const String& title);
// ExtendableEvent interface.
const AtomicString& InterfaceName() const override;
void Trace(blink::Visitor* visitor) override;
private:
BackgroundFetchedEvent(const AtomicString& type,
const BackgroundFetchedEventInit& initializer);
BackgroundFetchedEvent(
const AtomicString& type,
const BackgroundFetchedEventInit& initializer,
const String& unique_id,
const WebVector<WebBackgroundFetchSettledFetch>& fetches,
ScriptState* script_state,
WaitUntilObserver* observer,
ServiceWorkerRegistration* registration);
void DidUpdateUI(ScriptPromiseResolver* resolver,
mojom::blink::BackgroundFetchError error);
// Globally unique ID for the registration, generated in content/. Used to
// distinguish registrations in case a developer re-uses |developer_id_|s. Not
// exposed to JavaScript.
String unique_id_;
HeapVector<Member<BackgroundFetchSettledFetch>> fetches_;
Member<ServiceWorkerRegistration> registration_;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_BACKGROUND_FETCH_BACKGROUND_FETCHED_EVENT_H_
// 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.
// https://wicg.github.io/background-fetch/#background-fetch-end-event
[
Constructor(DOMString type, BackgroundFetchedEventInit init),
Exposed=ServiceWorker,
RuntimeEnabled=BackgroundFetch
] interface BackgroundFetchedEvent : BackgroundFetchEvent {
readonly attribute FrozenArray<BackgroundFetchSettledFetch> fetches;
[CallWith=ScriptState] Promise<void> updateUI(DOMString title);
};
// 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.
// https://wicg.github.io/background-fetch/#background-fetch-end-event
dictionary BackgroundFetchedEventInit : BackgroundFetchEventInit {
required sequence<BackgroundFetchSettledFetch> fetches;
};
......@@ -74,7 +74,6 @@ modules_idl_files =
"background_fetch/background_fetch_settled_fetch.idl",
"background_fetch/background_fetch_settled_fetches.idl",
"background_fetch/background_fetch_update_event.idl",
"background_fetch/background_fetched_event.idl",
"background_sync/sync_event.idl",
"background_sync/sync_manager.idl",
"battery/battery_manager.idl",
......@@ -469,7 +468,6 @@ modules_dictionary_idl_files =
"background_fetch/background_fetch_fail_event_init.idl",
"background_fetch/background_fetch_options.idl",
"background_fetch/background_fetch_settled_event_init.idl",
"background_fetch/background_fetched_event_init.idl",
"background_sync/sync_event_init.idl",
"bluetooth/bluetooth_le_scan_filter_init.idl",
"bluetooth/request_device_options.idl",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment