diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-11-15 10:50:20 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-15 10:50:20 -0600 |
commit | 07b9dbe05a3d27b2623195f0c77ea7d7c45a4783 (patch) | |
tree | fdfab8c411c77d05604ff166a9b623f4a957978e /components/script/script_thread.rs | |
parent | ef74d8da3bdb1cc3b1edf767a593e0e59228f23b (diff) | |
parent | c91ef86a20813d433fb7fb595c37d611d27967d0 (diff) | |
download | servo-07b9dbe05a3d27b2623195f0c77ea7d7c45a4783.tar.gz servo-07b9dbe05a3d27b2623195f0c77ea7d7c45a4783.zip |
Auto merge of #14023 - asajeffrey:storage-notify-via-constellation, r=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 -->
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r-- | components/script/script_thread.rs | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 7dfe41dac20..632397cc147 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -75,6 +75,7 @@ use msg::constellation_msg::{FrameId, FrameType, PipelineId, PipelineNamespace}; use net_traits::{CoreResourceMsg, IpcSend, Metadata, ReferrerPolicy, ResourceThreads}; use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheResult, ImageCacheThread}; use net_traits::request::{CredentialsMode, Destination, RequestInit}; +use net_traits::storage_thread::StorageType; use network_listener::NetworkListener; use profile_traits::mem::{self, OpaqueSender, Report, ReportKind, ReportsChan}; use profile_traits::time::{self, ProfilerCategory, profile}; @@ -90,7 +91,7 @@ use script_traits::CompositorEvent::{KeyEvent, MouseButtonEvent, MouseMoveEvent, use script_traits::CompositorEvent::{TouchEvent, TouchpadPressureEvent}; use script_traits::webdriver_msg::WebDriverScriptCommand; use std::borrow::ToOwned; -use std::cell::{Cell, Ref}; +use std::cell::Cell; use std::collections::{hash_map, HashMap, HashSet}; use std::option::Option; use std::ptr; @@ -605,12 +606,6 @@ impl ScriptThread { })) } - // TODO: This method is only needed for storage, and can be removed - // once storage event dispatch is moved to the constellation. - pub fn borrow_documents(&self) -> Ref<Documents> { - self.documents.borrow() - } - /// Creates a new script thread. pub fn new(state: InitialScriptState, port: Receiver<MainThreadScriptMsg>, @@ -981,6 +976,8 @@ impl ScriptThread { ConstellationControlMsg::DispatchFrameLoadEvent { target: frame_id, parent: parent_id, child: child_id } => self.handle_frame_load_event(parent_id, frame_id, child_id), + ConstellationControlMsg::DispatchStorageEvent(pipeline_id, storage, url, key, old_value, new_value) => + self.handle_storage_event(pipeline_id, storage, url, key, old_value, new_value), ConstellationControlMsg::FramedContentChanged(parent_pipeline_id, frame_id) => self.handle_framed_content_changed(parent_pipeline_id, frame_id), ConstellationControlMsg::ReportCSSError(pipeline_id, filename, line, column, msg) => @@ -1582,6 +1579,20 @@ impl ScriptThread { } } + /// Notify a window of a storage event + fn handle_storage_event(&self, pipeline_id: PipelineId, storage_type: StorageType, url: Url, + key: Option<String>, old_value: Option<String>, new_value: Option<String>) { + let storage = match self.documents.borrow().find_window(pipeline_id) { + None => return warn!("Storage event sent to closed pipeline {}.", pipeline_id), + Some(window) => match storage_type { + StorageType::Local => window.LocalStorage(), + StorageType::Session => window.SessionStorage(), + }, + }; + + storage.queue_storage_event(url, key, old_value, new_value); + } + /// Notify the containing document of a child frame that has completed loading. fn handle_frame_load_event(&self, parent_id: PipelineId, frame_id: FrameId, child_id: PipelineId) { match self.documents.borrow().find_iframe(parent_id, frame_id) { |