Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Unified Diff: content/browser/service_worker/service_worker_version.cc

Issue 1579413004: Move push event dispatching out of ServiceWorkerVersion. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/service_worker/service_worker_version.cc
diff --git a/content/browser/service_worker/service_worker_version.cc b/content/browser/service_worker/service_worker_version.cc
index b77ba3b06ec0ab61b2ac67e528e0bd38e8612d57..f0954a63c127a0791e8dcdb06d04a88768e5c8a3 100644
--- a/content/browser/service_worker/service_worker_version.cc
+++ b/content/browser/service_worker/service_worker_version.cc
@@ -656,30 +656,6 @@ void ServiceWorkerVersion::DispatchNotificationClickEvent(
}
}
-void ServiceWorkerVersion::DispatchPushEvent(const StatusCallback& callback,
- const std::string& data) {
- OnBeginEvent();
- DCHECK_EQ(ACTIVATED, status()) << status();
- if (running_status() != RUNNING) {
- // Schedule calling this method after starting the worker.
- StartWorker(base::Bind(&RunTaskAfterStartWorker,
- weak_factory_.GetWeakPtr(), callback,
- base::Bind(&self::DispatchPushEvent,
- weak_factory_.GetWeakPtr(),
- callback, data)));
- return;
- }
-
- int request_id = AddRequest(callback, &push_requests_, REQUEST_PUSH,
- ServiceWorkerMetrics::EventType::PUSH);
- ServiceWorkerStatusCode status = embedded_worker_->SendMessage(
- ServiceWorkerMsg_PushEvent(request_id, data));
- if (status != SERVICE_WORKER_OK) {
- push_requests_.Remove(request_id);
- RunSoon(base::Bind(callback, status));
- }
-}
-
void ServiceWorkerVersion::DispatchCrossOriginMessageEvent(
const NavigatorConnectClient& client,
const base::string16& message,
@@ -984,8 +960,6 @@ bool ServiceWorkerVersion::OnMessageReceived(const IPC::Message& message) {
OnFetchEventFinished)
IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_NotificationClickEventFinished,
OnNotificationClickEventFinished)
- IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_PushEventFinished,
- OnPushEventFinished)
IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_OpenWindow,
OnOpenWindow)
IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_SetCachedMetadata,
@@ -1175,29 +1149,6 @@ void ServiceWorkerVersion::OnNotificationClickEventFinished(
RemoveCallbackAndStopIfRedundant(&notification_click_requests_, request_id);
}
-void ServiceWorkerVersion::OnPushEventFinished(
- int request_id,
- blink::WebServiceWorkerEventResult result) {
- TRACE_EVENT1("ServiceWorker",
- "ServiceWorkerVersion::OnPushEventFinished",
- "Request id", request_id);
- PendingRequest<StatusCallback>* request = push_requests_.Lookup(request_id);
- if (!request) {
- NOTREACHED() << "Got unexpected message: " << request_id;
- return;
- }
- ServiceWorkerStatusCode status = SERVICE_WORKER_OK;
- if (result == blink::WebServiceWorkerEventResultRejected)
- status = SERVICE_WORKER_ERROR_EVENT_WAITUNTIL_REJECTED;
-
- ServiceWorkerMetrics::RecordEventDuration(
- request->event_type, base::TimeTicks::Now() - request->start_time);
-
- scoped_refptr<ServiceWorkerVersion> protect(this);
- request->callback.Run(status);
- RemoveCallbackAndStopIfRedundant(&push_requests_, request_id);
-}
-
void ServiceWorkerVersion::OnOpenWindow(int request_id, GURL url) {
// Just abort if we are shutting down.
if (!context_)
@@ -1733,7 +1684,7 @@ void ServiceWorkerVersion::StopWorkerIfIdle() {
bool ServiceWorkerVersion::HasInflightRequests() const {
return !activate_requests_.IsEmpty() || !install_requests_.IsEmpty() ||
!fetch_requests_.IsEmpty() ||
- !notification_click_requests_.IsEmpty() || !push_requests_.IsEmpty() ||
+ !notification_click_requests_.IsEmpty() ||
!custom_requests_.IsEmpty() || !streaming_url_request_jobs_.empty();
}
@@ -1831,9 +1782,6 @@ bool ServiceWorkerVersion::MaybeTimeOutRequest(const RequestInfo& info) {
case REQUEST_NOTIFICATION_CLICK:
return RunIDMapCallback(&notification_click_requests_, info.id,
SERVICE_WORKER_ERROR_TIMEOUT);
- case REQUEST_PUSH:
- return RunIDMapCallback(&push_requests_, info.id,
- SERVICE_WORKER_ERROR_TIMEOUT);
case REQUEST_CUSTOM:
return RunIDMapCallback(&custom_requests_, info.id,
SERVICE_WORKER_ERROR_TIMEOUT);
@@ -1953,7 +1901,6 @@ void ServiceWorkerVersion::OnStoppedInternal(
SERVICE_WORKER_FETCH_EVENT_RESULT_FALLBACK,
ServiceWorkerResponse());
RunIDMapCallbacks(&notification_click_requests_, SERVICE_WORKER_ERROR_FAILED);
- RunIDMapCallbacks(&push_requests_, SERVICE_WORKER_ERROR_FAILED);
RunIDMapCallbacks(&custom_requests_, SERVICE_WORKER_ERROR_FAILED);
// Close all mojo services. This will also fire and clear all callbacks

Powered by Google App Engine
This is Rietveld 408576698