1 // Copyright 2014 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 STORAGE_BROWSER_QUOTA_QUOTA_MANAGER_PROXY_H_
6 #define STORAGE_BROWSER_QUOTA_QUOTA_MANAGER_PROXY_H_
8 #include "base/basictypes.h"
9 #include "base/callback.h"
10 #include "base/files/file_path.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/sequenced_task_runner_helpers.h"
15 #include "storage/browser/quota/quota_callbacks.h"
16 #include "storage/browser/quota/quota_client.h"
17 #include "storage/browser/quota/quota_database.h"
18 #include "storage/browser/quota/quota_manager.h"
19 #include "storage/browser/quota/quota_task.h"
20 #include "storage/browser/quota/special_storage_policy.h"
21 #include "storage/browser/storage_browser_export.h"
24 class SequencedTaskRunner
;
25 class SingleThreadTaskRunner
;
30 // The proxy may be called and finally released on any thread.
31 class STORAGE_EXPORT QuotaManagerProxy
32 : public base::RefCountedThreadSafe
<QuotaManagerProxy
> {
34 typedef QuotaManager::GetUsageAndQuotaCallback
35 GetUsageAndQuotaCallback
;
37 virtual void RegisterClient(QuotaClient
* client
);
38 virtual void NotifyStorageAccessed(QuotaClient::ID client_id
,
41 virtual void NotifyStorageModified(QuotaClient::ID client_id
,
45 virtual void NotifyOriginInUse(const GURL
& origin
);
46 virtual void NotifyOriginNoLongerInUse(const GURL
& origin
);
48 virtual void SetUsageCacheEnabled(QuotaClient::ID client_id
,
52 virtual void GetUsageAndQuota(
53 base::SequencedTaskRunner
* original_task_runner
,
56 const GetUsageAndQuotaCallback
& callback
);
58 // This method may only be called on the IO thread.
59 // It may return NULL if the manager has already been deleted.
60 QuotaManager
* quota_manager() const;
63 friend class QuotaManager
;
64 friend class base::RefCountedThreadSafe
<QuotaManagerProxy
>;
67 QuotaManager
* manager
,
68 const scoped_refptr
<base::SingleThreadTaskRunner
>& io_thread
);
69 virtual ~QuotaManagerProxy();
71 QuotaManager
* manager_
; // only accessed on the io thread
72 scoped_refptr
<base::SingleThreadTaskRunner
> io_thread_
;
74 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy
);
77 } // namespace storage
79 #endif // STORAGE_BROWSER_QUOTA_QUOTA_MANAGER_PROXY_H_