aboutsummaryrefslogtreecommitdiffstats
path: root/components/net_traits/storage_thread.rs
diff options
context:
space:
mode:
authorrohan.prinja <rohan.prinja@samsung.com>2015-11-14 05:07:55 +0900
committerRohan Prinja <rohan.prinja@gmail.com>2016-01-10 17:58:13 +0900
commit1f02c4ebbb7d5ea49051f4391f1418f20c15d7a9 (patch)
tree7d61e58e746ddca93074ca6bca6849360a098b8c /components/net_traits/storage_thread.rs
parentf00532bab0382d1c24e6086314f26497fb6ffe0f (diff)
downloadservo-1f02c4ebbb7d5ea49051f4391f1418f20c15d7a9.tar.gz
servo-1f02c4ebbb7d5ea49051f4391f1418f20c15d7a9.zip
task -> thread
Diffstat (limited to 'components/net_traits/storage_thread.rs')
-rw-r--r--components/net_traits/storage_thread.rs45
1 files changed, 45 insertions, 0 deletions
diff --git a/components/net_traits/storage_thread.rs b/components/net_traits/storage_thread.rs
new file mode 100644
index 00000000000..f544c50a059
--- /dev/null
+++ b/components/net_traits/storage_thread.rs
@@ -0,0 +1,45 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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 ipc_channel::ipc::IpcSender;
+use url::Url;
+
+#[derive(Copy, Clone, Deserialize, Serialize, HeapSizeOf)]
+pub enum StorageType {
+ Session,
+ Local
+}
+
+/// Request operations on the storage data associated with a particular url
+#[derive(Deserialize, Serialize)]
+pub enum StorageThreadMsg {
+ /// gets the number of key/value pairs present in the associated storage data
+ Length(IpcSender<usize>, Url, StorageType),
+
+ /// gets the name of the key at the specified index in the associated storage data
+ Key(IpcSender<Option<String>>, Url, StorageType, u32),
+
+ /// Gets the available keys in the associated storage data
+ Keys(IpcSender<Vec<String>>, Url, StorageType),
+
+ /// gets the value associated with the given key in the associated storage data
+ GetItem(IpcSender<Option<String>>, Url, StorageType, String),
+
+ /// sets the value of the given key in the associated storage data
+ SetItem(IpcSender<Result<(bool, Option<String>), ()>>, Url, StorageType, String, String),
+
+ /// removes the key/value pair for the given key in the associated storage data
+ RemoveItem(IpcSender<Option<String>>, Url, StorageType, String),
+
+ /// clears the associated storage data by removing all the key/value pairs
+ Clear(IpcSender<bool>, Url, StorageType),
+
+ /// shut down this thread
+ Exit
+}
+
+/// Handle to a storage thread
+pub type StorageThread = IpcSender<StorageThreadMsg>;
+
+