Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2426)

Unified Diff: android_webview/native/aw_quota_manager_bridge.h

Issue 12253057: Implement WebStorage API methods (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Implementation mostly done. Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: android_webview/native/aw_quota_manager_bridge.h
diff --git a/android_webview/native/aw_quota_manager_bridge.h b/android_webview/native/aw_quota_manager_bridge.h
new file mode 100644
index 0000000000000000000000000000000000000000..d83161e3b964fa0ef68f282a8a8fefce5fe146b3
--- /dev/null
+++ b/android_webview/native/aw_quota_manager_bridge.h
@@ -0,0 +1,112 @@
+// 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_H_
+#define ANDROID_WEBVIEW_NATIVE_AW_QUOTA_MANAGER_BRIDGE_H_
+
+#include <jni.h>
+#include <set>
+#include <vector>
+#include <string>
+
+#include "base/android/jni_helper.h"
+#include "base/basictypes.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
+#include "webkit/quota/quota_types.h"
+
+class GURL;
+
+namespace content {
+class StoragePartition;
+}
+
+namespace quota {
+class QuotaManager;
+} // namespace quota
+
+namespace android_webview {
+
+class AwBrowserContext;
+class AwQuotaManagerBridge;
+
+namespace internal {
+
+class IOThreadSwitcher : public base::RefCountedThreadSafe<IOThreadSwitcher> {
mkosiba (inactive) 2013/02/19 11:37:13 this is a bit nasty. I get that you need to spill
boliu 2013/02/19 17:03:21 Me and my micro/premature optimizations. I though
boliu 2013/02/20 00:53:50 Through the magic of base::Bind, this class is gon
+ public:
+ IOThreadSwitcher(const base::WeakPtr<AwQuotaManagerBridge>& bridge);
mkosiba (inactive) 2013/02/19 11:37:13 to be honest I think this class and the other swit
boliu 2013/02/19 17:03:21 Just found base::PostTaskAndReplyWithResult. There
+
+ void DeleteAllDataOnIOThread();
mkosiba (inactive) 2013/02/19 11:37:13 Looks like all of the methods are OnIOThread, mayb
+ void DeleteOriginOnIOThread(const GURL& origin);
+ void GetQuotaForOriginOnIOThread(const GURL& origin, int jcallback_id);
+ void GetUsageForOriginOnIOThread(const GURL& origin, int jcallback_id);
+
+ private:
+ friend class base::RefCountedThreadSafe<IOThreadSwitcher>;
+ ~IOThreadSwitcher();
+
+ void DeleteOrigins(const std::set<GURL>& origins, quota::StorageType type);
+
+ void GetQuotaForOriginCallback(int jcallback_id,
+ quota::QuotaStatusCode status_code,
+ int64 usage,
+ int64 quota);
+ void GetUsageForOriginCallback(int jcallback_id,
+ quota::QuotaStatusCode status_code,
+ int64 usage,
+ int64 quota);
+
+ void GetQuotaForOriginCallbackOnUiThread(int jcallback_id, int64 quota);
+ void GetUsageForOriginCallbackOnUiThread(int jcallback_id, int64 usage);
+
+ base::WeakPtr<AwQuotaManagerBridge> bridge_;
+ quota::QuotaManager* quota_manager_;
+
+ DISALLOW_COPY_AND_ASSIGN(IOThreadSwitcher);
+};
+
+} // namespace internal
+
+class AwQuotaManagerBridge
+ : public base::SupportsWeakPtr<AwQuotaManagerBridge> {
+ public:
+ static AwQuotaManagerBridge* Create(AwBrowserContext* browser_context);
+
+ 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 GetQuotaForOrigin(JNIEnv* env,
+ jobject object,
+ jstring origin,
+ jint callback_id);
+ void GetUsageForOrigin(JNIEnv* env,
+ jobject object,
+ jstring origin,
+ jint callback_id);
+
+ // Used by the IOThreadSwitchers.
+ quota::QuotaManager* GetQuotaManager() const;
+ void GetOriginsCallback(
+ int jcallback_id,
+ const std::vector<std::string>& origin,
+ const std::vector<int64>& quota,
+ const std::vector<int64>& usage);
+ void GetQuotaForOriginCallback(int jcallback_id, int64 quota);
+ void GetUsageForOriginCallback(int jcallback_id, int64 usage);
+
+ private:
+ AwQuotaManagerBridge(AwBrowserContext* browser_context);
+
+ JavaObjectWeakGlobalRef java_ref_;
+ AwBrowserContext* browser_context_;
+ scoped_refptr<internal::IOThreadSwitcher> io_thread_switcher_;
+ DISALLOW_COPY_AND_ASSIGN(AwQuotaManagerBridge);
+};
+
+bool RegisterAwQuotaManagerBridge(JNIEnv* env);
+
+} // namespace android_webview
+
+#endif // ANDROID_WEBVIEW_NATIVE_AW_QUOTA_MANAGER_BRIDGE_H_

Powered by Google App Engine
This is Rietveld 408576698