Don't reset the database when there was an I/O error.
[chromium-blink-merge.git] / android_webview / native / aw_quota_manager_bridge_impl.h
blob8b9d60bc9332b781b71bff9955ece1f7af473fb5
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.
5 #ifndef ANDROID_WEBVIEW_NATIVE_AW_QUOTA_MANAGER_BRIDGE_IMPL_H_
6 #define ANDROID_WEBVIEW_NATIVE_AW_QUOTA_MANAGER_BRIDGE_IMPL_H_
8 #include <jni.h>
9 #include <string>
10 #include <vector>
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"
19 class GURL;
21 namespace content {
22 class StoragePartition;
25 namespace quota {
26 class QuotaManager;
27 } // namespace quota
29 namespace android_webview {
31 class AwBrowserContext;
33 class AwQuotaManagerBridgeImpl : public AwQuotaManagerBridge {
34 public:
35 explicit AwQuotaManagerBridgeImpl(AwBrowserContext* browser_context);
36 virtual ~AwQuotaManagerBridgeImpl();
38 // Called by Java.
39 void Init(JNIEnv* env, jobject object);
40 void DeleteAllData(JNIEnv* env, jobject object);
41 void DeleteOrigin(JNIEnv* env, jobject object, jstring origin);
42 void GetOrigins(JNIEnv* env, jobject object, jint callback_id);
43 void GetUsageAndQuotaForOrigin(JNIEnv* env,
44 jobject object,
45 jstring origin,
46 jint callback_id,
47 bool is_quota);
49 typedef base::Callback<
50 void(const std::vector<std::string>& /* origin */,
51 const std::vector<int64>& /* usage */,
52 const std::vector<int64>& /* quota */)> GetOriginsCallback;
53 typedef base::Callback<void(int64 /* usage */,
54 int64 /* quota */)> QuotaUsageCallback;
56 private:
57 content::StoragePartition* GetStoragePartition() const;
59 quota::QuotaManager* GetQuotaManager() const;
61 void GetOriginsCallbackImpl(
62 int jcallback_id,
63 const std::vector<std::string>& origin,
64 const std::vector<int64>& usage,
65 const std::vector<int64>& quota);
66 void QuotaUsageCallbackImpl(
67 int jcallback_id, bool is_quota, int64 usage, int64 quota);
69 base::WeakPtrFactory<AwQuotaManagerBridgeImpl> weak_factory_;
70 AwBrowserContext* browser_context_;
71 JavaObjectWeakGlobalRef java_ref_;
73 DISALLOW_COPY_AND_ASSIGN(AwQuotaManagerBridgeImpl);
76 bool RegisterAwQuotaManagerBridge(JNIEnv* env);
78 } // namespace android_webview
80 #endif // ANDROID_WEBVIEW_NATIVE_AW_QUOTA_MANAGER_BRIDGE_IMPL_H_