summaryrefslogtreecommitdiffstats
path: root/dom/localstorage/PBackgroundLSSnapshot.ipdl
blob: 45c744c840cc970940eccda2fee914c99d33fd2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/* 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/. */

include protocol PBackground;
include protocol PBackgroundLSDatabase;

include PBackgroundLSSharedTypes;

include "mozilla/dom/localstorage/SerializationHelpers.h";

using mozilla::dom::LSValue
  from "mozilla/dom/LSValue.h";

namespace mozilla {
namespace dom {

struct LSSetItemInfo
{
  nsString key;
  LSValue value;
};

struct LSRemoveItemInfo
{
  nsString key;
};

struct LSClearInfo
{
};

/**
 * Union of LocalStorage mutation types.
 */
union LSWriteInfo
{
  LSSetItemInfo;
  LSRemoveItemInfo;
  LSClearInfo;
};

struct LSSetItemAndNotifyInfo
{
  nsString key;
  LSValue oldValue;
  LSValue value;
};

struct LSRemoveItemAndNotifyInfo
{
  nsString key;
  LSValue oldValue;
};

/**
 * Union of LocalStorage mutation types.
 */
union LSWriteAndNotifyInfo
{
  LSSetItemAndNotifyInfo;
  LSRemoveItemAndNotifyInfo;
  LSClearInfo;
};

[ManualDealloc, ChildImpl=virtual, ParentImpl=virtual]
sync protocol PBackgroundLSSnapshot
{
  manager PBackgroundLSDatabase;

parent:
  async DeleteMe();

  async AsyncCheckpoint(LSWriteInfo[] writeInfos);

  async AsyncCheckpointAndNotify(LSWriteAndNotifyInfo[] writeAndNotifyInfos);

  // A synchronous checkpoint. This should only be used by the snapshotting code
  // to checkpoint an explicit snapshot.
  sync SyncCheckpoint(LSWriteInfo[] writeInfos);

  // A synchronous checkpoint and notify. This should only be used by the
  // snapshotting code to checkpoint and notify an explicit snapshot.
  sync SyncCheckpointAndNotify(LSWriteAndNotifyInfo[] writeAndNotifyInfos);

  async AsyncFinish();

  // A synchronous finish. This should only be used by the snapshotting code to
  // end an explicit snapshot.
  sync SyncFinish();

  async Loaded();

  /**
   * Invoked on demand to load an item that didn't fit into the initial
   * snapshot prefill and also some additional key/value pairs to lower down
   * the need to use this synchronous message again.
   *
   * This needs to be synchronous because LocalStorage's semantics are
   * synchronous.  Note that the Snapshot in the PBackground parent already
   * has the answers to this request immediately available without needing to
   * consult any other threads or perform any I/O.
   */
  sync LoadValueAndMoreItems(nsString key)
    returns (LSValue value, LSItemInfo[] itemInfos);

  /**
   * Invoked on demand to load all keys in in their canonical order if they
   * didn't fit into the initial snapshot prefill.
   *
   * This needs to be synchronous because LocalStorage's semantics are
   * synchronous.  Note that the Snapshot in the PBackground parent already
   * has the answers to this request immediately available without needing to
   * consult any other threads or perform any I/O.
   */
  sync LoadKeys()
    returns (nsString[] keys);

  /**
   * This needs to be synchronous because LocalStorage's semantics are
   * synchronous.  Note that the Snapshot in the PBackground parent typically
   * doesn't need to consult any other threads or perform any I/O to handle
   * this request.  However, it has to call a quota manager method that can
   * potentially do I/O directly on the PBackground thread.  It can only happen
   * rarely in a storage pressure (low storage space) situation.  Specifically,
   * after we get a list of origin directories for eviction, we will delete
   * them directly on the PBackground thread.  This doesn't cause any
   * performance problems, but avoiding I/O completely might need to be done as
   * a futher optimization.
   */
  sync IncreasePeakUsage(int64_t minSize)
    returns (int64_t size);

child:
  /**
   * Compels the child LSSnapshot to Checkpoint() and Finish(), effectively
   * compelling the snapshot to flush any issued mutations and close itself.
   * The child LSSnapshot does that either immediately if it's just waiting
   * to be reused or when it gets into a stable state.
   *
   * This message is expected to be sent in the following two cases only:
   *   1. The state of the underlying Datastore starts to differ from the state
   *      captured at the time of snapshot creation.
   *   2. The last private browsing context exits.  And in that case we expect
   *      all private browsing globals to already have been destroyed.
   */
  async MarkDirty();

  async __delete__();
};

} // namespace dom
} // namespace mozilla