Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: webkit/fileapi/file_system_quota_client.h

Issue 10828177: Refactors FileSystemQuotaClient using base::Callback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_QUOTA_CLIENT_H_ 5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_QUOTA_CLIENT_H_
6 #define WEBKIT_FILEAPI_FILE_SYSTEM_QUOTA_CLIENT_H_ 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_QUOTA_CLIENT_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/file_path.h" 14 #include "base/file_path.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "webkit/fileapi/fileapi_export.h" 16 #include "webkit/fileapi/fileapi_export.h"
17 #include "webkit/fileapi/file_system_quota_util.h" 17 #include "webkit/fileapi/file_system_quota_util.h"
18 #include "webkit/fileapi/file_system_types.h" 18 #include "webkit/fileapi/file_system_types.h"
19 #include "webkit/quota/quota_client.h" 19 #include "webkit/quota/quota_client.h"
20 #include "webkit/quota/quota_task.h"
21 20
22 namespace base { 21 namespace base {
23 class SequencedTaskRunner; 22 class SequencedTaskRunner;
24 } 23 }
25 24
26 namespace fileapi { 25 namespace fileapi {
27 26
28 class FileSystemContext; 27 class FileSystemContext;
29 28
30 // An instance of this class is created per-profile. This class 29 // An instance of this class is created per-profile. This class
31 // is self-destructed and will delete itself when OnQuotaManagerDestroyed 30 // is self-destructed and will delete itself when OnQuotaManagerDestroyed
32 // is called. 31 // is called.
33 // All of the public methods of this class are called by the quota manager 32 // All of the public methods of this class are called by the quota manager
34 // (except for the constructor/destructor). 33 // (except for the constructor/destructor).
35 class FILEAPI_EXPORT_PRIVATE FileSystemQuotaClient 34 class FILEAPI_EXPORT_PRIVATE FileSystemQuotaClient
36 : public NON_EXPORTED_BASE(quota::QuotaClient), 35 : public NON_EXPORTED_BASE(quota::QuotaClient) {
37 public quota::QuotaTaskObserver {
38 public: 36 public:
39 FileSystemQuotaClient( 37 FileSystemQuotaClient(
40 FileSystemContext* file_system_context, 38 FileSystemContext* file_system_context,
41 bool is_incognito); 39 bool is_incognito);
42 virtual ~FileSystemQuotaClient(); 40 virtual ~FileSystemQuotaClient();
43 41
44 // QuotaClient methods. 42 // QuotaClient methods.
45 virtual quota::QuotaClient::ID id() const OVERRIDE; 43 virtual quota::QuotaClient::ID id() const OVERRIDE;
46 virtual void OnQuotaManagerDestroyed() OVERRIDE; 44 virtual void OnQuotaManagerDestroyed() OVERRIDE;
47 virtual void GetOriginUsage(const GURL& origin_url, 45 virtual void GetOriginUsage(const GURL& origin_url,
48 quota::StorageType type, 46 quota::StorageType type,
49 const GetUsageCallback& callback) OVERRIDE; 47 const GetUsageCallback& callback) OVERRIDE;
50 virtual void GetOriginsForType( 48 virtual void GetOriginsForType(
51 quota::StorageType type, 49 quota::StorageType type,
52 const GetOriginsCallback& callback) OVERRIDE; 50 const GetOriginsCallback& callback) OVERRIDE;
53 virtual void GetOriginsForHost( 51 virtual void GetOriginsForHost(
54 quota::StorageType type, 52 quota::StorageType type,
55 const std::string& host, 53 const std::string& host,
56 const GetOriginsCallback& callback) OVERRIDE; 54 const GetOriginsCallback& callback) OVERRIDE;
57 virtual void DeleteOriginData( 55 virtual void DeleteOriginData(
58 const GURL& origin, 56 const GURL& origin,
59 quota::StorageType type, 57 quota::StorageType type,
60 const DeletionCallback& callback) OVERRIDE; 58 const DeletionCallback& callback) OVERRIDE;
61 59
62 private: 60 private:
63 class GetOriginUsageTask;
64 class GetOriginsTaskBase;
65 class GetOriginsForTypeTask;
66 class GetOriginsForHostTask;
67 class DeleteOriginTask;
68
69 typedef std::pair<fileapi::FileSystemType, std::string> TypeAndHostOrOrigin;
70 typedef quota::CallbackQueueMap1<GetUsageCallback,
71 TypeAndHostOrOrigin,
72 int64
73 > UsageCallbackMap;
74 typedef quota::CallbackQueueMap2<GetOriginsCallback,
75 fileapi::FileSystemType,
76 const std::set<GURL>&,
77 quota::StorageType
78 > OriginsForTypeCallbackMap;
79 typedef quota::CallbackQueueMap2<GetOriginsCallback,
80 TypeAndHostOrOrigin,
81 const std::set<GURL>&,
82 quota::StorageType
83 > OriginsForHostCallbackMap;
84
85 void DidGetOriginUsage(fileapi::FileSystemType type,
86 const GURL& origin, int64 usage);
87 void DidGetOriginsForType(fileapi::FileSystemType type,
88 const std::set<GURL>& origins);
89 void DidGetOriginsForHost(const TypeAndHostOrOrigin& type_and_host,
90 const std::set<GURL>& origins);
91
92 base::SequencedTaskRunner* file_task_runner() const; 61 base::SequencedTaskRunner* file_task_runner() const;
93 62
94 scoped_refptr<FileSystemContext> file_system_context_; 63 scoped_refptr<FileSystemContext> file_system_context_;
95 64
96 bool is_incognito_; 65 bool is_incognito_;
97 66
98 // Pending callbacks.
99 UsageCallbackMap pending_usage_callbacks_;
100 OriginsForTypeCallbackMap pending_origins_for_type_callbacks_;
101 OriginsForHostCallbackMap pending_origins_for_host_callbacks_;
102
103 DISALLOW_COPY_AND_ASSIGN(FileSystemQuotaClient); 67 DISALLOW_COPY_AND_ASSIGN(FileSystemQuotaClient);
104 }; 68 };
105 69
106 } // namespace fileapi 70 } // namespace fileapi
107 71
108 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_QUOTA_CLIENT_H_ 72 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_QUOTA_CLIENT_H_
OLDNEW
« no previous file with comments | « no previous file | webkit/fileapi/file_system_quota_client.cc » ('j') | webkit/fileapi/file_system_quota_client.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698