Split out shared networking code into net_traits crate

Fixes #4476
This commit is contained in:
Gilles Leblanc 2015-03-23 21:19:55 -04:00
parent 74f8c0eeb7
commit ba36a108c1
56 changed files with 674 additions and 518 deletions

View file

@ -3,48 +3,15 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::borrow::ToOwned;
use std::collections::HashMap;
use std::collections::BTreeMap;
use std::collections::HashMap;
use std::sync::mpsc::{channel, Receiver, Sender};
use url::Url;
use net_traits::storage_task::{StorageTask, StorageTaskMsg, StorageType};
use util::str::DOMString;
use util::task::spawn_named;
#[derive(Copy)]
pub enum StorageType {
Session,
Local
}
/// Request operations on the storage data associated with a particular url
pub enum StorageTaskMsg {
/// gets the number of key/value pairs present in the associated storage data
Length(Sender<u32>, Url, StorageType),
/// gets the name of the key at the specified index in the associated storage data
Key(Sender<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),
/// 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),
/// removes the key/value pair for the given key in the associated storage data
RemoveItem(Sender<Option<DOMString>>, Url, StorageType, DOMString),
/// clears the associated storage data by removing all the key/value pairs
Clear(Sender<bool>, Url, StorageType),
/// shut down this task
Exit
}
/// Handle to a storage task
pub type StorageTask = Sender<StorageTaskMsg>;
pub trait StorageTaskFactory {
fn new() -> Self;
}