Commit 57115fe5 authored by jsbell's avatar jsbell Committed by Commit bot

Quota: StorageInfo should be a dictionary

BUG=674542
R=foolip@chromium.org

Review-Url: https://codereview.chromium.org/2585563002
Cr-Commit-Position: refs/heads/master@{#439018}
parent 3cbfdb12
...@@ -4,9 +4,11 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE ...@@ -4,9 +4,11 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
* Querying about temporary storage. * Querying about temporary storage.
PASS info.__proto__ is Object.prototype
PASS usage is >= 0 PASS usage is >= 0
PASS quota is >= usage PASS quota is >= usage
* Querying about persistent storage. * Querying about persistent storage.
PASS info.__proto__ is Object.prototype
PASS usage is >= 0 PASS usage is >= 0
PASS quota is >= usage PASS quota is >= usage
* Querying about unknown storage. * Querying about unknown storage.
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
<script type="text/javascript"> <script type="text/javascript">
description("This tests navigator.storageQuota.queryInfo."); description("This tests navigator.storageQuota.queryInfo.");
var info;
var usage; var usage;
var quota; var quota;
...@@ -19,6 +20,9 @@ function onrejected(error) { ...@@ -19,6 +20,9 @@ function onrejected(error) {
function runQueryTemporaryTest() { function runQueryTemporaryTest() {
debug("* Querying about temporary storage."); debug("* Querying about temporary storage.");
navigator.storageQuota.queryInfo("temporary").then(function(storageInfo) { navigator.storageQuota.queryInfo("temporary").then(function(storageInfo) {
info = storageInfo;
shouldBe("info.__proto__", "Object.prototype");
usage = storageInfo.usage; usage = storageInfo.usage;
quota = storageInfo.quota; quota = storageInfo.quota;
...@@ -33,6 +37,9 @@ function runQueryTemporaryTest() { ...@@ -33,6 +37,9 @@ function runQueryTemporaryTest() {
function runQueryPersistentTest() { function runQueryPersistentTest() {
debug("* Querying about persistent storage."); debug("* Querying about persistent storage.");
navigator.storageQuota.queryInfo("persistent").then(function(storageInfo) { navigator.storageQuota.queryInfo("persistent").then(function(storageInfo) {
info = storageInfo;
shouldBe("info.__proto__", "Object.prototype");
usage = storageInfo.usage; usage = storageInfo.usage;
quota = storageInfo.quota; quota = storageInfo.quota;
......
...@@ -4,11 +4,13 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE ...@@ -4,11 +4,13 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
* Requesting persistent quota. * Requesting persistent quota.
PASS info.__proto__ is Object.prototype
PASS usage is >= 0 PASS usage is >= 0
PASS grantedQuota is non-zero. PASS grantedQuota is non-zero.
* Requesting persistent quota with missing argument. * Requesting persistent quota with missing argument.
PASS rejected as expected: TypeError: Failed to execute 'requestPersistentQuota' on 'StorageQuota': 1 argument required, but only 0 present. PASS rejected as expected: TypeError: Failed to execute 'requestPersistentQuota' on 'StorageQuota': 1 argument required, but only 0 present.
* Requesting persistent quota with negative value. * Requesting persistent quota with negative value.
PASS info.__proto__ is Object.prototype
PASS usage is >= 0 PASS usage is >= 0
PASS grantedQuota is 0 PASS grantedQuota is 0
Finished running tests. Finished running tests.
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
<script type="text/javascript"> <script type="text/javascript">
description("This tests navigator.storageQuota.requestPersistentQuota."); description("This tests navigator.storageQuota.requestPersistentQuota.");
var info;
var usage; var usage;
var grantedQuota; var grantedQuota;
...@@ -19,6 +20,10 @@ function onrejected(error) { ...@@ -19,6 +20,10 @@ function onrejected(error) {
function runRequestQuotaTest() { function runRequestQuotaTest() {
debug("* Requesting persistent quota."); debug("* Requesting persistent quota.");
navigator.storageQuota.requestPersistentQuota(1024).then(function(storageInfo) { navigator.storageQuota.requestPersistentQuota(1024).then(function(storageInfo) {
info = storageInfo;
shouldBe("info.__proto__", "Object.prototype");
usage = storageInfo.usage; usage = storageInfo.usage;
grantedQuota = storageInfo.quota; grantedQuota = storageInfo.quota;
...@@ -42,6 +47,9 @@ function runRequestQuotaWithMisingArgumentTest() { ...@@ -42,6 +47,9 @@ function runRequestQuotaWithMisingArgumentTest() {
function runRequestQuotaWithNegativeValueTest() { function runRequestQuotaWithNegativeValueTest() {
debug("* Requesting persistent quota with negative value."); debug("* Requesting persistent quota with negative value.");
navigator.storageQuota.requestPersistentQuota(-1024).then(function(storageInfo) { navigator.storageQuota.requestPersistentQuota(-1024).then(function(storageInfo) {
info = storageInfo;
shouldBe("info.__proto__", "Object.prototype");
usage = storageInfo.usage; usage = storageInfo.usage;
grantedQuota = storageInfo.quota; grantedQuota = storageInfo.quota;
......
...@@ -213,7 +213,6 @@ modules_idl_files = ...@@ -213,7 +213,6 @@ modules_idl_files =
"quota/DeprecatedStorageInfo.idl", "quota/DeprecatedStorageInfo.idl",
"quota/DeprecatedStorageQuota.idl", "quota/DeprecatedStorageQuota.idl",
"quota/StorageErrorCallback.idl", "quota/StorageErrorCallback.idl",
"quota/StorageInfo.idl",
"quota/StorageManager.idl", "quota/StorageManager.idl",
"quota/StorageQuota.idl", "quota/StorageQuota.idl",
"quota/StorageQuotaCallback.idl", "quota/StorageQuotaCallback.idl",
...@@ -476,6 +475,7 @@ modules_dictionary_idl_files = ...@@ -476,6 +475,7 @@ modules_dictionary_idl_files =
"push_messaging/PushEventInit.idl", "push_messaging/PushEventInit.idl",
"push_messaging/PushSubscriptionOptionsInit.idl", "push_messaging/PushSubscriptionOptionsInit.idl",
"quota/StorageEstimate.idl", "quota/StorageEstimate.idl",
"quota/StorageInfo.idl",
"sensor/AccelerometerOptions.idl", "sensor/AccelerometerOptions.idl",
"sensor/AccelerometerReadingInit.idl", "sensor/AccelerometerReadingInit.idl",
"sensor/GyroscopeReadingInit.idl", "sensor/GyroscopeReadingInit.idl",
...@@ -837,6 +837,8 @@ generated_modules_dictionary_files = [ ...@@ -837,6 +837,8 @@ generated_modules_dictionary_files = [
"$blink_modules_output_dir/push_messaging/PushSubscriptionOptionsInit.h", "$blink_modules_output_dir/push_messaging/PushSubscriptionOptionsInit.h",
"$blink_modules_output_dir/quota/StorageEstimate.cpp", "$blink_modules_output_dir/quota/StorageEstimate.cpp",
"$blink_modules_output_dir/quota/StorageEstimate.h", "$blink_modules_output_dir/quota/StorageEstimate.h",
"$blink_modules_output_dir/quota/StorageInfo.cpp",
"$blink_modules_output_dir/quota/StorageInfo.h",
"$blink_modules_output_dir/sensor/AccelerometerOptions.cpp", "$blink_modules_output_dir/sensor/AccelerometerOptions.cpp",
"$blink_modules_output_dir/sensor/AccelerometerOptions.h", "$blink_modules_output_dir/sensor/AccelerometerOptions.h",
"$blink_modules_output_dir/sensor/AccelerometerReadingInit.cpp", "$blink_modules_output_dir/sensor/AccelerometerReadingInit.cpp",
......
...@@ -20,8 +20,6 @@ blink_modules_sources("quota") { ...@@ -20,8 +20,6 @@ blink_modules_sources("quota") {
"NavigatorStorageQuota.h", "NavigatorStorageQuota.h",
"StorageErrorCallback.cpp", "StorageErrorCallback.cpp",
"StorageErrorCallback.h", "StorageErrorCallback.h",
"StorageInfo.cpp",
"StorageInfo.h",
"StorageManager.cpp", "StorageManager.cpp",
"StorageManager.h", "StorageManager.h",
"StorageQuota.cpp", "StorageQuota.cpp",
......
/*
* Copyright (C) 2014 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "modules/quota/StorageInfo.h"
namespace blink {
StorageInfo::StorageInfo(unsigned long long usage, unsigned long long quota)
: m_usage(usage), m_quota(quota) {}
} // namespace blink
/*
* Copyright (C) 2014 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef StorageInfo_h
#define StorageInfo_h
#include "bindings/core/v8/ScriptWrappable.h"
#include "platform/heap/Handle.h"
namespace blink {
class StorageInfo final : public GarbageCollected<StorageInfo>,
public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
public:
static StorageInfo* create(unsigned long long usage,
unsigned long long quota) {
return new StorageInfo(usage, quota);
}
unsigned long long usage() const { return m_usage; }
unsigned long long quota() const { return m_quota; }
DEFINE_INLINE_TRACE() {}
private:
StorageInfo(unsigned long long usage, unsigned long long quota);
unsigned long long m_usage;
unsigned long long m_quota;
};
} // namespace blink
#endif // StorageInfo_h
...@@ -28,10 +28,7 @@ ...@@ -28,10 +28,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
[ dictionary StorageInfo {
NoInterfaceObject, unsigned long long usage;
RuntimeEnabled=QuotaPromise unsigned long long quota;
] interface StorageInfo {
readonly attribute unsigned long long usage;
readonly attribute unsigned long long quota;
}; };
...@@ -44,13 +44,19 @@ StorageQuotaCallbacksImpl::~StorageQuotaCallbacksImpl() {} ...@@ -44,13 +44,19 @@ StorageQuotaCallbacksImpl::~StorageQuotaCallbacksImpl() {}
void StorageQuotaCallbacksImpl::didQueryStorageUsageAndQuota( void StorageQuotaCallbacksImpl::didQueryStorageUsageAndQuota(
unsigned long long usageInBytes, unsigned long long usageInBytes,
unsigned long long quotaInBytes) { unsigned long long quotaInBytes) {
m_resolver->resolve(StorageInfo::create(usageInBytes, quotaInBytes)); StorageInfo info;
info.setUsage(usageInBytes);
info.setQuota(quotaInBytes);
m_resolver->resolve(info);
} }
void StorageQuotaCallbacksImpl::didGrantStorageQuota( void StorageQuotaCallbacksImpl::didGrantStorageQuota(
unsigned long long usageInBytes, unsigned long long usageInBytes,
unsigned long long grantedQuotaInBytes) { unsigned long long grantedQuotaInBytes) {
m_resolver->resolve(StorageInfo::create(usageInBytes, grantedQuotaInBytes)); StorageInfo info;
info.setUsage(usageInBytes);
info.setQuota(grantedQuotaInBytes);
m_resolver->resolve(info);
} }
void StorageQuotaCallbacksImpl::didFail(WebStorageQuotaError error) { void StorageQuotaCallbacksImpl::didFail(WebStorageQuotaError error) {
......
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