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

Unified Diff: content/renderer/service_worker/service_worker_context_client.cc

Issue 1202453002: ServiceWorker: Implement navigate() method in WindowClient (chromium side). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « content/renderer/service_worker/service_worker_context_client.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/service_worker/service_worker_context_client.cc
diff --git a/content/renderer/service_worker/service_worker_context_client.cc b/content/renderer/service_worker/service_worker_context_client.cc
index 7b43099c3c990b04ae97ce4beaf2cd112f4e2362..a8c5b8ad2cfce04506a122e567183519ebb9c62e 100644
--- a/content/renderer/service_worker/service_worker_context_client.cc
+++ b/content/renderer/service_worker/service_worker_context_client.cc
@@ -258,6 +258,10 @@ void ServiceWorkerContextClient::OnMessageReceived(
OnOpenWindowError)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_FocusClientResponse,
OnFocusClientResponse)
+ IPC_MESSAGE_HANDLER(ServiceWorkerMsg_NavigateClientResponse,
+ OnNavigateClientResponse)
+ IPC_MESSAGE_HANDLER(ServiceWorkerMsg_NavigateClientError,
+ OnNavigateClientError)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidSkipWaiting, OnDidSkipWaiting)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidClaimClients, OnDidClaimClients)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ClaimClientsError, OnClaimClientsError)
@@ -587,6 +591,17 @@ void ServiceWorkerContextClient::focus(
base::UTF16ToUTF8(base::StringPiece16(uuid))));
}
+void ServiceWorkerContextClient::navigate(
+ const blink::WebString& uuid,
+ const blink::WebURL& url,
+ blink::WebServiceWorkerClientCallbacks* callback) {
+ DCHECK(callback);
+ int request_id = context_->client_callbacks.Add(callback);
+ Send(new ServiceWorkerHostMsg_NavigateClient(
+ GetRoutingID(), request_id, base::UTF16ToUTF8(base::StringPiece16(uuid)),
+ url));
+}
+
void ServiceWorkerContextClient::skipWaiting(
blink::WebServiceWorkerSkipWaitingCallbacks* callbacks) {
DCHECK(callbacks);
@@ -854,6 +869,46 @@ void ServiceWorkerContextClient::OnFocusClientResponse(
context_->client_callbacks.Remove(request_id);
}
+void ServiceWorkerContextClient::OnNavigateClientResponse(
+ int request_id,
+ const ServiceWorkerClientInfo& client) {
+ TRACE_EVENT0("ServiceWorker",
+ "ServiceWorkerContextClient::OnNavigateClientResponse");
+ blink::WebServiceWorkerClientCallbacks* callbacks =
+ context_->client_callbacks.Lookup(request_id);
+ if (!callbacks) {
+ NOTREACHED() << "Got stray response: " << request_id;
+ return;
+ }
+ scoped_ptr<blink::WebServiceWorkerClientInfo> web_client;
+ if (!client.IsEmpty()) {
+ DCHECK(client.IsValid());
+ web_client.reset(new blink::WebServiceWorkerClientInfo(
+ ToWebServiceWorkerClientInfo(client)));
+ }
+ callbacks->onSuccess(web_client.release());
+ context_->client_callbacks.Remove(request_id);
+}
+
+void ServiceWorkerContextClient::OnNavigateClientError(int request_id,
+ const GURL& url) {
+ TRACE_EVENT0("ServiceWorker",
+ "ServiceWorkerContextClient::OnNavigateClientError");
+ blink::WebServiceWorkerClientCallbacks* callbacks =
+ context_->client_callbacks.Lookup(request_id);
+ if (!callbacks) {
+ NOTREACHED() << "Got stray response: " << request_id;
+ return;
+ }
+ std::string message = "Cannot navigate to URL: " + url.spec();
+ scoped_ptr<blink::WebServiceWorkerError> error(
+ new blink::WebServiceWorkerError(
+ blink::WebServiceWorkerError::ErrorTypeUnknown,
+ blink::WebString::fromUTF8(message)));
+ callbacks->onError(error.release());
+ context_->client_callbacks.Remove(request_id);
+}
+
void ServiceWorkerContextClient::OnDidSkipWaiting(int request_id) {
TRACE_EVENT0("ServiceWorker",
"ServiceWorkerContextClient::OnDidSkipWaiting");
« no previous file with comments | « content/renderer/service_worker/service_worker_context_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698