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/memory/ref_counted.h"
12#include "base/memory/weak_ptr.h"
13#include "base/message_loop/message_loop_proxy.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 "storage/common/quota/quota_types.h"
18
19namespace content {
20class IndexedDBContextImpl;
21
22// A QuotaClient implementation to integrate IndexedDB
23// with the quota  management system. This interface is used
24// on the IO thread by the quota manager.
25class IndexedDBQuotaClient : public storage::QuotaClient,
26                             public storage::QuotaTaskObserver {
27 public:
28  CONTENT_EXPORT explicit IndexedDBQuotaClient(
29      IndexedDBContextImpl* indexed_db_context);
30  CONTENT_EXPORT virtual ~IndexedDBQuotaClient();
31
32  // QuotaClient method overrides
33  virtual ID id() const OVERRIDE;
34  virtual void OnQuotaManagerDestroyed() OVERRIDE;
35  CONTENT_EXPORT virtual void GetOriginUsage(
36      const GURL& origin_url,
37      storage::StorageType type,
38      const GetUsageCallback& callback) OVERRIDE;
39  CONTENT_EXPORT virtual void GetOriginsForType(
40      storage::StorageType type,
41      const GetOriginsCallback& callback) OVERRIDE;
42  CONTENT_EXPORT virtual void GetOriginsForHost(
43      storage::StorageType type,
44      const std::string& host,
45      const GetOriginsCallback& callback) OVERRIDE;
46  CONTENT_EXPORT virtual void DeleteOriginData(
47      const GURL& origin,
48      storage::StorageType type,
49      const DeletionCallback& callback) OVERRIDE;
50  virtual bool DoesSupport(storage::StorageType type) const OVERRIDE;
51
52 private:
53  scoped_refptr<IndexedDBContextImpl> indexed_db_context_;
54
55  DISALLOW_COPY_AND_ASSIGN(IndexedDBQuotaClient);
56};
57
58}  // namespace content
59
60#endif  // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_QUOTA_CLIENT_H_
61