chrome: bluetooth: hook up the AdapterAdded signal
[chromium-blink-merge.git] / webkit / fileapi / file_system_quota_util.h
blob5ba638a031942ad8a7ce517644902951faabeb8d
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.
5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_QUOTA_UTIL_H_
6 #define WEBKIT_FILEAPI_FILE_SYSTEM_QUOTA_UTIL_H_
8 #include <set>
9 #include <string>
11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h"
13 #include "googleurl/src/gurl.h"
14 #include "webkit/fileapi/file_system_types.h"
16 namespace base {
17 class MessageLoopProxy;
20 namespace quota {
21 class QuotaManagerProxy;
24 namespace fileapi {
26 // An abstract interface that provides common quota-related utility functions
27 // for internal filesystem modules. The main consumer of this class is
28 // file_system_quota_client and quota_file_util.
29 // All the methods of this class are synchronous and need to be called on
30 // the thread that the method name implies.
31 class FileSystemQuotaUtil {
32 public:
33 // Methods of this class can be called on any thread.
34 class Proxy : public base::RefCountedThreadSafe<Proxy> {
35 public:
36 void UpdateOriginUsage(quota::QuotaManagerProxy* proxy,
37 const GURL& origin_url,
38 fileapi::FileSystemType type,
39 int64 delta);
40 void StartUpdateOrigin(const GURL& origin_url,
41 fileapi::FileSystemType type);
42 void EndUpdateOrigin(const GURL& origin_url,
43 fileapi::FileSystemType type);
45 private:
46 friend class FileSystemQuotaUtil;
47 friend class base::RefCountedThreadSafe<Proxy>;
48 Proxy(FileSystemQuotaUtil* quota_handler,
49 base::MessageLoopProxy* file_thread);
50 ~Proxy();
52 FileSystemQuotaUtil* quota_util_; // Accessed only on the FILE thread.
53 scoped_refptr<base::MessageLoopProxy> file_thread_;
54 DISALLOW_COPY_AND_ASSIGN(Proxy);
57 // Called by quota client.
58 virtual void GetOriginsForTypeOnFileThread(fileapi::FileSystemType type,
59 std::set<GURL>* origins) = 0;
61 // Called by quota client.
62 virtual void GetOriginsForHostOnFileThread(fileapi::FileSystemType type,
63 const std::string& host,
64 std::set<GURL>* origins) = 0;
66 // Called by quota client.
67 // Returns the amount of data used for the origin for usage tracking.
68 virtual int64 GetOriginUsageOnFileThread(const GURL& origin_url,
69 fileapi::FileSystemType type) = 0;
71 // Called by quota file util.
72 virtual void UpdateOriginUsageOnFileThread(quota::QuotaManagerProxy* proxy,
73 const GURL& origin_url,
74 fileapi::FileSystemType type,
75 int64 delta) = 0;
77 // Called by file_system_operation.
78 // Called when a read operation accesses the origin's storage data.
79 virtual void NotifyOriginWasAccessedOnIOThread(
80 quota::QuotaManagerProxy* proxy,
81 const GURL& origin_url,
82 fileapi::FileSystemType type) = 0;
84 // Called by quota_file_util or file_writer_delegate.
85 // Called before a write operation modifies the origin's storage data.
86 virtual void StartUpdateOriginOnFileThread(const GURL& origin_url,
87 fileapi::FileSystemType type) = 0;
89 // Called by quota_file_util or file_writer_delegate.
90 // Called after a write operation modifies the origin's storage data.
91 virtual void EndUpdateOriginOnFileThread(const GURL& origin_url,
92 fileapi::FileSystemType type) = 0;
94 virtual void InvalidateUsageCache(const GURL& origin_url,
95 fileapi::FileSystemType type) = 0;
97 Proxy* proxy() { return proxy_.get(); }
99 protected:
100 explicit FileSystemQuotaUtil(base::MessageLoopProxy* file_thread);
101 virtual ~FileSystemQuotaUtil();
103 private:
104 scoped_refptr<Proxy> proxy_;
107 } // namespace fileapi
109 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_QUOTA_UTIL_H_