OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef ANDROID_WEBVIEW_NATIVE_AW_QUOTA_MANAGER_BRIDGE_IMPL_H_ | 5 #ifndef ANDROID_WEBVIEW_NATIVE_AW_QUOTA_MANAGER_BRIDGE_IMPL_H_ |
6 #define ANDROID_WEBVIEW_NATIVE_AW_QUOTA_MANAGER_BRIDGE_IMPL_H_ | 6 #define ANDROID_WEBVIEW_NATIVE_AW_QUOTA_MANAGER_BRIDGE_IMPL_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "android_webview/browser/aw_quota_manager_bridge.h" | 12 #include "android_webview/browser/aw_quota_manager_bridge.h" |
13 #include "base/android/jni_helper.h" | 13 #include "base/android/jni_helper.h" |
14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
15 #include "base/callback.h" | 15 #include "base/callback.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/strings/string16.h" |
18 | 19 |
19 class GURL; | 20 class GURL; |
20 | 21 |
21 namespace content { | 22 namespace content { |
22 class StoragePartition; | 23 class StoragePartition; |
23 } | 24 } |
24 | 25 |
25 namespace quota { | 26 namespace quota { |
26 class QuotaManager; | 27 class QuotaManager; |
27 } // namespace quota | 28 } // namespace quota |
28 | 29 |
29 namespace android_webview { | 30 namespace android_webview { |
30 | 31 |
31 class AwBrowserContext; | 32 class AwBrowserContext; |
32 | 33 |
33 class AwQuotaManagerBridgeImpl : public AwQuotaManagerBridge { | 34 class AwQuotaManagerBridgeImpl : public AwQuotaManagerBridge { |
34 public: | 35 public: |
35 explicit AwQuotaManagerBridgeImpl(AwBrowserContext* browser_context); | 36 static scoped_refptr<AwQuotaManagerBridge> Create( |
36 virtual ~AwQuotaManagerBridgeImpl(); | 37 AwBrowserContext* browser_context); |
37 | 38 |
38 // Called by Java. | 39 // Called by Java. |
39 void Init(JNIEnv* env, jobject object); | 40 void Init(JNIEnv* env, jobject object); |
40 void DeleteAllData(JNIEnv* env, jobject object); | 41 void DeleteAllData(JNIEnv* env, jobject object); |
41 void DeleteOrigin(JNIEnv* env, jobject object, jstring origin); | 42 void DeleteOrigin(JNIEnv* env, jobject object, jstring origin); |
42 void GetOrigins(JNIEnv* env, jobject object, jint callback_id); | 43 void GetOrigins(JNIEnv* env, jobject object, jint callback_id); |
43 void GetUsageAndQuotaForOrigin(JNIEnv* env, | 44 void GetUsageAndQuotaForOrigin(JNIEnv* env, |
44 jobject object, | 45 jobject object, |
45 jstring origin, | 46 jstring origin, |
46 jint callback_id, | 47 jint callback_id, |
47 bool is_quota); | 48 bool is_quota); |
48 | 49 |
49 typedef base::Callback< | 50 typedef base::Callback< |
50 void(const std::vector<std::string>& /* origin */, | 51 void(const std::vector<std::string>& /* origin */, |
51 const std::vector<int64>& /* usage */, | 52 const std::vector<int64>& /* usage */, |
52 const std::vector<int64>& /* quota */)> GetOriginsCallback; | 53 const std::vector<int64>& /* quota */)> GetOriginsCallback; |
53 typedef base::Callback<void(int64 /* usage */, | 54 typedef base::Callback<void(int64 /* usage */, |
54 int64 /* quota */)> QuotaUsageCallback; | 55 int64 /* quota */)> QuotaUsageCallback; |
55 | 56 |
56 private: | 57 private: |
| 58 explicit AwQuotaManagerBridgeImpl(AwBrowserContext* browser_context); |
| 59 virtual ~AwQuotaManagerBridgeImpl(); |
| 60 |
57 content::StoragePartition* GetStoragePartition() const; | 61 content::StoragePartition* GetStoragePartition() const; |
58 | 62 |
59 quota::QuotaManager* GetQuotaManager() const; | 63 quota::QuotaManager* GetQuotaManager() const; |
60 | 64 |
| 65 void DeleteAllDataOnUiThread(); |
| 66 void DeleteOriginOnUiThread(const base::string16& origin); |
| 67 void GetOriginsOnUiThread(jint callback_id); |
| 68 void GetUsageAndQuotaForOriginOnUiThread(const base::string16& origin, |
| 69 jint callback_id, |
| 70 bool is_quota); |
| 71 |
61 void GetOriginsCallbackImpl( | 72 void GetOriginsCallbackImpl( |
62 int jcallback_id, | 73 int jcallback_id, |
63 const std::vector<std::string>& origin, | 74 const std::vector<std::string>& origin, |
64 const std::vector<int64>& usage, | 75 const std::vector<int64>& usage, |
65 const std::vector<int64>& quota); | 76 const std::vector<int64>& quota); |
66 void QuotaUsageCallbackImpl( | 77 void QuotaUsageCallbackImpl( |
67 int jcallback_id, bool is_quota, int64 usage, int64 quota); | 78 int jcallback_id, bool is_quota, int64 usage, int64 quota); |
68 | 79 |
69 base::WeakPtrFactory<AwQuotaManagerBridgeImpl> weak_factory_; | 80 base::WeakPtrFactory<AwQuotaManagerBridgeImpl> weak_factory_; |
70 AwBrowserContext* browser_context_; | 81 AwBrowserContext* browser_context_; |
71 JavaObjectWeakGlobalRef java_ref_; | 82 JavaObjectWeakGlobalRef java_ref_; |
72 | 83 |
73 DISALLOW_COPY_AND_ASSIGN(AwQuotaManagerBridgeImpl); | 84 DISALLOW_COPY_AND_ASSIGN(AwQuotaManagerBridgeImpl); |
74 }; | 85 }; |
75 | 86 |
76 bool RegisterAwQuotaManagerBridge(JNIEnv* env); | 87 bool RegisterAwQuotaManagerBridge(JNIEnv* env); |
77 | 88 |
78 } // namespace android_webview | 89 } // namespace android_webview |
79 | 90 |
80 #endif // ANDROID_WEBVIEW_NATIVE_AW_QUOTA_MANAGER_BRIDGE_IMPL_H_ | 91 #endif // ANDROID_WEBVIEW_NATIVE_AW_QUOTA_MANAGER_BRIDGE_IMPL_H_ |
OLD | NEW |