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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 main_script_loader_.Clear(); | 116 main_script_loader_.Clear(); |
117 client_->WorkerScriptLoadFailed(); | 117 client_->WorkerScriptLoadFailed(); |
118 delete this; | 118 delete this; |
119 return; | 119 return; |
120 } | 120 } |
121 if (worker_thread_) | 121 if (worker_thread_) |
122 worker_thread_->Terminate(); | 122 worker_thread_->Terminate(); |
123 worker_inspector_proxy_->WorkerThreadTerminated(); | 123 worker_inspector_proxy_->WorkerThreadTerminated(); |
124 } | 124 } |
125 | 125 |
126 void WebSharedWorkerImpl::InitializeLoader() { | 126 void WebSharedWorkerImpl::InitializeLoader(bool data_saver_enabled) { |
127 DCHECK(IsMainThread()); | 127 DCHECK(IsMainThread()); |
128 | 128 |
129 // Create 'shadow page'. This page is never displayed, it is used to proxy the | 129 // Create 'shadow page'. This page is never displayed, it is used to proxy the |
130 // loading requests from the worker context to the rest of WebKit and Chromium | 130 // loading requests from the worker context to the rest of WebKit and Chromium |
131 // infrastructure. | 131 // infrastructure. |
132 DCHECK(!web_view_); | 132 DCHECK(!web_view_); |
133 web_view_ = WebView::Create(nullptr, kWebPageVisibilityStateVisible); | 133 web_view_ = WebView::Create(nullptr, kWebPageVisibilityStateVisible); |
134 // FIXME: http://crbug.com/363843. This needs to find a better way to | 134 // FIXME: http://crbug.com/363843. This needs to find a better way to |
135 // not create graphics layers. | 135 // not create graphics layers. |
136 web_view_->GetSettings()->SetAcceleratedCompositingEnabled(false); | 136 web_view_->GetSettings()->SetAcceleratedCompositingEnabled(false); |
| 137 web_view_->GetSettings()->SetDataSaverEnabled(data_saver_enabled); |
137 // FIXME: Settings information should be passed to the Worker process from | 138 // FIXME: Settings information should be passed to the Worker process from |
138 // Browser process when the worker is created (similar to | 139 // Browser process when the worker is created (similar to |
139 // RenderThread::OnCreateNewView). | 140 // RenderThread::OnCreateNewView). |
140 main_frame_ = ToWebLocalFrameBase(WebLocalFrame::Create( | 141 main_frame_ = ToWebLocalFrameBase(WebLocalFrame::Create( |
141 WebTreeScopeType::kDocument, this, | 142 WebTreeScopeType::kDocument, this, |
142 Platform::Current()->GetInterfaceProvider(), nullptr)); | 143 Platform::Current()->GetInterfaceProvider(), nullptr)); |
143 web_view_->SetMainFrame(main_frame_.Get()); | 144 web_view_->SetMainFrame(main_frame_.Get()); |
144 main_frame_->SetDevToolsAgentClient(this); | 145 main_frame_->SetDevToolsAgentClient(this); |
145 | 146 |
146 // If we were asked to pause worker context on start and wait for debugger | 147 // If we were asked to pause worker context on start and wait for debugger |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 port->Entangle(std::move(channel)); | 285 port->Entangle(std::move(channel)); |
285 SECURITY_DCHECK(worker_global_scope->IsSharedWorkerGlobalScope()); | 286 SECURITY_DCHECK(worker_global_scope->IsSharedWorkerGlobalScope()); |
286 worker_global_scope->DispatchEvent(CreateConnectEvent(port)); | 287 worker_global_scope->DispatchEvent(CreateConnectEvent(port)); |
287 } | 288 } |
288 | 289 |
289 void WebSharedWorkerImpl::StartWorkerContext( | 290 void WebSharedWorkerImpl::StartWorkerContext( |
290 const WebURL& url, | 291 const WebURL& url, |
291 const WebString& name, | 292 const WebString& name, |
292 const WebString& content_security_policy, | 293 const WebString& content_security_policy, |
293 WebContentSecurityPolicyType policy_type, | 294 WebContentSecurityPolicyType policy_type, |
294 WebAddressSpace creation_address_space) { | 295 WebAddressSpace creation_address_space, |
| 296 bool data_saver_enabled) { |
295 DCHECK(IsMainThread()); | 297 DCHECK(IsMainThread()); |
296 url_ = url; | 298 url_ = url; |
297 name_ = name; | 299 name_ = name; |
298 creation_address_space_ = creation_address_space; | 300 creation_address_space_ = creation_address_space; |
299 InitializeLoader(); | 301 InitializeLoader(data_saver_enabled); |
300 } | 302 } |
301 | 303 |
302 void WebSharedWorkerImpl::DidReceiveScriptLoaderResponse() { | 304 void WebSharedWorkerImpl::DidReceiveScriptLoaderResponse() { |
303 DCHECK(IsMainThread()); | 305 DCHECK(IsMainThread()); |
304 probe::didReceiveScriptResponse(loading_document_, | 306 probe::didReceiveScriptResponse(loading_document_, |
305 main_script_loader_->Identifier()); | 307 main_script_loader_->Identifier()); |
306 client_->SelectAppCacheID(main_script_loader_->AppCacheID()); | 308 client_->SelectAppCacheID(main_script_loader_->AppCacheID()); |
307 } | 309 } |
308 | 310 |
309 void WebSharedWorkerImpl::OnScriptLoaderFinished() { | 311 void WebSharedWorkerImpl::OnScriptLoaderFinished() { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 if (devtools_agent) | 439 if (devtools_agent) |
438 devtools_agent->DispatchOnInspectorBackend(session_id, call_id, method, | 440 devtools_agent->DispatchOnInspectorBackend(session_id, call_id, method, |
439 message); | 441 message); |
440 } | 442 } |
441 | 443 |
442 WebSharedWorker* WebSharedWorker::Create(WebSharedWorkerClient* client) { | 444 WebSharedWorker* WebSharedWorker::Create(WebSharedWorkerClient* client) { |
443 return new WebSharedWorkerImpl(client); | 445 return new WebSharedWorkerImpl(client); |
444 } | 446 } |
445 | 447 |
446 } // namespace blink | 448 } // namespace blink |
OLD | NEW |