net_traits/
storage_thread.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5use base::generic_channel::GenericSender;
6use base::id::WebViewId;
7use malloc_size_of_derive::MallocSizeOf;
8use profile_traits::mem::ReportsChan;
9use serde::{Deserialize, Serialize};
10use servo_url::ServoUrl;
11
12#[derive(Clone, Copy, Debug, Deserialize, MallocSizeOf, Serialize)]
13pub enum StorageType {
14    Session,
15    Local,
16}
17
18/// Request operations on the storage data associated with a particular url
19#[derive(Debug, Deserialize, Serialize)]
20pub enum StorageThreadMsg {
21    /// gets the number of key/value pairs present in the associated storage data
22    Length(GenericSender<usize>, StorageType, WebViewId, ServoUrl),
23
24    /// gets the name of the key at the specified index in the associated storage data
25    Key(
26        GenericSender<Option<String>>,
27        StorageType,
28        WebViewId,
29        ServoUrl,
30        u32,
31    ),
32
33    /// Gets the available keys in the associated storage data
34    Keys(GenericSender<Vec<String>>, StorageType, WebViewId, ServoUrl),
35
36    /// gets the value associated with the given key in the associated storage data
37    GetItem(
38        GenericSender<Option<String>>,
39        StorageType,
40        WebViewId,
41        ServoUrl,
42        String,
43    ),
44
45    /// sets the value of the given key in the associated storage data
46    SetItem(
47        GenericSender<Result<(bool, Option<String>), ()>>,
48        StorageType,
49        WebViewId,
50        ServoUrl,
51        String,
52        String,
53    ),
54
55    /// removes the key/value pair for the given key in the associated storage data
56    RemoveItem(
57        GenericSender<Option<String>>,
58        StorageType,
59        WebViewId,
60        ServoUrl,
61        String,
62    ),
63
64    /// clears the associated storage data by removing all the key/value pairs
65    Clear(GenericSender<bool>, StorageType, WebViewId, ServoUrl),
66
67    /// clones all storage data of the given top-level browsing context for a new browsing context.
68    /// should only be used for sessionStorage.
69    Clone {
70        sender: GenericSender<()>,
71        src: WebViewId,
72        dest: WebViewId,
73    },
74
75    /// send a reply when done cleaning up thread resources and then shut it down
76    Exit(GenericSender<()>),
77
78    /// Measure memory used by this thread and send the report over the provided channel.
79    CollectMemoryReport(ReportsChan),
80}