mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
net: Convert the storage task to use IPC.
This commit is contained in:
parent
8edf1a5ecd
commit
43cb7d5abd
8 changed files with 58 additions and 31 deletions
|
@ -2,43 +2,44 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::sync::mpsc::Sender;
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
use url::Url;
|
||||
|
||||
use util::str::DOMString;
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Copy, Clone, Deserialize, Serialize)]
|
||||
pub enum StorageType {
|
||||
Session,
|
||||
Local
|
||||
}
|
||||
|
||||
/// Request operations on the storage data associated with a particular url
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub enum StorageTaskMsg {
|
||||
/// gets the number of key/value pairs present in the associated storage data
|
||||
Length(Sender<usize>, Url, StorageType),
|
||||
Length(IpcSender<usize>, Url, StorageType),
|
||||
|
||||
/// gets the name of the key at the specified index in the associated storage data
|
||||
Key(Sender<Option<DOMString>>, Url, StorageType, u32),
|
||||
Key(IpcSender<Option<DOMString>>, Url, StorageType, u32),
|
||||
|
||||
/// gets the value associated with the given key in the associated storage data
|
||||
GetItem(Sender<Option<DOMString>>, Url, StorageType, DOMString),
|
||||
GetItem(IpcSender<Option<DOMString>>, Url, StorageType, DOMString),
|
||||
|
||||
/// sets the value of the given key in the associated storage data
|
||||
/// TODO throw QuotaExceededError in case of error
|
||||
SetItem(Sender<(bool, Option<DOMString>)>, Url, StorageType, DOMString, DOMString),
|
||||
SetItem(IpcSender<(bool, Option<DOMString>)>, Url, StorageType, DOMString, DOMString),
|
||||
|
||||
/// removes the key/value pair for the given key in the associated storage data
|
||||
RemoveItem(Sender<Option<DOMString>>, Url, StorageType, DOMString),
|
||||
RemoveItem(IpcSender<Option<DOMString>>, Url, StorageType, DOMString),
|
||||
|
||||
/// clears the associated storage data by removing all the key/value pairs
|
||||
Clear(Sender<bool>, Url, StorageType),
|
||||
Clear(IpcSender<bool>, Url, StorageType),
|
||||
|
||||
/// shut down this task
|
||||
Exit
|
||||
}
|
||||
|
||||
/// Handle to a storage task
|
||||
pub type StorageTask = Sender<StorageTaskMsg>;
|
||||
pub type StorageTask = IpcSender<StorageTaskMsg>;
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue