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

Unified Diff: content/child/service_worker/service_worker_dispatcher.cc

Issue 2443103002: service worker: Implement NavigationPreloadManager.getState (Closed)
Patch Set: rm file added in bad merge Created 4 years, 2 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/child/service_worker/service_worker_dispatcher.cc
diff --git a/content/child/service_worker/service_worker_dispatcher.cc b/content/child/service_worker/service_worker_dispatcher.cc
index 6ca9fac9f7e9fe5144594f55d03946f2c13f7b47..5619cf46045c7d17f0a92adef083e6c13d2b0388 100644
--- a/content/child/service_worker/service_worker_dispatcher.cc
+++ b/content/child/service_worker/service_worker_dispatcher.cc
@@ -24,6 +24,7 @@
#include "content/common/service_worker/service_worker_types.h"
#include "content/public/common/content_constants.h"
#include "third_party/WebKit/public/platform/WebString.h"
+#include "third_party/WebKit/public/platform/modules/serviceworker/WebNavigationPreloadState.h"
#include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerProviderClient.h"
#include "url/url_constants.h"
@@ -81,6 +82,8 @@ void ServiceWorkerDispatcher::OnMessageReceived(const IPC::Message& msg) {
OnDidGetRegistrationForReady)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidEnableNavigationPreload,
OnDidEnableNavigationPreload)
+ IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidGetNavigationPreloadState,
+ OnDidGetNavigationPreloadState)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerRegistrationError,
OnRegistrationError)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerUpdateError,
@@ -93,6 +96,8 @@ void ServiceWorkerDispatcher::OnMessageReceived(const IPC::Message& msg) {
OnGetRegistrationsError)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_EnableNavigationPreloadError,
OnEnableNavigationPreloadError)
+ IPC_MESSAGE_HANDLER(ServiceWorkerMsg_GetNavigationPreloadStateError,
+ OnGetNavigationPreloadStateError)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerStateChanged,
OnServiceWorkerStateChanged)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_SetVersionAttributes,
@@ -222,6 +227,17 @@ void ServiceWorkerDispatcher::EnableNavigationPreload(
CurrentWorkerId(), request_id, provider_id, registration_id, enable));
}
+void ServiceWorkerDispatcher::GetNavigationPreloadState(
+ int provider_id,
+ int64_t registration_id,
+ std::unique_ptr<WebGetNavigationPreloadStateCallbacks> callbacks) {
+ DCHECK(callbacks);
+ int request_id =
+ get_navigation_preload_state_callbacks_.Add(callbacks.release());
+ thread_safe_sender_->Send(new ServiceWorkerHostMsg_GetNavigationPreloadState(
+ CurrentWorkerId(), request_id, provider_id, registration_id));
+}
+
void ServiceWorkerDispatcher::AddProviderContext(
ServiceWorkerProviderContext* provider_context) {
DCHECK(provider_context);
@@ -547,6 +563,20 @@ void ServiceWorkerDispatcher::OnDidEnableNavigationPreload(int thread_id,
enable_navigation_preload_callbacks_.Remove(request_id);
}
+void ServiceWorkerDispatcher::OnDidGetNavigationPreloadState(int thread_id,
+ int request_id,
+ bool enabled) {
+ WebGetNavigationPreloadStateCallbacks* callbacks =
+ get_navigation_preload_state_callbacks_.Lookup(request_id);
+ DCHECK(callbacks);
+ if (!callbacks)
+ return;
+ // TODO(falken): Implement populating headerValue.
+ callbacks->onSuccess(
+ blink::WebNavigationPreloadState(enabled, blink::WebString()));
+ get_navigation_preload_state_callbacks_.Remove(request_id);
+}
+
void ServiceWorkerDispatcher::OnRegistrationError(
int thread_id,
int request_id,
@@ -674,6 +704,21 @@ void ServiceWorkerDispatcher::OnEnableNavigationPreloadError(
enable_navigation_preload_callbacks_.Remove(request_id);
}
+void ServiceWorkerDispatcher::OnGetNavigationPreloadStateError(
+ int thread_id,
+ int request_id,
+ WebServiceWorkerError::ErrorType error_type,
+ const std::string& message) {
+ WebGetNavigationPreloadStateCallbacks* callbacks =
+ get_navigation_preload_state_callbacks_.Lookup(request_id);
+ DCHECK(callbacks);
+ if (!callbacks)
+ return;
+ callbacks->onError(
+ WebServiceWorkerError(error_type, blink::WebString::fromUTF8(message)));
+ get_navigation_preload_state_callbacks_.Remove(request_id);
+}
+
void ServiceWorkerDispatcher::OnServiceWorkerStateChanged(
int thread_id,
int handle_id,

Powered by Google App Engine
This is Rietveld 408576698