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

Side by Side Diff: third_party/WebKit/Source/web/WebSharedWorkerImpl.cpp

Issue 2881073003: Support DataSaver for SharedWorker (Closed)
Patch Set: fix #include "public/web/WebDataSaverFlag.h" Created 3 years, 7 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 unified diff | Download patch
OLDNEW
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
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(WebDataSaverFlag data_saver_flag) {
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()->SetDataSaverFlag(data_saver_flag);
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
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 WebDataSaverFlag data_saver_flag) {
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_flag);
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 30 matching lines...) Expand all
340 342
341 if (RuntimeEnabledFeatures::offMainThreadFetchEnabled()) { 343 if (RuntimeEnabledFeatures::offMainThreadFetchEnabled()) {
342 std::unique_ptr<WebWorkerFetchContext> web_worker_fetch_context = 344 std::unique_ptr<WebWorkerFetchContext> web_worker_fetch_context =
343 client_->CreateWorkerFetchContext( 345 client_->CreateWorkerFetchContext(
344 WebLocalFrameBase::FromFrame(main_frame_->GetFrame()) 346 WebLocalFrameBase::FromFrame(main_frame_->GetFrame())
345 ->DataSource() 347 ->DataSource()
346 ->GetServiceWorkerNetworkProvider()); 348 ->GetServiceWorkerNetworkProvider());
347 DCHECK(web_worker_fetch_context); 349 DCHECK(web_worker_fetch_context);
348 // TODO(horo): Set more information about the context (ex: AppCacheHostID) 350 // TODO(horo): Set more information about the context (ex: AppCacheHostID)
349 // to |web_worker_fetch_context|. 351 // to |web_worker_fetch_context|.
350 web_worker_fetch_context->SetDataSaverEnabled( 352 web_worker_fetch_context->SetDataSaverFlag(
351 document->GetFrame()->GetSettings()->GetDataSaverEnabled()); 353 document->GetFrame()->GetSettings()->GetDataSaverFlag());
352 ProvideWorkerFetchContextToWorker(worker_clients, 354 ProvideWorkerFetchContextToWorker(worker_clients,
353 std::move(web_worker_fetch_context)); 355 std::move(web_worker_fetch_context));
354 } 356 }
355 357
356 ContentSecurityPolicy* content_security_policy = 358 ContentSecurityPolicy* content_security_policy =
357 main_script_loader_->ReleaseContentSecurityPolicy(); 359 main_script_loader_->ReleaseContentSecurityPolicy();
358 WorkerThreadStartMode start_mode = 360 WorkerThreadStartMode start_mode =
359 worker_inspector_proxy_->WorkerStartMode(document); 361 worker_inspector_proxy_->WorkerStartMode(document);
360 std::unique_ptr<WorkerSettings> worker_settings = 362 std::unique_ptr<WorkerSettings> worker_settings =
361 WTF::WrapUnique(new WorkerSettings(document->GetSettings())); 363 WTF::WrapUnique(new WorkerSettings(document->GetSettings()));
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698