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

Side by Side Diff: content/renderer/service_worker/service_worker_context_client.cc

Issue 1481523006: ServiceWorker: Should throw TypeError instead of Unknown/SecurityError. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/serviceworker/windowclient-navigate.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/service_worker/service_worker_context_client.h" 5 #include "content/renderer/service_worker/service_worker_context_client.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 const std::string& message) { 859 const std::string& message) {
860 TRACE_EVENT0("ServiceWorker", 860 TRACE_EVENT0("ServiceWorker",
861 "ServiceWorkerContextClient::OnOpenWindowError"); 861 "ServiceWorkerContextClient::OnOpenWindowError");
862 blink::WebServiceWorkerClientCallbacks* callbacks = 862 blink::WebServiceWorkerClientCallbacks* callbacks =
863 context_->client_callbacks.Lookup(request_id); 863 context_->client_callbacks.Lookup(request_id);
864 if (!callbacks) { 864 if (!callbacks) {
865 NOTREACHED() << "Got stray response: " << request_id; 865 NOTREACHED() << "Got stray response: " << request_id;
866 return; 866 return;
867 } 867 }
868 callbacks->onError(blink::WebServiceWorkerError( 868 callbacks->onError(blink::WebServiceWorkerError(
869 blink::WebServiceWorkerError::ErrorTypeUnknown, 869 blink::WebServiceWorkerError::ErrorTypeNavigation,
870 blink::WebString::fromUTF8(message))); 870 blink::WebString::fromUTF8(message)));
871 context_->client_callbacks.Remove(request_id); 871 context_->client_callbacks.Remove(request_id);
872 } 872 }
873 873
874 void ServiceWorkerContextClient::OnFocusClientResponse( 874 void ServiceWorkerContextClient::OnFocusClientResponse(
875 int request_id, const ServiceWorkerClientInfo& client) { 875 int request_id, const ServiceWorkerClientInfo& client) {
876 TRACE_EVENT0("ServiceWorker", 876 TRACE_EVENT0("ServiceWorker",
877 "ServiceWorkerContextClient::OnFocusClientResponse"); 877 "ServiceWorkerContextClient::OnFocusClientResponse");
878 blink::WebServiceWorkerClientCallbacks* callback = 878 blink::WebServiceWorkerClientCallbacks* callback =
879 context_->client_callbacks.Lookup(request_id); 879 context_->client_callbacks.Lookup(request_id);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 TRACE_EVENT0("ServiceWorker", 922 TRACE_EVENT0("ServiceWorker",
923 "ServiceWorkerContextClient::OnNavigateClientError"); 923 "ServiceWorkerContextClient::OnNavigateClientError");
924 blink::WebServiceWorkerClientCallbacks* callbacks = 924 blink::WebServiceWorkerClientCallbacks* callbacks =
925 context_->client_callbacks.Lookup(request_id); 925 context_->client_callbacks.Lookup(request_id);
926 if (!callbacks) { 926 if (!callbacks) {
927 NOTREACHED() << "Got stray response: " << request_id; 927 NOTREACHED() << "Got stray response: " << request_id;
928 return; 928 return;
929 } 929 }
930 std::string message = "Cannot navigate to URL: " + url.spec(); 930 std::string message = "Cannot navigate to URL: " + url.spec();
931 callbacks->onError(blink::WebServiceWorkerError( 931 callbacks->onError(blink::WebServiceWorkerError(
932 blink::WebServiceWorkerError::ErrorTypeUnknown, 932 blink::WebServiceWorkerError::ErrorTypeNavigation,
933 blink::WebString::fromUTF8(message))); 933 blink::WebString::fromUTF8(message)));
934 context_->client_callbacks.Remove(request_id); 934 context_->client_callbacks.Remove(request_id);
935 } 935 }
936 936
937 void ServiceWorkerContextClient::OnDidSkipWaiting(int request_id) { 937 void ServiceWorkerContextClient::OnDidSkipWaiting(int request_id) {
938 TRACE_EVENT0("ServiceWorker", 938 TRACE_EVENT0("ServiceWorker",
939 "ServiceWorkerContextClient::OnDidSkipWaiting"); 939 "ServiceWorkerContextClient::OnDidSkipWaiting");
940 blink::WebServiceWorkerSkipWaitingCallbacks* callbacks = 940 blink::WebServiceWorkerSkipWaitingCallbacks* callbacks =
941 context_->skip_waiting_callbacks.Lookup(request_id); 941 context_->skip_waiting_callbacks.Lookup(request_id);
942 if (!callbacks) { 942 if (!callbacks) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 } 981 }
982 982
983 base::WeakPtr<ServiceWorkerContextClient> 983 base::WeakPtr<ServiceWorkerContextClient>
984 ServiceWorkerContextClient::GetWeakPtr() { 984 ServiceWorkerContextClient::GetWeakPtr() {
985 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); 985 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread());
986 DCHECK(context_); 986 DCHECK(context_);
987 return context_->weak_factory.GetWeakPtr(); 987 return context_->weak_factory.GetWeakPtr();
988 } 988 }
989 989
990 } // namespace content 990 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/serviceworker/windowclient-navigate.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698