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 : public RefCounted<WebStorageQuotaCallbacksPrivate> {
19 static PassRefPtr<WebStorageQuotaCallbacksPrivate> create(const PassOwnPtr<StorageQuotaCallbacks>& callbacks)
21 return adoptRef(new WebStorageQuotaCallbacksPrivate(callbacks));
24 StorageQuotaCallbacks* callbacks() { return m_callbacks.get(); }
27 WebStorageQuotaCallbacksPrivate(const PassOwnPtr<StorageQuotaCallbacks>& callbacks) : m_callbacks(callbacks) { }
28 OwnPtr<StorageQuotaCallbacks> m_callbacks;
31 WebStorageQuotaCallbacks::WebStorageQuotaCallbacks(const PassOwnPtr<StorageQuotaCallbacks>& callbacks)
33 m_private = WebStorageQuotaCallbacksPrivate::create(callbacks);
36 void WebStorageQuotaCallbacks::reset()
41 void WebStorageQuotaCallbacks::assign(const WebStorageQuotaCallbacks& other)
43 m_private = other.m_private;
46 void WebStorageQuotaCallbacks::didQueryStorageUsageAndQuota(unsigned long long usageInBytes, unsigned long long quotaInBytes)
48 ASSERT(!m_private.isNull());
49 m_private->callbacks()->didQueryStorageUsageAndQuota(usageInBytes, quotaInBytes);
53 void WebStorageQuotaCallbacks::didGrantStorageQuota(unsigned long long usageInBytes, unsigned long long grantedQuotaInBytes)
55 ASSERT(!m_private.isNull());
56 m_private->callbacks()->didGrantStorageQuota(usageInBytes, grantedQuotaInBytes);
60 void WebStorageQuotaCallbacks::didFail(WebStorageQuotaError error)
62 ASSERT(!m_private.isNull());
63 m_private->callbacks()->didFail(error);