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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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_H_
6 #define ANDROID_WEBVIEW_NATIVE_AW_QUOTA_MANAGER_BRIDGE_H_
7
8 #include <jni.h>
9 #include <set>
10 #include <vector>
11 #include <string>
12
13 #include "base/android/jni_helper.h"
14 #include "base/basictypes.h"
15 #include "base/memory/ref_counted.h"
16 #include "base/memory/weak_ptr.h"
17 #include "webkit/quota/quota_types.h"
18
19 class GURL;
20
21 namespace content {
22 class StoragePartition;
23 }
24
25 namespace quota {
26 class QuotaManager;
27 } // namespace quota
28
29 namespace android_webview {
30
31 class AwBrowserContext;
32 class AwQuotaManagerBridge;
33
34 namespace internal {
35
36 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
37 public:
38 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
39
40 void DeleteAllDataOnIOThread();
mkosiba (inactive) 2013/02/19 11:37:13 Looks like all of the methods are OnIOThread, mayb
41 void DeleteOriginOnIOThread(const GURL& origin);
42 void GetQuotaForOriginOnIOThread(const GURL& origin, int jcallback_id);
43 void GetUsageForOriginOnIOThread(const GURL& origin, int jcallback_id);
44
45 private:
46 friend class base::RefCountedThreadSafe<IOThreadSwitcher>;
47 ~IOThreadSwitcher();
48
49 void DeleteOrigins(const std::set<GURL>& origins, quota::StorageType type);
50
51 void GetQuotaForOriginCallback(int jcallback_id,
52 quota::QuotaStatusCode status_code,
53 int64 usage,
54 int64 quota);
55 void GetUsageForOriginCallback(int jcallback_id,
56 quota::QuotaStatusCode status_code,
57 int64 usage,
58 int64 quota);
59
60 void GetQuotaForOriginCallbackOnUiThread(int jcallback_id, int64 quota);
61 void GetUsageForOriginCallbackOnUiThread(int jcallback_id, int64 usage);
62
63 base::WeakPtr<AwQuotaManagerBridge> bridge_;
64 quota::QuotaManager* quota_manager_;
65
66 DISALLOW_COPY_AND_ASSIGN(IOThreadSwitcher);
67 };
68
69 } // namespace internal
70
71 class AwQuotaManagerBridge
72 : public base::SupportsWeakPtr<AwQuotaManagerBridge> {
73 public:
74 static AwQuotaManagerBridge* Create(AwBrowserContext* browser_context);
75
76 void Init(JNIEnv* env, jobject object);
77 void DeleteAllData(JNIEnv* env, jobject object);
78 void DeleteOrigin(JNIEnv* env, jobject object, jstring origin);
79 void GetOrigins(JNIEnv* env, jobject object, jint callback_id);
80 void GetQuotaForOrigin(JNIEnv* env,
81 jobject object,
82 jstring origin,
83 jint callback_id);
84 void GetUsageForOrigin(JNIEnv* env,
85 jobject object,
86 jstring origin,
87 jint callback_id);
88
89 // Used by the IOThreadSwitchers.
90 quota::QuotaManager* GetQuotaManager() const;
91 void GetOriginsCallback(
92 int jcallback_id,
93 const std::vector<std::string>& origin,
94 const std::vector<int64>& quota,
95 const std::vector<int64>& usage);
96 void GetQuotaForOriginCallback(int jcallback_id, int64 quota);
97 void GetUsageForOriginCallback(int jcallback_id, int64 usage);
98
99 private:
100 AwQuotaManagerBridge(AwBrowserContext* browser_context);
101
102 JavaObjectWeakGlobalRef java_ref_;
103 AwBrowserContext* browser_context_;
104 scoped_refptr<internal::IOThreadSwitcher> io_thread_switcher_;
105 DISALLOW_COPY_AND_ASSIGN(AwQuotaManagerBridge);
106 };
107
108 bool RegisterAwQuotaManagerBridge(JNIEnv* env);
109
110 } // namespace android_webview
111
112 #endif // ANDROID_WEBVIEW_NATIVE_AW_QUOTA_MANAGER_BRIDGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698