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_NATIVE_AW_QUOTA_MANAGER_BRIDGE_IMPL_H_ |
| 6 #define ANDROID_WEBVIEW_NATIVE_AW_QUOTA_MANAGER_BRIDGE_IMPL_H_ |
| 7 |
| 8 #include <jni.h> |
| 9 #include <string> |
| 10 #include <vector> |
| 11 |
| 12 #include "android_webview/browser/aw_quota_manager_bridge.h" |
| 13 #include "base/android/jni_helper.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 |
| 19 class GURL; |
| 20 |
| 21 namespace quota { |
| 22 class QuotaManager; |
| 23 } // namespace quota |
| 24 |
| 25 namespace android_webview { |
| 26 |
| 27 class AwBrowserContext; |
| 28 |
| 29 class AwQuotaManagerBridgeImpl : public AwQuotaManagerBridge { |
| 30 public: |
| 31 explicit AwQuotaManagerBridgeImpl(AwBrowserContext* browser_context); |
| 32 virtual ~AwQuotaManagerBridgeImpl(); |
| 33 |
| 34 // Called by Java. |
| 35 void Init(JNIEnv* env, jobject object); |
| 36 void DeleteAllData(JNIEnv* env, jobject object); |
| 37 void DeleteOrigin(JNIEnv* env, jobject object, jstring origin); |
| 38 void GetOrigins(JNIEnv* env, jobject object, jint callback_id); |
| 39 void GetUsageAndQuotaForOrigin(JNIEnv* env, |
| 40 jobject object, |
| 41 jstring origin, |
| 42 jint callback_id, |
| 43 bool is_quota); |
| 44 |
| 45 typedef base::Callback< |
| 46 void(const std::vector<std::string>& /* origin */, |
| 47 const std::vector<int64>& /* usage */, |
| 48 const std::vector<int64>& /* quota */)> GetOriginsCallback; |
| 49 typedef base::Callback<void(int64 /* usage */, |
| 50 int64 /* quota */)> QuotaUsageCallback; |
| 51 |
| 52 private: |
| 53 quota::QuotaManager* GetQuotaManager() const; |
| 54 |
| 55 void GetOriginsCallbackImpl( |
| 56 int jcallback_id, |
| 57 const std::vector<std::string>& origin, |
| 58 const std::vector<int64>& usage, |
| 59 const std::vector<int64>& quota); |
| 60 void QuotaUsageCallbackImpl( |
| 61 int jcallback_id, bool is_quota, int64 usage, int64 quota); |
| 62 |
| 63 base::WeakPtrFactory<AwQuotaManagerBridgeImpl> weak_factory_; |
| 64 AwBrowserContext* browser_context_; |
| 65 JavaObjectWeakGlobalRef java_ref_; |
| 66 |
| 67 DISALLOW_COPY_AND_ASSIGN(AwQuotaManagerBridgeImpl); |
| 68 }; |
| 69 |
| 70 bool RegisterAwQuotaManagerBridge(JNIEnv* env); |
| 71 |
| 72 } // namespace android_webview |
| 73 |
| 74 #endif // ANDROID_WEBVIEW_NATIVE_AW_QUOTA_MANAGER_BRIDGE_IMPL_H_ |
OLD | NEW |