Commit 9329f741 authored by Findit's avatar Findit

Revert "[Background Fetch] Delete the unused FetchedEvent files."

This reverts commit f7206154.

Reason for revert:

Findit (https://goo.gl/kROfz5) identified CL at revision 577271 as the
culprit for failures in the build cycles as shown on:
https://findit-for-me.appspot.com/waterfall/culprit?key=ag9zfmZpbmRpdC1mb3ItbWVyRAsSDVdmU3VzcGVjdGVkQ0wiMWNocm9taXVtL2Y3MjA2MTU0ZmI0OTcwZjQzZWY3YjQ4NTM0OGNkZjMyYzg4ZDkyNjYM

Sample Failed Build: https://ci.chromium.org/buildbot/chromium/Linux%20x64/70091

Sample Failed Step: compile

Original change's description:
> [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: Mugdha Lakhani <nator@chromium.org>
> Reviewed-by: Peter Beverloo <peter@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#577271}

Change-Id: Ic3771c3853efcdcc742d5aadcbfdf8377b73c7d4
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 822765
Reviewed-on: https://chromium-review.googlesource.com/1146941
Cr-Commit-Position: refs/heads/master@{#577275}
parent 3df5254f
......@@ -64,6 +64,11 @@ 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,6 +22,7 @@ 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,6 +32,8 @@ 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,6 +74,7 @@ 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",
......@@ -468,6 +469,7 @@ 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