Commit 84869dc2 authored by Tim Judkins's avatar Tim Judkins Committed by Commit Bot

[Extensions] Enable promise support on the storage API

This CL changes over the json schema to use the new returns_async format
to define callbacks, enabling promise support on those APIs.

Bug: 328932
Change-Id: I6b93bf1977582ff5a104820728ad891bd2a329e5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2514965Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Commit-Queue: Tim Judkins <tjudkins@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826845}
parent bb858b6d
...@@ -51,21 +51,20 @@ ...@@ -51,21 +51,20 @@
], ],
"description": "A single key to get, list of keys to get, or a dictionary specifying default values (see description of the object). An empty list or object will return an empty result object. Pass in <code>null</code> to get the entire contents of storage.", "description": "A single key to get, list of keys to get, or a dictionary specifying default values (see description of the object). An empty list or object will return an empty result object. Pass in <code>null</code> to get the entire contents of storage.",
"optional": true "optional": true
},
{
"name": "callback",
"type": "function",
"description": "Callback with storage items, or on failure (in which case $(ref:runtime.lastError) will be set).",
"parameters": [
{
"name": "items",
"type": "object",
"additionalProperties": { "type": "any" },
"description": "Object with items in their key-value mappings."
}
]
} }
] ],
"returns_async": {
"name": "callback",
"description": "Callback with storage items, or on failure (in which case $(ref:runtime.lastError) will be set).",
"parameters": [
{
"name": "items",
"type": "object",
"additionalProperties": { "type": "any" },
"description": "Object with items in their key-value mappings."
}
]
}
}, },
{ {
"name": "getBytesInUse", "name": "getBytesInUse",
...@@ -80,20 +79,19 @@ ...@@ -80,20 +79,19 @@
], ],
"description": "A single key or list of keys to get the total usage for. An empty list will return 0. Pass in <code>null</code> to get the total usage of all of storage.", "description": "A single key or list of keys to get the total usage for. An empty list will return 0. Pass in <code>null</code> to get the total usage of all of storage.",
"optional": true "optional": true
},
{
"name": "callback",
"type": "function",
"description": "Callback with the amount of space being used by storage, or on failure (in which case $(ref:runtime.lastError) will be set).",
"parameters": [
{
"name": "bytesInUse",
"type": "integer",
"description": "Amount of space being used in storage, in bytes."
}
]
} }
] ],
"returns_async": {
"name": "callback",
"description": "Callback with the amount of space being used by storage, or on failure (in which case $(ref:runtime.lastError) will be set).",
"parameters": [
{
"name": "bytesInUse",
"type": "integer",
"description": "Amount of space being used in storage, in bytes."
}
]
}
}, },
{ {
"name": "set", "name": "set",
...@@ -106,15 +104,14 @@ ...@@ -106,15 +104,14 @@
"additionalProperties": { "type": "any", "preserveNull": true }, "additionalProperties": { "type": "any", "preserveNull": true },
"preserveNull": true, "preserveNull": true,
"description": "<p>An object which gives each key/value pair to update storage with. Any other key/value pairs in storage will not be affected.</p><p>Primitive values such as numbers will serialize as expected. Values with a <code>typeof</code> <code>\"object\"</code> and <code>\"function\"</code> will typically serialize to <code>{}</code>, with the exception of <code>Array</code> (serializes as expected), <code>Date</code>, and <code>Regex</code> (serialize using their <code>String</code> representation).</p>" "description": "<p>An object which gives each key/value pair to update storage with. Any other key/value pairs in storage will not be affected.</p><p>Primitive values such as numbers will serialize as expected. Values with a <code>typeof</code> <code>\"object\"</code> and <code>\"function\"</code> will typically serialize to <code>{}</code>, with the exception of <code>Array</code> (serializes as expected), <code>Date</code>, and <code>Regex</code> (serialize using their <code>String</code> representation).</p>"
},
{
"name": "callback",
"type": "function",
"description": "Callback on success, or on failure (in which case $(ref:runtime.lastError) will be set).",
"parameters": [],
"optional": true
} }
] ],
"returns_async": {
"name": "callback",
"description": "Callback on success, or on failure (in which case $(ref:runtime.lastError) will be set).",
"parameters": [],
"optional": true
}
}, },
{ {
"name": "remove", "name": "remove",
...@@ -128,29 +125,26 @@ ...@@ -128,29 +125,26 @@
{"type": "array", "items": {"type": "string"}} {"type": "array", "items": {"type": "string"}}
], ],
"description": "A single key or a list of keys for items to remove." "description": "A single key or a list of keys for items to remove."
},
{
"name": "callback",
"type": "function",
"description": "Callback on success, or on failure (in which case $(ref:runtime.lastError) will be set).",
"parameters": [],
"optional": true
} }
] ],
"returns_async": {
"name": "callback",
"description": "Callback on success, or on failure (in which case $(ref:runtime.lastError) will be set).",
"parameters": [],
"optional": true
}
}, },
{ {
"name": "clear", "name": "clear",
"type": "function", "type": "function",
"description": "Removes all items from storage.", "description": "Removes all items from storage.",
"parameters": [ "parameters": [],
{ "returns_async": {
"name": "callback", "name": "callback",
"type": "function", "description": "Callback on success, or on failure (in which case $(ref:runtime.lastError) will be set).",
"description": "Callback on success, or on failure (in which case $(ref:runtime.lastError) will be set).", "parameters": [],
"parameters": [], "optional": true
"optional": true }
}
]
} }
], ],
"events": [ "events": [
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment