OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 // If we were asked to pause worker context on start and wait for debugger | 146 // If we were asked to pause worker context on start and wait for debugger |
147 // then it is the good time to do that. | 147 // then it is the good time to do that. |
148 client_->WorkerReadyForInspection(); | 148 client_->WorkerReadyForInspection(); |
149 if (pause_worker_context_on_start_) { | 149 if (pause_worker_context_on_start_) { |
150 is_paused_on_start_ = true; | 150 is_paused_on_start_ = true; |
151 return; | 151 return; |
152 } | 152 } |
153 LoadShadowPage(); | 153 LoadShadowPage(); |
154 } | 154 } |
155 | 155 |
156 WebApplicationCacheHost* WebSharedWorkerImpl::CreateApplicationCacheHost( | 156 std::unique_ptr<WebApplicationCacheHost> |
| 157 WebSharedWorkerImpl::CreateApplicationCacheHost( |
157 WebApplicationCacheHostClient* appcache_host_client) { | 158 WebApplicationCacheHostClient* appcache_host_client) { |
158 DCHECK(IsMainThread()); | 159 DCHECK(IsMainThread()); |
159 return client_->CreateApplicationCacheHost(appcache_host_client); | 160 return client_->CreateApplicationCacheHost(appcache_host_client); |
160 } | 161 } |
161 | 162 |
162 void WebSharedWorkerImpl::LoadShadowPage() { | 163 void WebSharedWorkerImpl::LoadShadowPage() { |
163 DCHECK(IsMainThread()); | 164 DCHECK(IsMainThread()); |
164 | 165 |
165 // Construct substitute data source for the 'shadow page'. We only need it | 166 // Construct substitute data source for the 'shadow page'. We only need it |
166 // to have same origin as the worker so the loading checks work correctly. | 167 // to have same origin as the worker so the loading checks work correctly. |
167 CString content(""); | 168 CString content(""); |
168 RefPtr<SharedBuffer> buffer( | 169 RefPtr<SharedBuffer> buffer( |
169 SharedBuffer::Create(content.data(), content.length())); | 170 SharedBuffer::Create(content.data(), content.length())); |
170 main_frame_->GetFrame()->Loader().Load( | 171 main_frame_->GetFrame()->Loader().Load( |
171 FrameLoadRequest(0, ResourceRequest(url_), | 172 FrameLoadRequest(0, ResourceRequest(url_), |
172 SubstituteData(buffer, "text/html", "UTF-8", KURL()))); | 173 SubstituteData(buffer, "text/html", "UTF-8", KURL()))); |
173 } | 174 } |
174 | 175 |
175 void WebSharedWorkerImpl::DidFinishDocumentLoad(WebLocalFrame* frame) { | 176 void WebSharedWorkerImpl::DidFinishDocumentLoad(WebLocalFrame* frame) { |
176 DCHECK_EQ(frame, main_frame_); | 177 DCHECK_EQ(frame, main_frame_); |
177 DCHECK(IsMainThread()); | 178 DCHECK(IsMainThread()); |
178 DCHECK(!loading_document_); | 179 DCHECK(!loading_document_); |
179 DCHECK(!main_script_loader_); | 180 DCHECK(!main_script_loader_); |
180 frame->DataSource()->SetServiceWorkerNetworkProvider( | 181 frame->DataSource()->SetServiceWorkerNetworkProvider( |
181 WTF::WrapUnique(client_->CreateServiceWorkerNetworkProvider())); | 182 client_->CreateServiceWorkerNetworkProvider()); |
182 main_script_loader_ = WorkerScriptLoader::Create(); | 183 main_script_loader_ = WorkerScriptLoader::Create(); |
183 main_script_loader_->SetRequestContext( | 184 main_script_loader_->SetRequestContext( |
184 WebURLRequest::kRequestContextSharedWorker); | 185 WebURLRequest::kRequestContextSharedWorker); |
185 loading_document_ = ToWebLocalFrameImpl(frame)->GetFrame()->GetDocument(); | 186 loading_document_ = ToWebLocalFrameImpl(frame)->GetFrame()->GetDocument(); |
186 | 187 |
187 CrossOriginRequestPolicy cross_origin_request_policy = | 188 CrossOriginRequestPolicy cross_origin_request_policy = |
188 (static_cast<KURL>(url_)).ProtocolIsData() ? kAllowCrossOriginRequests | 189 (static_cast<KURL>(url_)).ProtocolIsData() ? kAllowCrossOriginRequests |
189 : kDenyCrossOriginRequests; | 190 : kDenyCrossOriginRequests; |
190 | 191 |
191 main_script_loader_->LoadAsynchronously( | 192 main_script_loader_->LoadAsynchronously( |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 if (devtools_agent) | 429 if (devtools_agent) |
429 devtools_agent->DispatchOnInspectorBackend(session_id, call_id, method, | 430 devtools_agent->DispatchOnInspectorBackend(session_id, call_id, method, |
430 message); | 431 message); |
431 } | 432 } |
432 | 433 |
433 WebSharedWorker* WebSharedWorker::Create(WebSharedWorkerClient* client) { | 434 WebSharedWorker* WebSharedWorker::Create(WebSharedWorkerClient* client) { |
434 return new WebSharedWorkerImpl(client); | 435 return new WebSharedWorkerImpl(client); |
435 } | 436 } |
436 | 437 |
437 } // namespace blink | 438 } // namespace blink |
OLD | NEW |