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

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

Issue 2451373003: service worker: Implement NavigationPreloadManager.setHeaderValue (Closed)
Patch Set: rebase Created 4 years, 1 month 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 5619cf46045c7d17f0a92adef083e6c13d2b0388..4e18acab56905da319d2e70acf02de5f1772c540 100644
--- a/content/child/service_worker/service_worker_dispatcher.cc
+++ b/content/child/service_worker/service_worker_dispatcher.cc
@@ -84,6 +84,8 @@ void ServiceWorkerDispatcher::OnMessageReceived(const IPC::Message& msg) {
OnDidEnableNavigationPreload)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidGetNavigationPreloadState,
OnDidGetNavigationPreloadState)
+ IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidSetNavigationPreloadHeader,
+ OnDidSetNavigationPreloadHeader)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerRegistrationError,
OnRegistrationError)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerUpdateError,
@@ -98,6 +100,8 @@ void ServiceWorkerDispatcher::OnMessageReceived(const IPC::Message& msg) {
OnEnableNavigationPreloadError)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_GetNavigationPreloadStateError,
OnGetNavigationPreloadStateError)
+ IPC_MESSAGE_HANDLER(ServiceWorkerMsg_SetNavigationPreloadHeaderError,
+ OnSetNavigationPreloadHeaderError)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerStateChanged,
OnServiceWorkerStateChanged)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_SetVersionAttributes,
@@ -238,6 +242,18 @@ void ServiceWorkerDispatcher::GetNavigationPreloadState(
CurrentWorkerId(), request_id, provider_id, registration_id));
}
+void ServiceWorkerDispatcher::SetNavigationPreloadHeader(
+ int provider_id,
+ int64_t registration_id,
+ const std::string& value,
+ std::unique_ptr<WebSetNavigationPreloadHeaderCallbacks> callbacks) {
+ DCHECK(callbacks);
+ int request_id =
+ set_navigation_preload_header_callbacks_.Add(callbacks.release());
+ thread_safe_sender_->Send(new ServiceWorkerHostMsg_SetNavigationPreloadHeader(
+ CurrentWorkerId(), request_id, provider_id, registration_id, value));
+}
+
void ServiceWorkerDispatcher::AddProviderContext(
ServiceWorkerProviderContext* provider_context) {
DCHECK(provider_context);
@@ -563,20 +579,31 @@ void ServiceWorkerDispatcher::OnDidEnableNavigationPreload(int thread_id,
enable_navigation_preload_callbacks_.Remove(request_id);
}
-void ServiceWorkerDispatcher::OnDidGetNavigationPreloadState(int thread_id,
- int request_id,
- bool enabled) {
+void ServiceWorkerDispatcher::OnDidGetNavigationPreloadState(
+ int thread_id,
+ int request_id,
+ const NavigationPreloadState& state) {
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()));
+ callbacks->onSuccess(blink::WebNavigationPreloadState(
+ state.enabled, blink::WebString::fromUTF8(state.header)));
get_navigation_preload_state_callbacks_.Remove(request_id);
}
+void ServiceWorkerDispatcher::OnDidSetNavigationPreloadHeader(int thread_id,
+ int request_id) {
+ WebSetNavigationPreloadHeaderCallbacks* callbacks =
+ set_navigation_preload_header_callbacks_.Lookup(request_id);
+ DCHECK(callbacks);
+ if (!callbacks)
+ return;
+ callbacks->onSuccess();
+ set_navigation_preload_header_callbacks_.Remove(request_id);
+}
+
void ServiceWorkerDispatcher::OnRegistrationError(
int thread_id,
int request_id,
@@ -719,6 +746,21 @@ void ServiceWorkerDispatcher::OnGetNavigationPreloadStateError(
get_navigation_preload_state_callbacks_.Remove(request_id);
}
+void ServiceWorkerDispatcher::OnSetNavigationPreloadHeaderError(
+ int thread_id,
+ int request_id,
+ WebServiceWorkerError::ErrorType error_type,
+ const std::string& message) {
+ WebSetNavigationPreloadHeaderCallbacks* callbacks =
+ set_navigation_preload_header_callbacks_.Lookup(request_id);
+ DCHECK(callbacks);
+ if (!callbacks)
+ return;
+ callbacks->onError(
+ WebServiceWorkerError(error_type, blink::WebString::fromUTF8(message)));
+ set_navigation_preload_header_callbacks_.Remove(request_id);
+}
+
void ServiceWorkerDispatcher::OnServiceWorkerStateChanged(
int thread_id,
int handle_id,

Powered by Google App Engine
This is Rietveld 408576698