| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef ANDROID_WEBVIEW_BROWSER_AW_QUOTA_MANAGER_BRIDGE_IMPL_H_ | |
| 6 #define ANDROID_WEBVIEW_BROWSER_AW_QUOTA_MANAGER_BRIDGE_IMPL_H_ | |
| 7 | |
| 8 #include <jni.h> | |
| 9 #include <stdint.h> | |
| 10 | |
| 11 #include <string> | |
| 12 #include <vector> | |
| 13 | |
| 14 #include "android_webview/browser/aw_quota_manager_bridge.h" | |
| 15 #include "base/android/jni_weak_ref.h" | |
| 16 #include "base/callback.h" | |
| 17 #include "base/macros.h" | |
| 18 #include "base/memory/ref_counted.h" | |
| 19 #include "base/memory/weak_ptr.h" | |
| 20 #include "base/strings/string16.h" | |
| 21 | |
| 22 namespace content { | |
| 23 class StoragePartition; | |
| 24 } | |
| 25 | |
| 26 namespace storage { | |
| 27 class QuotaManager; | |
| 28 } // namespace storage | |
| 29 | |
| 30 namespace android_webview { | |
| 31 | |
| 32 class AwBrowserContext; | |
| 33 | |
| 34 class AwQuotaManagerBridgeImpl : public AwQuotaManagerBridge { | |
| 35 public: | |
| 36 static scoped_refptr<AwQuotaManagerBridge> Create( | |
| 37 AwBrowserContext* browser_context); | |
| 38 | |
| 39 // Called by Java. | |
| 40 void Init(JNIEnv* env, const base::android::JavaParamRef<jobject>& object); | |
| 41 void DeleteAllData(JNIEnv* env, | |
| 42 const base::android::JavaParamRef<jobject>& object); | |
| 43 void DeleteOrigin(JNIEnv* env, | |
| 44 const base::android::JavaParamRef<jobject>& object, | |
| 45 const base::android::JavaParamRef<jstring>& origin); | |
| 46 void GetOrigins(JNIEnv* env, | |
| 47 const base::android::JavaParamRef<jobject>& object, | |
| 48 jint callback_id); | |
| 49 void GetUsageAndQuotaForOrigin( | |
| 50 JNIEnv* env, | |
| 51 const base::android::JavaParamRef<jobject>& object, | |
| 52 const base::android::JavaParamRef<jstring>& origin, | |
| 53 jint callback_id, | |
| 54 bool is_quota); | |
| 55 | |
| 56 typedef base::Callback<void(const std::vector<std::string>& /* origin */, | |
| 57 const std::vector<int64_t>& /* usage */, | |
| 58 const std::vector<int64_t>& /* quota */)> | |
| 59 GetOriginsCallback; | |
| 60 typedef base::Callback<void(int64_t /* usage */, int64_t /* quota */)> | |
| 61 QuotaUsageCallback; | |
| 62 | |
| 63 private: | |
| 64 explicit AwQuotaManagerBridgeImpl(AwBrowserContext* browser_context); | |
| 65 ~AwQuotaManagerBridgeImpl() override; | |
| 66 | |
| 67 content::StoragePartition* GetStoragePartition() const; | |
| 68 | |
| 69 storage::QuotaManager* GetQuotaManager() const; | |
| 70 | |
| 71 void DeleteAllDataOnUiThread(); | |
| 72 void DeleteOriginOnUiThread(const base::string16& origin); | |
| 73 void GetOriginsOnUiThread(jint callback_id); | |
| 74 void GetUsageAndQuotaForOriginOnUiThread(const base::string16& origin, | |
| 75 jint callback_id, | |
| 76 bool is_quota); | |
| 77 | |
| 78 void GetOriginsCallbackImpl(int jcallback_id, | |
| 79 const std::vector<std::string>& origin, | |
| 80 const std::vector<int64_t>& usage, | |
| 81 const std::vector<int64_t>& quota); | |
| 82 void QuotaUsageCallbackImpl(int jcallback_id, | |
| 83 bool is_quota, | |
| 84 int64_t usage, | |
| 85 int64_t quota); | |
| 86 | |
| 87 AwBrowserContext* browser_context_; | |
| 88 JavaObjectWeakGlobalRef java_ref_; | |
| 89 | |
| 90 base::WeakPtrFactory<AwQuotaManagerBridgeImpl> weak_factory_; | |
| 91 | |
| 92 DISALLOW_COPY_AND_ASSIGN(AwQuotaManagerBridgeImpl); | |
| 93 }; | |
| 94 | |
| 95 bool RegisterAwQuotaManagerBridge(JNIEnv* env); | |
| 96 | |
| 97 } // namespace android_webview | |
| 98 | |
| 99 #endif // ANDROID_WEBVIEW_BROWSER_AW_QUOTA_MANAGER_BRIDGE_IMPL_H_ | |
| OLD | NEW |