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

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

Issue 2388023002: service worker: navigation preload basic setters/getters and flag
Patch Set: idl 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 984468a725342878cf099057958ac33bfaa193ad..493d74b175075e1639fa40b41820452d572f16fb 100644
--- a/content/child/service_worker/service_worker_dispatcher.cc
+++ b/content/child/service_worker/service_worker_dispatcher.cc
@@ -79,6 +79,10 @@ void ServiceWorkerDispatcher::OnMessageReceived(const IPC::Message& msg) {
OnDidGetRegistrations)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidGetRegistrationForReady,
OnDidGetRegistrationForReady)
+ IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidSetNavigationPreload,
+ OnDidSetNavigationPreload)
+ IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidGetNavigationPreload,
+ OnDidGetNavigationPreload)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerRegistrationError,
OnRegistrationError)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerUpdateError,
@@ -206,6 +210,25 @@ void ServiceWorkerDispatcher::GetRegistrationForReady(
CurrentWorkerId(), request_id, provider_id));
}
+void ServiceWorkerDispatcher::SetNavigationPreload(
+ int handle_id,
+ const std::string& value,
+ blink::WebServiceWorker::WebSetNavigationPreloadCallbacks* callback) {
+ LOG(ERROR) << "ServiceWorkerDispatcher::SetNavigationPreload value=" << value;
+ int request_id = pending_set_navigation_preload_callbacks_.Add(callback);
+ thread_safe_sender_->Send(new ServiceWorkerHostMsg_SetNavigationPreload(
+ CurrentWorkerId(), request_id, handle_id, value));
+}
+
+void ServiceWorkerDispatcher::GetNavigationPreload(
+ int handle_id,
+ blink::WebServiceWorker::WebGetNavigationPreloadCallbacks* callback) {
+ LOG(ERROR) << "ServiceWorkerDispatcher::GetNavigationPreload";
+ int request_id = pending_get_navigation_preload_callbacks_.Add(callback);
+ thread_safe_sender_->Send(new ServiceWorkerHostMsg_GetNavigationPreload(
+ CurrentWorkerId(), request_id, handle_id));
+}
+
void ServiceWorkerDispatcher::AddProviderContext(
ServiceWorkerProviderContext* provider_context) {
DCHECK(provider_context);
@@ -520,6 +543,39 @@ void ServiceWorkerDispatcher::OnDidGetRegistrationForReady(
get_for_ready_callbacks_.Remove(request_id);
}
+void ServiceWorkerDispatcher::OnDidGetNavigationPreload(
+ int thread_id,
+ int request_id,
+ bool is_enabled,
+ const std::string& value) {
+ LOG(ERROR) << "SWDispatcher::OnDidGetNavigationPreload: enabled="
+ << is_enabled << ", value=" << value;
+ WebGetNavigationPreloadCallbacks* callbacks =
+ pending_get_navigation_preload_callbacks_.Lookup(request_id);
+ DCHECK(callbacks);
+ if (!callbacks)
+ return;
+
+ if (is_enabled)
+ callbacks->onSuccess(blink::WebString::fromUTF8(value));
+ else
+ callbacks->onSuccess(blink::WebString());
+ pending_get_navigation_preload_callbacks_.Remove(request_id);
+}
+
+void ServiceWorkerDispatcher::OnDidSetNavigationPreload(int thread_id,
+ int request_id) {
+ LOG(ERROR) << "SWDispatcher::OnDidSetNavigationPreload";
+ WebSetNavigationPreloadCallbacks* callbacks =
+ pending_set_navigation_preload_callbacks_.Lookup(request_id);
+ DCHECK(callbacks);
+ if (!callbacks)
+ return;
+
+ callbacks->onSuccess();
+ pending_set_navigation_preload_callbacks_.Remove(request_id);
+}
+
void ServiceWorkerDispatcher::OnRegistrationError(
int thread_id,
int request_id,
« no previous file with comments | « content/child/service_worker/service_worker_dispatcher.h ('k') | content/child/service_worker/web_service_worker_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698