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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 if (main_script_loader_->Failed()) { | 308 if (main_script_loader_->Failed()) { |
309 main_script_loader_->Cancel(); | 309 main_script_loader_->Cancel(); |
310 client_->WorkerScriptLoadFailed(); | 310 client_->WorkerScriptLoadFailed(); |
311 | 311 |
312 // The SharedWorker was unable to load the initial script, so | 312 // The SharedWorker was unable to load the initial script, so |
313 // shut it down right here. | 313 // shut it down right here. |
314 delete this; | 314 delete this; |
315 return; | 315 return; |
316 } | 316 } |
317 | 317 |
318 Document* document = main_frame_->GetFrame()->GetDocument(); | 318 // FIXME: this document's origin is pristine and without any extra privileges |
319 // FIXME: this document's origin is pristine and without any extra privileges. | 319 // (e.g. GrantUniversalAccess) that can be overriden in regular documents |
320 // (crbug.com/254993) | 320 // via WebPreference by embedders. (crbug.com/254993) |
321 SecurityOrigin* starter_origin = document->GetSecurityOrigin(); | 321 SecurityOrigin* starter_origin = loading_document_->GetSecurityOrigin(); |
322 | 322 |
323 WorkerClients* worker_clients = WorkerClients::Create(); | 323 WorkerClients* worker_clients = WorkerClients::Create(); |
324 ProvideLocalFileSystemToWorker(worker_clients, | 324 ProvideLocalFileSystemToWorker(worker_clients, |
325 LocalFileSystemClient::Create()); | 325 LocalFileSystemClient::Create()); |
326 WebSecurityOrigin web_security_origin(loading_document_->GetSecurityOrigin()); | 326 WebSecurityOrigin web_security_origin(loading_document_->GetSecurityOrigin()); |
327 ProvideContentSettingsClientToWorker( | 327 ProvideContentSettingsClientToWorker( |
328 worker_clients, | 328 worker_clients, |
329 WTF::WrapUnique(client_->CreateWorkerContentSettingsClientProxy( | 329 WTF::WrapUnique(client_->CreateWorkerContentSettingsClientProxy( |
330 web_security_origin))); | 330 web_security_origin))); |
331 ProvideIndexedDBClientToWorker(worker_clients, | 331 ProvideIndexedDBClientToWorker(worker_clients, |
332 IndexedDBClientImpl::Create(*worker_clients)); | 332 IndexedDBClientImpl::Create(*worker_clients)); |
333 | 333 |
334 if (RuntimeEnabledFeatures::offMainThreadFetchEnabled()) { | 334 if (RuntimeEnabledFeatures::offMainThreadFetchEnabled()) { |
335 std::unique_ptr<WebWorkerFetchContext> web_worker_fetch_context = | 335 std::unique_ptr<WebWorkerFetchContext> web_worker_fetch_context = |
336 client_->CreateWorkerFetchContext( | 336 client_->CreateWorkerFetchContext( |
337 WebLocalFrameBase::FromFrame(main_frame_->GetFrame()) | 337 WebLocalFrameBase::FromFrame(main_frame_->GetFrame()) |
338 ->DataSource() | 338 ->DataSource() |
339 ->GetServiceWorkerNetworkProvider()); | 339 ->GetServiceWorkerNetworkProvider()); |
340 DCHECK(web_worker_fetch_context); | 340 DCHECK(web_worker_fetch_context); |
341 // TODO(horo): Set more information about the context (ex: DataSaverEnabled) | 341 // TODO(horo): Set more information about the context (ex: DataSaverEnabled) |
342 // to |web_worker_fetch_context|. | 342 // to |web_worker_fetch_context|. |
343 ProvideWorkerFetchContextToWorker(worker_clients, | 343 ProvideWorkerFetchContextToWorker(worker_clients, |
344 std::move(web_worker_fetch_context)); | 344 std::move(web_worker_fetch_context)); |
345 } | 345 } |
346 | 346 |
347 ContentSecurityPolicy* content_security_policy = | 347 ContentSecurityPolicy* content_security_policy = |
348 main_script_loader_->ReleaseContentSecurityPolicy(); | 348 main_script_loader_->ReleaseContentSecurityPolicy(); |
349 WorkerThreadStartMode start_mode = | 349 WorkerThreadStartMode start_mode = |
350 worker_inspector_proxy_->WorkerStartMode(document); | 350 worker_inspector_proxy_->WorkerStartMode(loading_document_); |
351 std::unique_ptr<WorkerSettings> worker_settings = | 351 std::unique_ptr<WorkerSettings> worker_settings = WTF::WrapUnique( |
352 WTF::WrapUnique(new WorkerSettings(document->GetSettings())); | 352 new WorkerSettings(main_frame_->GetFrame()->GetSettings())); |
353 WorkerV8Settings worker_v8_settings = WorkerV8Settings::Default(); | 353 WorkerV8Settings worker_v8_settings = WorkerV8Settings::Default(); |
354 worker_v8_settings.atomics_wait_mode_ = | 354 worker_v8_settings.atomics_wait_mode_ = |
355 WorkerV8Settings::AtomicsWaitMode::kAllow; | 355 WorkerV8Settings::AtomicsWaitMode::kAllow; |
356 std::unique_ptr<WorkerThreadStartupData> startup_data = | 356 std::unique_ptr<WorkerThreadStartupData> startup_data = |
357 WorkerThreadStartupData::Create( | 357 WorkerThreadStartupData::Create( |
358 url_, loading_document_->UserAgent(), | 358 url_, loading_document_->UserAgent(), |
359 main_script_loader_->SourceText(), nullptr, start_mode, | 359 main_script_loader_->SourceText(), nullptr, start_mode, |
360 content_security_policy ? content_security_policy->Headers().get() | 360 content_security_policy ? content_security_policy->Headers().get() |
361 : nullptr, | 361 : nullptr, |
362 main_script_loader_->GetReferrerPolicy(), starter_origin, | 362 main_script_loader_->GetReferrerPolicy(), starter_origin, |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 if (devtools_agent) | 428 if (devtools_agent) |
429 devtools_agent->DispatchOnInspectorBackend(session_id, call_id, method, | 429 devtools_agent->DispatchOnInspectorBackend(session_id, call_id, method, |
430 message); | 430 message); |
431 } | 431 } |
432 | 432 |
433 WebSharedWorker* WebSharedWorker::Create(WebSharedWorkerClient* client) { | 433 WebSharedWorker* WebSharedWorker::Create(WebSharedWorkerClient* client) { |
434 return new WebSharedWorkerImpl(client); | 434 return new WebSharedWorkerImpl(client); |
435 } | 435 } |
436 | 436 |
437 } // namespace blink | 437 } // namespace blink |
OLD | NEW |