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

Side by Side Diff: content/child/service_worker/service_worker_dispatcher.cc

Issue 1497743005: Allow huge data: URIs only via WebView.loadDataWithBaseUrl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sort out the tests 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/child/service_worker/service_worker_dispatcher.h" 5 #include "content/child/service_worker/service_worker_dispatcher.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/single_thread_task_runner.h" 8 #include "base/single_thread_task_runner.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
11 #include "base/threading/thread_local.h" 11 #include "base/threading/thread_local.h"
12 #include "base/trace_event/trace_event.h" 12 #include "base/trace_event/trace_event.h"
13 #include "content/child/service_worker/service_worker_handle_reference.h" 13 #include "content/child/service_worker/service_worker_handle_reference.h"
14 #include "content/child/service_worker/service_worker_provider_context.h" 14 #include "content/child/service_worker/service_worker_provider_context.h"
15 #include "content/child/service_worker/service_worker_registration_handle_refere nce.h" 15 #include "content/child/service_worker/service_worker_registration_handle_refere nce.h"
16 #include "content/child/service_worker/web_service_worker_impl.h" 16 #include "content/child/service_worker/web_service_worker_impl.h"
17 #include "content/child/service_worker/web_service_worker_registration_impl.h" 17 #include "content/child/service_worker/web_service_worker_registration_impl.h"
18 #include "content/child/thread_safe_sender.h" 18 #include "content/child/thread_safe_sender.h"
19 #include "content/child/webmessageportchannel_impl.h" 19 #include "content/child/webmessageportchannel_impl.h"
20 #include "content/common/service_worker/service_worker_messages.h" 20 #include "content/common/service_worker/service_worker_messages.h"
21 #include "content/common/service_worker/service_worker_types.h" 21 #include "content/common/service_worker/service_worker_types.h"
22 #include "content/public/common/url_utils.h" 22 #include "content/public/common/content_constants.h"
23 #include "third_party/WebKit/public/platform/WebString.h" 23 #include "third_party/WebKit/public/platform/WebString.h"
24 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor kerProviderClient.h" 24 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor kerProviderClient.h"
25 25
26 using blink::WebServiceWorkerError; 26 using blink::WebServiceWorkerError;
27 using blink::WebServiceWorkerProvider; 27 using blink::WebServiceWorkerProvider;
28 using base::ThreadLocalPointer; 28 using base::ThreadLocalPointer;
29 29
30 namespace content { 30 namespace content {
31 31
32 namespace { 32 namespace {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 return thread_safe_sender_->Send(msg); 100 return thread_safe_sender_->Send(msg);
101 } 101 }
102 102
103 void ServiceWorkerDispatcher::RegisterServiceWorker( 103 void ServiceWorkerDispatcher::RegisterServiceWorker(
104 int provider_id, 104 int provider_id,
105 const GURL& pattern, 105 const GURL& pattern,
106 const GURL& script_url, 106 const GURL& script_url,
107 WebServiceWorkerRegistrationCallbacks* callbacks) { 107 WebServiceWorkerRegistrationCallbacks* callbacks) {
108 DCHECK(callbacks); 108 DCHECK(callbacks);
109 109
110 if (pattern.possibly_invalid_spec().size() > GetMaxURLChars() || 110 if (pattern.possibly_invalid_spec().size() > kMaxURLChars ||
111 script_url.possibly_invalid_spec().size() > GetMaxURLChars()) { 111 script_url.possibly_invalid_spec().size() > kMaxURLChars) {
112 scoped_ptr<WebServiceWorkerRegistrationCallbacks> 112 scoped_ptr<WebServiceWorkerRegistrationCallbacks>
113 owned_callbacks(callbacks); 113 owned_callbacks(callbacks);
114 std::string error_message(kServiceWorkerRegisterErrorPrefix); 114 std::string error_message(kServiceWorkerRegisterErrorPrefix);
115 error_message += "The provided scriptURL or scope is too long."; 115 error_message += "The provided scriptURL or scope is too long.";
116 callbacks->onError( 116 callbacks->onError(
117 WebServiceWorkerError(WebServiceWorkerError::ErrorTypeSecurity, 117 WebServiceWorkerError(WebServiceWorkerError::ErrorTypeSecurity,
118 blink::WebString::fromUTF8(error_message))); 118 blink::WebString::fromUTF8(error_message)));
119 return; 119 return;
120 } 120 }
121 121
(...skipping 29 matching lines...) Expand all
151 thread_safe_sender_->Send(new ServiceWorkerHostMsg_UnregisterServiceWorker( 151 thread_safe_sender_->Send(new ServiceWorkerHostMsg_UnregisterServiceWorker(
152 CurrentWorkerId(), request_id, provider_id, registration_id)); 152 CurrentWorkerId(), request_id, provider_id, registration_id));
153 } 153 }
154 154
155 void ServiceWorkerDispatcher::GetRegistration( 155 void ServiceWorkerDispatcher::GetRegistration(
156 int provider_id, 156 int provider_id,
157 const GURL& document_url, 157 const GURL& document_url,
158 WebServiceWorkerGetRegistrationCallbacks* callbacks) { 158 WebServiceWorkerGetRegistrationCallbacks* callbacks) {
159 DCHECK(callbacks); 159 DCHECK(callbacks);
160 160
161 if (document_url.possibly_invalid_spec().size() > GetMaxURLChars()) { 161 if (document_url.possibly_invalid_spec().size() > kMaxURLChars) {
162 scoped_ptr<WebServiceWorkerGetRegistrationCallbacks> owned_callbacks( 162 scoped_ptr<WebServiceWorkerGetRegistrationCallbacks> owned_callbacks(
163 callbacks); 163 callbacks);
164 std::string error_message(kServiceWorkerGetRegistrationErrorPrefix); 164 std::string error_message(kServiceWorkerGetRegistrationErrorPrefix);
165 error_message += "The provided documentURL is too long."; 165 error_message += "The provided documentURL is too long.";
166 callbacks->onError( 166 callbacks->onError(
167 WebServiceWorkerError(WebServiceWorkerError::ErrorTypeSecurity, 167 WebServiceWorkerError(WebServiceWorkerError::ErrorTypeSecurity,
168 blink::WebString::fromUTF8(error_message))); 168 blink::WebString::fromUTF8(error_message)));
169 return; 169 return;
170 } 170 }
171 171
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 return ServiceWorkerRegistrationHandleReference::Adopt( 762 return ServiceWorkerRegistrationHandleReference::Adopt(
763 info, thread_safe_sender_.get()); 763 info, thread_safe_sender_.get());
764 } 764 }
765 765
766 scoped_ptr<ServiceWorkerHandleReference> ServiceWorkerDispatcher::Adopt( 766 scoped_ptr<ServiceWorkerHandleReference> ServiceWorkerDispatcher::Adopt(
767 const ServiceWorkerObjectInfo& info) { 767 const ServiceWorkerObjectInfo& info) {
768 return ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_.get()); 768 return ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_.get());
769 } 769 }
770 770
771 } // namespace content 771 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698