Skip to content

Storage notifications routed via the constellation.#14023

Merged
bors-servo merged 1 commit intoservo:masterfrom
asajeffrey:storage-notify-via-constellation
Nov 15, 2016
Merged

Storage notifications routed via the constellation.#14023
bors-servo merged 1 commit intoservo:masterfrom
asajeffrey:storage-notify-via-constellation

Conversation

@asajeffrey
Copy link
Copy Markdown
Contributor

@asajeffrey asajeffrey commented Nov 2, 2016

At the moment, storage notifications are only sent within a script thread, not to same-origin pipelines in different script threads. This PR fixes that.



This change is Reviewable

@asajeffrey asajeffrey added A-content/script Related to the script thread A-constellation Involves the constellation labels Nov 2, 2016
@highfive
Copy link
Copy Markdown

highfive commented Nov 2, 2016

Heads up! This PR modifies the following files:

  • @fitzgen: components/script/dom/storage.rs, components/script_traits/script_msg.rs, components/script_traits/script_msg.rs, components/script/script_thread.rs, components/script_traits/lib.rs, components/script_traits/lib.rs
  • @KiChjang: components/script/dom/storage.rs, components/script_traits/script_msg.rs, components/script_traits/script_msg.rs, components/script/script_thread.rs, components/script_traits/lib.rs, components/script_traits/lib.rs

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Nov 2, 2016
@asajeffrey asajeffrey added the S-needs-squash Some (or all) of the commits in the PR should be combined. label Nov 3, 2016
@bors-servo
Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #13646) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Nov 4, 2016
@asajeffrey asajeffrey force-pushed the storage-notify-via-constellation branch from a8b66da to 75867ef Compare November 4, 2016 02:38
@asajeffrey asajeffrey removed the S-needs-rebase There are merge conflict errors. label Nov 4, 2016
let msg = ConstellationControlMsg::DispatchStorageEvent(
pipeline.id, storage, url.clone(), key.clone(), old_value.clone(), new_value.clone()
);
let _ = pipeline.script_chan.send(msg);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why ignore failure here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

};

for pipeline in self.pipelines.values() {
if (pipeline.id != pipeline_id) && (pipeline.url.origin() == origin) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: remove parens.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I prefer explicit parens rather than relying on operator pecedence to resolve ambiguity.

let origin = match Url::parse(&*url) {
Ok(url) => url.origin(),
Err(err) => return warn!("Failed to parse url {}: {:?}.", url, err),
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why ignore failure here? Why isn't that method taking an Url directly? I see below that the String comes directly from an Url, so please just unwrap the result of Url::parse or pass an actual Url around.

Oh I see you did that in second commit. Could you squash them?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll squash them before merging.

DOMString::from(ev_url.to_string()),
Some(&storage)
DOMString::from(this.url),
Some(&*storage)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the sudden *?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently no good reason, not sure how this snuck in. Fixed.

pub enum ScriptMsg {
/// Broadcast a storage event to every same-origin pipeline.
/// The strings are url, key, old value and new value.
BroadcastStorageEvent(PipelineId, StorageType, String, Option<String>, Option<String>, Option<String>),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use a struct variant instead of documenting each field in prose?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you, but we should be consistent about it, not just adopt struct variants piecemeal.

@nox
Copy link
Copy Markdown
Contributor

nox commented Nov 7, 2016

GitHub somehow decided that some of my comments are outdated when they are not, please expand them when you read this @asajeffrey.

@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Nov 7, 2016
@asajeffrey asajeffrey added the S-awaiting-review There is new code that needs to be reviewed. label Nov 8, 2016
@asajeffrey
Copy link
Copy Markdown
Contributor Author

@highfive highfive removed the S-needs-code-changes Changes have not yet been made that were requested by a reviewer. label Nov 8, 2016
@asajeffrey asajeffrey force-pushed the storage-notify-via-constellation branch from 0ee6c6d to 2711a0e Compare November 8, 2016 17:47
@bors-servo
Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #14013) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Nov 8, 2016
@asajeffrey asajeffrey force-pushed the storage-notify-via-constellation branch from 2711a0e to 4c09ef4 Compare November 8, 2016 18:39
@jdm jdm removed the S-needs-rebase There are merge conflict errors. label Nov 15, 2016
@asajeffrey asajeffrey force-pushed the storage-notify-via-constellation branch from 4c09ef4 to d8a9112 Compare November 15, 2016 15:51
@nox
Copy link
Copy Markdown
Contributor

nox commented Nov 15, 2016

Squash and r=me.

@asajeffrey asajeffrey force-pushed the storage-notify-via-constellation branch from d8a9112 to c91ef86 Compare November 15, 2016 15:57
@asajeffrey
Copy link
Copy Markdown
Contributor Author

Squashed. @bors-servo r=nox

@bors-servo
Copy link
Copy Markdown
Contributor

📌 Commit c91ef86 has been approved by nox

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. S-needs-squash Some (or all) of the commits in the PR should be combined. labels Nov 15, 2016
@bors-servo
Copy link
Copy Markdown
Contributor

⌛ Testing commit c91ef86 with merge 07b9dbe...

bors-servo pushed a commit that referenced this pull request Nov 15, 2016
…=nox

Storage notifications routed via the constellation.

<!-- Please describe your changes on the following line: -->

At the moment, storage notifications are only sent within a script thread, not to same-origin pipelines in different script threads. This PR fixes that.

---
<!-- 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 #5196
- [X] These changes do not require tests because existing tests now pass

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->

---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14023)
<!-- Reviewable:end -->
@bors-servo
Copy link
Copy Markdown
Contributor

@bors-servo bors-servo merged commit c91ef86 into servo:master Nov 15, 2016
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Nov 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-constellation Involves the constellation A-content/script Related to the script thread

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dispatch StorageEvent events to other windows when modifying storage instances

6 participants