1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 #include "public/platform/WebStorageQuotaCallbacks.h"
8 #include "platform/StorageQuotaCallbacks.h"
9 #include "wtf/Forward.h"
10 #include "wtf/OwnPtr.h"
11 #include "wtf/PassOwnPtr.h"
12 #include "wtf/PassRefPtr.h"
13 #include "wtf/RefCounted.h"
17 class WebStorageQuotaCallbacksPrivate FINAL : public RefCountedWillBeGarbageCollected<WebStorageQuotaCallbacksPrivate> {
19 static PassRefPtrWillBeRawPtr<WebStorageQuotaCallbacksPrivate> create(const PassOwnPtrWillBeRawPtr<StorageQuotaCallbacks>& callbacks)
21 return adoptRefWillBeNoop(new WebStorageQuotaCallbacksPrivate(callbacks));
26 StorageQuotaCallbacks* callbacks() { return m_callbacks.get(); }
29 WebStorageQuotaCallbacksPrivate(const PassOwnPtrWillBeRawPtr<StorageQuotaCallbacks>& callbacks) : m_callbacks(callbacks) { }
30 OwnPtrWillBeMember<StorageQuotaCallbacks> m_callbacks;
33 void WebStorageQuotaCallbacksPrivate::trace(Visitor* visitor)
35 visitor->trace(m_callbacks);
38 WebStorageQuotaCallbacks::WebStorageQuotaCallbacks(const PassOwnPtrWillBeRawPtr<StorageQuotaCallbacks>& callbacks)
40 m_private = WebStorageQuotaCallbacksPrivate::create(callbacks);
43 void WebStorageQuotaCallbacks::reset()
48 void WebStorageQuotaCallbacks::assign(const WebStorageQuotaCallbacks& other)
50 m_private = other.m_private;
53 void WebStorageQuotaCallbacks::didQueryStorageUsageAndQuota(unsigned long long usageInBytes, unsigned long long quotaInBytes)
55 ASSERT(!m_private.isNull());
56 m_private->callbacks()->didQueryStorageUsageAndQuota(usageInBytes, quotaInBytes);
60 void WebStorageQuotaCallbacks::didGrantStorageQuota(unsigned long long usageInBytes, unsigned long long grantedQuotaInBytes)
62 ASSERT(!m_private.isNull());
63 m_private->callbacks()->didGrantStorageQuota(usageInBytes, grantedQuotaInBytes);
67 void WebStorageQuotaCallbacks::didFail(WebStorageQuotaError error)
69 ASSERT(!m_private.isNull());
70 m_private->callbacks()->didFail(error);