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

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

Issue 2878933003: Makes WorkerInspectorProxy work with ExecutionContext instead of Document (Closed)
Patch Set: . 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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 if (main_script_loader_->Failed()) { 315 if (main_script_loader_->Failed()) {
316 main_script_loader_->Cancel(); 316 main_script_loader_->Cancel();
317 client_->WorkerScriptLoadFailed(); 317 client_->WorkerScriptLoadFailed();
318 318
319 // The SharedWorker was unable to load the initial script, so 319 // The SharedWorker was unable to load the initial script, so
320 // shut it down right here. 320 // shut it down right here.
321 delete this; 321 delete this;
322 return; 322 return;
323 } 323 }
324 324
325 Document* document = main_frame_->GetFrame()->GetDocument(); 325 // FIXME: this document's origin is pristine and without any extra privileges
326 // FIXME: this document's origin is pristine and without any extra privileges. 326 // (e.g. GrantUniversalAccess) that can be overriden in regular documents
327 // (crbug.com/254993) 327 // via WebPreference by embedders. (crbug.com/254993)
328 SecurityOrigin* starter_origin = document->GetSecurityOrigin(); 328 SecurityOrigin* starter_origin = loading_document_->GetSecurityOrigin();
329 329
330 WorkerClients* worker_clients = WorkerClients::Create(); 330 WorkerClients* worker_clients = WorkerClients::Create();
331 ProvideLocalFileSystemToWorker(worker_clients, 331 ProvideLocalFileSystemToWorker(worker_clients,
332 LocalFileSystemClient::Create()); 332 LocalFileSystemClient::Create());
333 WebSecurityOrigin web_security_origin(loading_document_->GetSecurityOrigin()); 333 WebSecurityOrigin web_security_origin(loading_document_->GetSecurityOrigin());
334 ProvideContentSettingsClientToWorker( 334 ProvideContentSettingsClientToWorker(
335 worker_clients, 335 worker_clients,
336 WTF::WrapUnique(client_->CreateWorkerContentSettingsClientProxy( 336 WTF::WrapUnique(client_->CreateWorkerContentSettingsClientProxy(
337 web_security_origin))); 337 web_security_origin)));
338 ProvideIndexedDBClientToWorker(worker_clients, 338 ProvideIndexedDBClientToWorker(worker_clients,
339 IndexedDBClientImpl::Create(*worker_clients)); 339 IndexedDBClientImpl::Create(*worker_clients));
340 340
341 if (RuntimeEnabledFeatures::offMainThreadFetchEnabled()) { 341 if (RuntimeEnabledFeatures::offMainThreadFetchEnabled()) {
342 std::unique_ptr<WebWorkerFetchContext> web_worker_fetch_context = 342 std::unique_ptr<WebWorkerFetchContext> web_worker_fetch_context =
343 client_->CreateWorkerFetchContext( 343 client_->CreateWorkerFetchContext(
344 WebLocalFrameBase::FromFrame(main_frame_->GetFrame()) 344 WebLocalFrameBase::FromFrame(main_frame_->GetFrame())
345 ->DataSource() 345 ->DataSource()
346 ->GetServiceWorkerNetworkProvider()); 346 ->GetServiceWorkerNetworkProvider());
347 DCHECK(web_worker_fetch_context); 347 DCHECK(web_worker_fetch_context);
348 // TODO(horo): Set more information about the context (ex: AppCacheHostID) 348 // TODO(horo): Set more information about the context (ex: AppCacheHostID)
349 // to |web_worker_fetch_context|. 349 // to |web_worker_fetch_context|.
350 web_worker_fetch_context->SetDataSaverEnabled( 350 web_worker_fetch_context->SetDataSaverEnabled(
351 document->GetFrame()->GetSettings()->GetDataSaverEnabled()); 351 main_frame_->GetFrame()->GetSettings()->GetDataSaverEnabled());
352 ProvideWorkerFetchContextToWorker(worker_clients, 352 ProvideWorkerFetchContextToWorker(worker_clients,
353 std::move(web_worker_fetch_context)); 353 std::move(web_worker_fetch_context));
354 } 354 }
355 355
356 ContentSecurityPolicy* content_security_policy = 356 ContentSecurityPolicy* content_security_policy =
357 main_script_loader_->ReleaseContentSecurityPolicy(); 357 main_script_loader_->ReleaseContentSecurityPolicy();
358 WorkerThreadStartMode start_mode = 358 WorkerThreadStartMode start_mode =
359 worker_inspector_proxy_->WorkerStartMode(document); 359 worker_inspector_proxy_->WorkerStartMode(loading_document_);
360 std::unique_ptr<WorkerSettings> worker_settings = 360 std::unique_ptr<WorkerSettings> worker_settings = WTF::WrapUnique(
361 WTF::WrapUnique(new WorkerSettings(document->GetSettings())); 361 new WorkerSettings(main_frame_->GetFrame()->GetSettings()));
362 WorkerV8Settings worker_v8_settings = WorkerV8Settings::Default(); 362 WorkerV8Settings worker_v8_settings = WorkerV8Settings::Default();
363 worker_v8_settings.atomics_wait_mode_ = 363 worker_v8_settings.atomics_wait_mode_ =
364 WorkerV8Settings::AtomicsWaitMode::kAllow; 364 WorkerV8Settings::AtomicsWaitMode::kAllow;
365 std::unique_ptr<WorkerThreadStartupData> startup_data = 365 std::unique_ptr<WorkerThreadStartupData> startup_data =
366 WorkerThreadStartupData::Create( 366 WorkerThreadStartupData::Create(
367 url_, loading_document_->UserAgent(), 367 url_, loading_document_->UserAgent(),
368 main_script_loader_->SourceText(), nullptr, start_mode, 368 main_script_loader_->SourceText(), nullptr, start_mode,
369 content_security_policy ? content_security_policy->Headers().get() 369 content_security_policy ? content_security_policy->Headers().get()
370 : nullptr, 370 : nullptr,
371 main_script_loader_->GetReferrerPolicy(), starter_origin, 371 main_script_loader_->GetReferrerPolicy(), starter_origin,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 if (devtools_agent) 437 if (devtools_agent)
438 devtools_agent->DispatchOnInspectorBackend(session_id, call_id, method, 438 devtools_agent->DispatchOnInspectorBackend(session_id, call_id, method,
439 message); 439 message);
440 } 440 }
441 441
442 WebSharedWorker* WebSharedWorker::Create(WebSharedWorkerClient* client) { 442 WebSharedWorker* WebSharedWorker::Create(WebSharedWorkerClient* client) {
443 return new WebSharedWorkerImpl(client); 443 return new WebSharedWorkerImpl(client);
444 } 444 }
445 445
446 } // namespace blink 446 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698