summaryrefslogtreecommitdiffstats
path: root/android_webview/native/aw_quota_manager_bridge_impl.h
diff options
context:
space:
mode:
authorboliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-22 18:53:04 +0000
committerboliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-22 18:53:04 +0000
commit2a3a0596a6a5d0703ff49df9d45fd57e9db96959 (patch)
tree77b52f512dd593a3c9a9a335c02c8c5065aadb37 /android_webview/native/aw_quota_manager_bridge_impl.h
parent6f356a88e6587d7d206f6327b0771e810609cf70 (diff)
downloadchromium_src-2a3a0596a6a5d0703ff49df9d45fd57e9db96959.zip
chromium_src-2a3a0596a6a5d0703ff49df9d45fd57e9db96959.tar.gz
chromium_src-2a3a0596a6a5d0703ff49df9d45fd57e9db96959.tar.bz2
Implement WebStorage API methods
Most of the methods involves calling methods to QuotaManager on the IO thread and translating the arguments between Java and native code. Introduce AwQuotaManagerBridge to facilitate this logic. The Java AwQuotaManagerBridge is currently a singleton but should be owned by AwBrowserContext when we have one. The native one is owned by native AwBrowserContext. Java calls the corresponding native AwBrowserContext to obtain the pointer. Introduced JniDependencyFactory interface used to create native objects under native but is used or passed in BrowserContext or ContentsBrowserClient. Also added base::android::ToJavaLongArray to convert to Java long arrays. BUG= Android only change. Ran through android bots. NOTRY=true Review URL: https://chromiumcodereview.appspot.com/12253057 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@184139 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview/native/aw_quota_manager_bridge_impl.h')
-rw-r--r--android_webview/native/aw_quota_manager_bridge_impl.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/android_webview/native/aw_quota_manager_bridge_impl.h b/android_webview/native/aw_quota_manager_bridge_impl.h
new file mode 100644
index 0000000..a776949
--- /dev/null
+++ b/android_webview/native/aw_quota_manager_bridge_impl.h
@@ -0,0 +1,74 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ANDROID_WEBVIEW_NATIVE_AW_QUOTA_MANAGER_BRIDGE_IMPL_H_
+#define ANDROID_WEBVIEW_NATIVE_AW_QUOTA_MANAGER_BRIDGE_IMPL_H_
+
+#include <jni.h>
+#include <string>
+#include <vector>
+
+#include "android_webview/browser/aw_quota_manager_bridge.h"
+#include "base/android/jni_helper.h"
+#include "base/basictypes.h"
+#include "base/callback.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
+
+class GURL;
+
+namespace quota {
+class QuotaManager;
+} // namespace quota
+
+namespace android_webview {
+
+class AwBrowserContext;
+
+class AwQuotaManagerBridgeImpl : public AwQuotaManagerBridge {
+ public:
+ explicit AwQuotaManagerBridgeImpl(AwBrowserContext* browser_context);
+ virtual ~AwQuotaManagerBridgeImpl();
+
+ // Called by Java.
+ void Init(JNIEnv* env, jobject object);
+ void DeleteAllData(JNIEnv* env, jobject object);
+ void DeleteOrigin(JNIEnv* env, jobject object, jstring origin);
+ void GetOrigins(JNIEnv* env, jobject object, jint callback_id);
+ void GetUsageAndQuotaForOrigin(JNIEnv* env,
+ jobject object,
+ jstring origin,
+ jint callback_id,
+ bool is_quota);
+
+ typedef base::Callback<
+ void(const std::vector<std::string>& /* origin */,
+ const std::vector<int64>& /* usage */,
+ const std::vector<int64>& /* quota */)> GetOriginsCallback;
+ typedef base::Callback<void(int64 /* usage */,
+ int64 /* quota */)> QuotaUsageCallback;
+
+ private:
+ quota::QuotaManager* GetQuotaManager() const;
+
+ void GetOriginsCallbackImpl(
+ int jcallback_id,
+ const std::vector<std::string>& origin,
+ const std::vector<int64>& usage,
+ const std::vector<int64>& quota);
+ void QuotaUsageCallbackImpl(
+ int jcallback_id, bool is_quota, int64 usage, int64 quota);
+
+ base::WeakPtrFactory<AwQuotaManagerBridgeImpl> weak_factory_;
+ AwBrowserContext* browser_context_;
+ JavaObjectWeakGlobalRef java_ref_;
+
+ DISALLOW_COPY_AND_ASSIGN(AwQuotaManagerBridgeImpl);
+};
+
+bool RegisterAwQuotaManagerBridge(JNIEnv* env);
+
+} // namespace android_webview
+
+#endif // ANDROID_WEBVIEW_NATIVE_AW_QUOTA_MANAGER_BRIDGE_IMPL_H_