Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: Source/modules/quota/StorageQuota.cpp

Issue 20262003: Use Platform::queryUsageAndQuota and deprecate WebFrameClient::queryUsageAndQuota (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 11 matching lines...) Expand all
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "modules/quota/StorageQuota.h"
32 33
33 #include "modules/quota/StorageQuota.h" 34 #include "core/dom/ExceptionCode.h"
35 #include "core/dom/ScriptExecutionContext.h"
36 #include "modules/quota/StorageErrorCallback.h"
37 #include "modules/quota/StorageUsageCallback.h"
38 #include "modules/quota/WebStorageQuotaCallbacksImpl.h"
39 #include "public/platform/Platform.h"
40 #include "public/platform/WebStorageQuotaCallbacks.h"
41 #include "public/platform/WebStorageQuotaType.h"
42 #include "weborigin/KURL.h"
43 #include "weborigin/SecurityOrigin.h"
34 44
35 namespace WebCore { 45 namespace WebCore {
36 46
37 StorageQuota::StorageQuota(Type type) 47 StorageQuota::StorageQuota(Type type)
38 : m_type(type) 48 : m_type(type)
39 { 49 {
40 ScriptWrappable::init(this); 50 ScriptWrappable::init(this);
41 } 51 }
42 52
53 void StorageQuota::queryUsageAndQuota(ScriptExecutionContext* scriptExecutionCon text, PassRefPtr<StorageUsageCallback> successCallback, PassRefPtr<StorageErrorC allback> errorCallback)
54 {
55 ASSERT(scriptExecutionContext);
56
57 WebKit::WebStorageQuotaType storageType = static_cast<WebKit::WebStorageQuot aType>(m_type);
58 if (storageType != WebKit::WebStorageQuotaTypeTemporary && storageType != We bKit::WebStorageQuotaTypePersistent) {
59 // Unknown storage type is requested.
60 scriptExecutionContext->postTask(StorageErrorCallback::CallbackTask::cre ate(errorCallback, NotSupportedError));
61 return;
62 }
63
64 SecurityOrigin* securityOrigin = scriptExecutionContext->securityOrigin();
65 if (securityOrigin->isUnique()) {
66 scriptExecutionContext->postTask(StorageErrorCallback::CallbackTask::cre ate(errorCallback, NotSupportedError));
67 return;
68 }
69
70 KURL storagePartition = KURL(KURL(), securityOrigin->toString());
71 WebKit::Platform::current()->queryStorageUsageAndQuota(storagePartition, sto rageType, WebStorageQuotaCallbacksImpl::createLeakedPtr(successCallback, errorCa llback));
72 }
73
43 StorageQuota::~StorageQuota() 74 StorageQuota::~StorageQuota()
44 { 75 {
45 } 76 }
46 77
47 } // namespace WebCore 78 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698