1 // Copyright (c) 2011 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 CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_QUOTA_CLIENT_H_
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_QUOTA_CLIENT_H_
7 
8 #include <set>
9 #include <string>
10 
11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h"
14 #include "content/common/content_export.h"
15 #include "storage/browser/quota/quota_client.h"
16 #include "storage/browser/quota/quota_task.h"
17 #include "third_party/blink/public/mojom/quota/quota_types.mojom.h"
18 #include "url/origin.h"
19 
20 namespace content {
21 class IndexedDBContextImpl;
22 
23 // Integrates IndexedDB with the quota management system.
24 //
25 // This interface is used on the IO thread by the quota manager.
26 class IndexedDBQuotaClient : public storage::QuotaClient {
27  public:
28   CONTENT_EXPORT explicit IndexedDBQuotaClient(
29       scoped_refptr<IndexedDBContextImpl> indexed_db_context);
30 
31   // QuotaClient implementation:
32   ID id() const override;
33   void OnQuotaManagerDestroyed() override;
34   void GetOriginUsage(const url::Origin& origin,
35                       blink::mojom::StorageType type,
36                       GetUsageCallback callback) override;
37   void GetOriginsForType(blink::mojom::StorageType type,
38                          GetOriginsCallback callback) override;
39   void GetOriginsForHost(blink::mojom::StorageType type,
40                          const std::string& host,
41                          GetOriginsCallback callback) override;
42   void DeleteOriginData(const url::Origin& origin,
43                         blink::mojom::StorageType type,
44                         DeletionCallback callback) override;
45   void PerformStorageCleanup(blink::mojom::StorageType type,
46                              base::OnceClosure callback) override;
47   bool DoesSupport(blink::mojom::StorageType type) const override;
48 
49  private:
50   ~IndexedDBQuotaClient() override;
51 
52   const scoped_refptr<IndexedDBContextImpl> indexed_db_context_;
53 
54   DISALLOW_COPY_AND_ASSIGN(IndexedDBQuotaClient);
55 };
56 
57 }  // namespace content
58 
59 #endif  // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_QUOTA_CLIENT_H_
60