1 // Copyright (c) 2013 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.
5 #ifndef ANDROID_WEBVIEW_NATIVE_AW_QUOTA_MANAGER_BRIDGE_IMPL_H_
6 #define ANDROID_WEBVIEW_NATIVE_AW_QUOTA_MANAGER_BRIDGE_IMPL_H_
12 #include "android_webview/browser/aw_quota_manager_bridge.h"
13 #include "base/android/jni_weak_ref.h"
14 #include "base/basictypes.h"
15 #include "base/callback.h"
16 #include "base/memory/ref_counted.h"
17 #include "base/memory/weak_ptr.h"
18 #include "base/strings/string16.h"
23 class StoragePartition
;
28 } // namespace storage
30 namespace android_webview
{
32 class AwBrowserContext
;
34 class AwQuotaManagerBridgeImpl
: public AwQuotaManagerBridge
{
36 static scoped_refptr
<AwQuotaManagerBridge
> Create(
37 AwBrowserContext
* browser_context
);
40 void Init(JNIEnv
* env
, jobject object
);
41 void DeleteAllData(JNIEnv
* env
, jobject object
);
42 void DeleteOrigin(JNIEnv
* env
, jobject object
, jstring origin
);
43 void GetOrigins(JNIEnv
* env
, jobject object
, jint callback_id
);
44 void GetUsageAndQuotaForOrigin(JNIEnv
* env
,
50 typedef base::Callback
<
51 void(const std::vector
<std::string
>& /* origin */,
52 const std::vector
<int64
>& /* usage */,
53 const std::vector
<int64
>& /* quota */)> GetOriginsCallback
;
54 typedef base::Callback
<void(int64
/* usage */,
55 int64
/* quota */)> QuotaUsageCallback
;
58 explicit AwQuotaManagerBridgeImpl(AwBrowserContext
* browser_context
);
59 ~AwQuotaManagerBridgeImpl() override
;
61 content::StoragePartition
* GetStoragePartition() const;
63 storage::QuotaManager
* GetQuotaManager() const;
65 void DeleteAllDataOnUiThread();
66 void DeleteOriginOnUiThread(const base::string16
& origin
);
67 void GetOriginsOnUiThread(jint callback_id
);
68 void GetUsageAndQuotaForOriginOnUiThread(const base::string16
& origin
,
72 void GetOriginsCallbackImpl(
74 const std::vector
<std::string
>& origin
,
75 const std::vector
<int64
>& usage
,
76 const std::vector
<int64
>& quota
);
77 void QuotaUsageCallbackImpl(
78 int jcallback_id
, bool is_quota
, int64 usage
, int64 quota
);
80 AwBrowserContext
* browser_context_
;
81 JavaObjectWeakGlobalRef java_ref_
;
83 base::WeakPtrFactory
<AwQuotaManagerBridgeImpl
> weak_factory_
;
85 DISALLOW_COPY_AND_ASSIGN(AwQuotaManagerBridgeImpl
);
88 bool RegisterAwQuotaManagerBridge(JNIEnv
* env
);
90 } // namespace android_webview
92 #endif // ANDROID_WEBVIEW_NATIVE_AW_QUOTA_MANAGER_BRIDGE_IMPL_H_