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

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

Issue 10830330: Clean up FileSystemQuotaClient. (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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "webkit/fileapi/file_system_quota_client.h" 5 #include "webkit/fileapi/file_system_quota_client.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 13 matching lines...) Expand all
24 #include "webkit/fileapi/file_system_usage_cache.h" 24 #include "webkit/fileapi/file_system_usage_cache.h"
25 #include "webkit/fileapi/file_system_util.h" 25 #include "webkit/fileapi/file_system_util.h"
26 #include "webkit/fileapi/sandbox_mount_point_provider.h" 26 #include "webkit/fileapi/sandbox_mount_point_provider.h"
27 27
28 using quota::StorageType; 28 using quota::StorageType;
29 29
30 namespace fileapi { 30 namespace fileapi {
31 31
32 namespace { 32 namespace {
33 33
34 void GetOriginsForTypeOnFileThread(FileSystemContext* context, 34 void GetOriginsForTypeOnFileThread(
35 StorageType storage_type, 35 FileSystemContext* context,
36 std::set<GURL>* origins_ptr) { 36 StorageType storage_type,
37 std::set<GURL>* origins_ptr) {
37 FileSystemType type = QuotaStorageTypeToFileSystemType(storage_type); 38 FileSystemType type = QuotaStorageTypeToFileSystemType(storage_type);
38 DCHECK(type != kFileSystemTypeUnknown); 39 DCHECK(type != kFileSystemTypeUnknown);
39 40
40 FileSystemQuotaUtil* quota_util = context->GetQuotaUtil(type); 41 FileSystemQuotaUtil* quota_util = context->GetQuotaUtil(type);
41 if (!quota_util) 42 if (!quota_util)
42 return; 43 return;
43 quota_util->GetOriginsForTypeOnFileThread(type, origins_ptr); 44 quota_util->GetOriginsForTypeOnFileThread(type, origins_ptr);
44 } 45 }
45 46
46 void GetOriginsForHostOnFileThread(FileSystemContext* context, 47 void GetOriginsForHostOnFileThread(
47 StorageType storage_type, 48 FileSystemContext* context,
48 const std::string& host, 49 StorageType storage_type,
49 std::set<GURL>* origins_ptr) { 50 const std::string& host,
51 std::set<GURL>* origins_ptr) {
50 FileSystemType type = QuotaStorageTypeToFileSystemType(storage_type); 52 FileSystemType type = QuotaStorageTypeToFileSystemType(storage_type);
51 DCHECK(type != kFileSystemTypeUnknown); 53 DCHECK(type != kFileSystemTypeUnknown);
52 54
53 FileSystemQuotaUtil* quota_util = context->GetQuotaUtil(type); 55 FileSystemQuotaUtil* quota_util = context->GetQuotaUtil(type);
54 if (!quota_util) 56 if (!quota_util)
55 return; 57 return;
56 quota_util->GetOriginsForHostOnFileThread(type, host, origins_ptr); 58 quota_util->GetOriginsForHostOnFileThread(type, host, origins_ptr);
57 } 59 }
58 60
59 void DidGetOrigins( 61 void DidGetOrigins(
60 const base::Callback<void(const std::set<GURL>&, StorageType)>& callback, 62 const quota::QuotaClient::GetOriginsCallback& callback,
61 std::set<GURL>* origins_ptr, 63 std::set<GURL>* origins_ptr,
62 StorageType storage_type) { 64 StorageType storage_type) {
63 callback.Run(*origins_ptr, storage_type); 65 callback.Run(*origins_ptr, storage_type);
64 } 66 }
65 67
66 quota::QuotaStatusCode DeleteOriginOnTargetThread( 68 quota::QuotaStatusCode DeleteOriginOnFileThread(
67 FileSystemContext* context, 69 FileSystemContext* context,
68 const GURL& origin, 70 const GURL& origin,
69 FileSystemType type) { 71 FileSystemType type) {
70 base::PlatformFileError result = 72 base::PlatformFileError result =
71 context->sandbox_provider()->DeleteOriginDataOnFileThread( 73 context->sandbox_provider()->DeleteOriginDataOnFileThread(
72 context, context->quota_manager_proxy(), origin, type); 74 context, context->quota_manager_proxy(), origin, type);
73 if (result == base::PLATFORM_FILE_OK) 75 if (result == base::PLATFORM_FILE_OK)
74 return quota::kQuotaStatusOk; 76 return quota::kQuotaStatusOk;
75 return quota::kQuotaErrorInvalidModification; 77 return quota::kQuotaErrorInvalidModification;
76 } 78 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 file_system_context_, 174 file_system_context_,
173 storage_type, 175 storage_type,
174 host, 176 host,
175 base::Unretained(origins_ptr)), 177 base::Unretained(origins_ptr)),
176 base::Bind(&DidGetOrigins, 178 base::Bind(&DidGetOrigins,
177 callback, 179 callback,
178 base::Owned(origins_ptr), 180 base::Owned(origins_ptr),
179 storage_type)); 181 storage_type));
180 } 182 }
181 183
182 void FileSystemQuotaClient::DeleteOriginData(const GURL& origin, 184 void FileSystemQuotaClient::DeleteOriginData(
183 StorageType type, 185 const GURL& origin,
184 const DeletionCallback& callback) { 186 StorageType type,
187 const DeletionCallback& callback) {
185 FileSystemType fs_type = QuotaStorageTypeToFileSystemType(type); 188 FileSystemType fs_type = QuotaStorageTypeToFileSystemType(type);
186 DCHECK(fs_type != kFileSystemTypeUnknown); 189 DCHECK(fs_type != kFileSystemTypeUnknown);
187 190
188 base::PostTaskAndReplyWithResult( 191 base::PostTaskAndReplyWithResult(
189 file_task_runner(), 192 file_task_runner(),
190 FROM_HERE, 193 FROM_HERE,
191 base::Bind(&DeleteOriginOnTargetThread, 194 base::Bind(&DeleteOriginOnFileThread,
192 file_system_context_, 195 file_system_context_,
193 origin, 196 origin,
194 fs_type), 197 fs_type),
195 callback); 198 callback);
196 } 199 }
197 200
198 base::SequencedTaskRunner* FileSystemQuotaClient::file_task_runner() const { 201 base::SequencedTaskRunner* FileSystemQuotaClient::file_task_runner() const {
199 return file_system_context_->task_runners()->file_task_runner(); 202 return file_system_context_->task_runners()->file_task_runner();
200 } 203 }
201 204
202 } // namespace fileapi 205 } // namespace fileapi
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698