Auto merge of #25338 - warren-fisher:master, r=jdm

Remove Optional pipeline_id

<!-- Please describe your changes on the following line: -->
All code that creates a WorkerScriptLoadOrigin passes a Some value for the pipeline, so we should remove the Option from the struct member field.

I changed the `WorkerScriptLoadOrigin` struct in `components/script_traits/lib.rs` to have a PipelineId and not an Option<PipelineId>. In `components/script/dom/worker.rs` and `components/script/dom/serviceworkerregistration.rs` it was changed so that `WorkerScriptLoadOrigin` was instantiated with a non-Optional. In `components/script/dom/dedicatedworkerglobalscope.rs` testing for if pipeline_id is an Optional is removed.

In `components/script/dom/serviceworkerglobalscope.rs` and `components/script/dom/dedicatedworkerglobalscope.rs` a `PipelineId` was provided as an Optional to a `RequestBuilder` and I changed it to provide a `Some(pipeline_id)` instead. I am not sure changing the [RequestBuilder struct](5c3bda0251/components/net_traits/request.rs (L118-L159)) at line 147 to accept a non-optional was within this issue so I left it as is.

I was able to successfully build it so I assume these changes worked, however I am not sure about the implications of the changes made in the unsafe block in `components/script/dom/dedicatedworkerglobalscope.rs`.

<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #24772 (GitHub issue number if applicable)

<!-- Either: -->
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because the issue says so

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
This commit is contained in:
bors-servo 2019-12-19 10:10:15 -05:00 committed by GitHub
commit aa36d5f657
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 18 deletions

View file

@ -320,24 +320,20 @@ impl DedicatedWorkerGlobalScope {
.credentials_mode(CredentialsMode::CredentialsSameOrigin) .credentials_mode(CredentialsMode::CredentialsSameOrigin)
.parser_metadata(ParserMetadata::NotParserInserted) .parser_metadata(ParserMetadata::NotParserInserted)
.use_url_credentials(true) .use_url_credentials(true)
.pipeline_id(pipeline_id) .pipeline_id(Some(pipeline_id))
.referrer(referrer) .referrer(referrer)
.referrer_policy(referrer_policy) .referrer_policy(referrer_policy)
.origin(origin); .origin(origin);
let runtime = unsafe { let runtime = unsafe {
if let Some(pipeline_id) = pipeline_id { let task_source = NetworkingTaskSource(
let task_source = NetworkingTaskSource( Box::new(WorkerThreadWorkerChan {
Box::new(WorkerThreadWorkerChan { sender: own_sender.clone(),
sender: own_sender.clone(), worker: worker.clone(),
worker: worker.clone(), }),
}), pipeline_id,
pipeline_id, );
); new_child_runtime(parent, Some(task_source))
new_child_runtime(parent, Some(task_source))
} else {
new_child_runtime(parent, None)
}
}; };
let (devtools_mpsc_chan, devtools_mpsc_port) = unbounded(); let (devtools_mpsc_chan, devtools_mpsc_port) = unbounded();
@ -375,7 +371,7 @@ impl DedicatedWorkerGlobalScope {
.send(CommonScriptMsg::Task( .send(CommonScriptMsg::Task(
WorkerEvent, WorkerEvent,
Box::new(SimpleWorkerErrorHandler::new(worker)), Box::new(SimpleWorkerErrorHandler::new(worker)),
pipeline_id, Some(pipeline_id),
TaskSourceName::DOMManipulation, TaskSourceName::DOMManipulation,
)) ))
.unwrap(); .unwrap();

View file

@ -289,7 +289,7 @@ impl ServiceWorkerGlobalScope {
.credentials_mode(CredentialsMode::Include) .credentials_mode(CredentialsMode::Include)
.parser_metadata(ParserMetadata::NotParserInserted) .parser_metadata(ParserMetadata::NotParserInserted)
.use_url_credentials(true) .use_url_credentials(true)
.pipeline_id(pipeline_id) .pipeline_id(Some(pipeline_id))
.referrer(referrer) .referrer(referrer)
.referrer_policy(referrer_policy) .referrer_policy(referrer_policy)
.origin(origin); .origin(origin);

View file

@ -110,7 +110,7 @@ impl ServiceWorkerRegistration {
let worker_load_origin = WorkerScriptLoadOrigin { let worker_load_origin = WorkerScriptLoadOrigin {
referrer_url: None, referrer_url: None,
referrer_policy: None, referrer_policy: None,
pipeline_id: Some(global.pipeline_id()), pipeline_id: global.pipeline_id(),
}; };
let worker_id = WorkerId(Uuid::new_v4()); let worker_id = WorkerId(Uuid::new_v4());

View file

@ -97,7 +97,7 @@ impl Worker {
let worker_load_origin = WorkerScriptLoadOrigin { let worker_load_origin = WorkerScriptLoadOrigin {
referrer_url: None, referrer_url: None,
referrer_policy: None, referrer_policy: None,
pipeline_id: Some(global.pipeline_id()), pipeline_id: global.pipeline_id(),
}; };
let (devtools_sender, devtools_receiver) = ipc::channel().unwrap(); let (devtools_sender, devtools_receiver) = ipc::channel().unwrap();

View file

@ -962,7 +962,7 @@ pub struct WorkerScriptLoadOrigin {
/// the referrer policy which is used /// the referrer policy which is used
pub referrer_policy: Option<ReferrerPolicy>, pub referrer_policy: Option<ReferrerPolicy>,
/// the pipeline id of the entity requesting the load /// the pipeline id of the entity requesting the load
pub pipeline_id: Option<PipelineId>, pub pipeline_id: PipelineId,
} }
/// Errors from executing a paint worklet /// Errors from executing a paint worklet