mirror of
https://github.com/servo/servo.git
synced 2025-08-30 01:28:21 +01:00
script: send StorageThreadMsg directly (#38921)
Remove the intermediate clone of an IpcSender, by directly sending. Testing: No functional changes Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
This commit is contained in:
parent
91c08f49e1
commit
c4b2f3af56
1 changed files with 35 additions and 40 deletions
|
@ -5,9 +5,8 @@
|
||||||
use base::id::WebViewId;
|
use base::id::WebViewId;
|
||||||
use constellation_traits::ScriptToConstellationMessage;
|
use constellation_traits::ScriptToConstellationMessage;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use ipc_channel::ipc::IpcSender;
|
|
||||||
use net_traits::IpcSend;
|
|
||||||
use net_traits::storage_thread::{StorageThreadMsg, StorageType};
|
use net_traits::storage_thread::{StorageThreadMsg, StorageType};
|
||||||
|
use net_traits::{IpcSend, IpcSendResult};
|
||||||
use profile_traits::ipc;
|
use profile_traits::ipc;
|
||||||
use servo_url::ServoUrl;
|
use servo_url::ServoUrl;
|
||||||
|
|
||||||
|
@ -58,8 +57,8 @@ impl Storage {
|
||||||
self.global().get_url()
|
self.global().get_url()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_storage_thread(&self) -> IpcSender<StorageThreadMsg> {
|
fn send_storage_msg(&self, msg: StorageThreadMsg) -> IpcSendResult {
|
||||||
self.global().resource_threads().sender()
|
self.global().resource_threads().send(msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,14 +67,13 @@ impl StorageMethods<crate::DomTypeHolder> for Storage {
|
||||||
fn Length(&self) -> u32 {
|
fn Length(&self) -> u32 {
|
||||||
let (sender, receiver) = ipc::channel(self.global().time_profiler_chan().clone()).unwrap();
|
let (sender, receiver) = ipc::channel(self.global().time_profiler_chan().clone()).unwrap();
|
||||||
|
|
||||||
self.get_storage_thread()
|
self.send_storage_msg(StorageThreadMsg::Length(
|
||||||
.send(StorageThreadMsg::Length(
|
sender,
|
||||||
sender,
|
self.storage_type,
|
||||||
self.storage_type,
|
self.webview_id(),
|
||||||
self.webview_id(),
|
self.get_url(),
|
||||||
self.get_url(),
|
))
|
||||||
))
|
.unwrap();
|
||||||
.unwrap();
|
|
||||||
receiver.recv().unwrap() as u32
|
receiver.recv().unwrap() as u32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,15 +81,14 @@ impl StorageMethods<crate::DomTypeHolder> for Storage {
|
||||||
fn Key(&self, index: u32) -> Option<DOMString> {
|
fn Key(&self, index: u32) -> Option<DOMString> {
|
||||||
let (sender, receiver) = ipc::channel(self.global().time_profiler_chan().clone()).unwrap();
|
let (sender, receiver) = ipc::channel(self.global().time_profiler_chan().clone()).unwrap();
|
||||||
|
|
||||||
self.get_storage_thread()
|
self.send_storage_msg(StorageThreadMsg::Key(
|
||||||
.send(StorageThreadMsg::Key(
|
sender,
|
||||||
sender,
|
self.storage_type,
|
||||||
self.storage_type,
|
self.webview_id(),
|
||||||
self.webview_id(),
|
self.get_url(),
|
||||||
self.get_url(),
|
index,
|
||||||
index,
|
))
|
||||||
))
|
.unwrap();
|
||||||
.unwrap();
|
|
||||||
receiver.recv().unwrap().map(DOMString::from)
|
receiver.recv().unwrap().map(DOMString::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +104,7 @@ impl StorageMethods<crate::DomTypeHolder> for Storage {
|
||||||
self.get_url(),
|
self.get_url(),
|
||||||
name,
|
name,
|
||||||
);
|
);
|
||||||
self.get_storage_thread().send(msg).unwrap();
|
self.send_storage_msg(msg).unwrap();
|
||||||
receiver.recv().unwrap().map(DOMString::from)
|
receiver.recv().unwrap().map(DOMString::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +122,7 @@ impl StorageMethods<crate::DomTypeHolder> for Storage {
|
||||||
name.clone(),
|
name.clone(),
|
||||||
value.clone(),
|
value.clone(),
|
||||||
);
|
);
|
||||||
self.get_storage_thread().send(msg).unwrap();
|
self.send_storage_msg(msg).unwrap();
|
||||||
match receiver.recv().unwrap() {
|
match receiver.recv().unwrap() {
|
||||||
Err(_) => Err(Error::QuotaExceeded {
|
Err(_) => Err(Error::QuotaExceeded {
|
||||||
quota: None,
|
quota: None,
|
||||||
|
@ -152,7 +149,7 @@ impl StorageMethods<crate::DomTypeHolder> for Storage {
|
||||||
self.get_url(),
|
self.get_url(),
|
||||||
name.clone(),
|
name.clone(),
|
||||||
);
|
);
|
||||||
self.get_storage_thread().send(msg).unwrap();
|
self.send_storage_msg(msg).unwrap();
|
||||||
if let Some(old_value) = receiver.recv().unwrap() {
|
if let Some(old_value) = receiver.recv().unwrap() {
|
||||||
self.broadcast_change_notification(Some(name), Some(old_value), None);
|
self.broadcast_change_notification(Some(name), Some(old_value), None);
|
||||||
}
|
}
|
||||||
|
@ -162,14 +159,13 @@ impl StorageMethods<crate::DomTypeHolder> for Storage {
|
||||||
fn Clear(&self) {
|
fn Clear(&self) {
|
||||||
let (sender, receiver) = ipc::channel(self.global().time_profiler_chan().clone()).unwrap();
|
let (sender, receiver) = ipc::channel(self.global().time_profiler_chan().clone()).unwrap();
|
||||||
|
|
||||||
self.get_storage_thread()
|
self.send_storage_msg(StorageThreadMsg::Clear(
|
||||||
.send(StorageThreadMsg::Clear(
|
sender,
|
||||||
sender,
|
self.storage_type,
|
||||||
self.storage_type,
|
self.webview_id(),
|
||||||
self.webview_id(),
|
self.get_url(),
|
||||||
self.get_url(),
|
))
|
||||||
))
|
.unwrap();
|
||||||
.unwrap();
|
|
||||||
if receiver.recv().unwrap() {
|
if receiver.recv().unwrap() {
|
||||||
self.broadcast_change_notification(None, None, None);
|
self.broadcast_change_notification(None, None, None);
|
||||||
}
|
}
|
||||||
|
@ -179,14 +175,13 @@ impl StorageMethods<crate::DomTypeHolder> for Storage {
|
||||||
fn SupportedPropertyNames(&self) -> Vec<DOMString> {
|
fn SupportedPropertyNames(&self) -> Vec<DOMString> {
|
||||||
let (sender, receiver) = ipc::channel(self.global().time_profiler_chan().clone()).unwrap();
|
let (sender, receiver) = ipc::channel(self.global().time_profiler_chan().clone()).unwrap();
|
||||||
|
|
||||||
self.get_storage_thread()
|
self.send_storage_msg(StorageThreadMsg::Keys(
|
||||||
.send(StorageThreadMsg::Keys(
|
sender,
|
||||||
sender,
|
self.storage_type,
|
||||||
self.storage_type,
|
self.webview_id(),
|
||||||
self.webview_id(),
|
self.get_url(),
|
||||||
self.get_url(),
|
))
|
||||||
))
|
.unwrap();
|
||||||
.unwrap();
|
|
||||||
receiver
|
receiver
|
||||||
.recv()
|
.recv()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue