OLD | NEW |
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/browser/fileapi/file_system_quota_client.h" | 5 #include "webkit/browser/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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 DCHECK(type != kFileSystemTypeUnknown); | 53 DCHECK(type != kFileSystemTypeUnknown); |
54 | 54 |
55 FileSystemQuotaUtil* quota_util = context->GetQuotaUtil(type); | 55 FileSystemQuotaUtil* quota_util = context->GetQuotaUtil(type); |
56 if (!quota_util) | 56 if (!quota_util) |
57 return; | 57 return; |
58 quota_util->GetOriginsForHostOnFileThread(type, host, origins_ptr); | 58 quota_util->GetOriginsForHostOnFileThread(type, host, origins_ptr); |
59 } | 59 } |
60 | 60 |
61 void DidGetOrigins( | 61 void DidGetOrigins( |
62 const quota::QuotaClient::GetOriginsCallback& callback, | 62 const quota::QuotaClient::GetOriginsCallback& callback, |
63 std::set<GURL>* origins_ptr, | 63 std::set<GURL>* origins_ptr) { |
64 StorageType storage_type) { | 64 callback.Run(*origins_ptr); |
65 callback.Run(*origins_ptr, storage_type); | |
66 } | 65 } |
67 | 66 |
68 quota::QuotaStatusCode DeleteOriginOnFileThread( | 67 quota::QuotaStatusCode DeleteOriginOnFileThread( |
69 FileSystemContext* context, | 68 FileSystemContext* context, |
70 const GURL& origin, | 69 const GURL& origin, |
71 FileSystemType type) { | 70 FileSystemType type) { |
72 base::PlatformFileError result = | 71 base::PlatformFileError result = |
73 context->sandbox_provider()->DeleteOriginDataOnFileThread( | 72 context->sandbox_provider()->DeleteOriginDataOnFileThread( |
74 context, context->quota_manager_proxy(), origin, type); | 73 context, context->quota_manager_proxy(), origin, type); |
75 if (result == base::PLATFORM_FILE_OK) | 74 if (result == base::PLATFORM_FILE_OK) |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 } | 129 } |
131 | 130 |
132 void FileSystemQuotaClient::GetOriginsForType( | 131 void FileSystemQuotaClient::GetOriginsForType( |
133 StorageType storage_type, | 132 StorageType storage_type, |
134 const GetOriginsCallback& callback) { | 133 const GetOriginsCallback& callback) { |
135 DCHECK(!callback.is_null()); | 134 DCHECK(!callback.is_null()); |
136 | 135 |
137 if (is_incognito_) { | 136 if (is_incognito_) { |
138 // We don't support FileSystem in incognito mode yet. | 137 // We don't support FileSystem in incognito mode yet. |
139 std::set<GURL> origins; | 138 std::set<GURL> origins; |
140 callback.Run(origins, storage_type); | 139 callback.Run(origins); |
141 return; | 140 return; |
142 } | 141 } |
143 | 142 |
144 std::set<GURL>* origins_ptr = new std::set<GURL>(); | 143 std::set<GURL>* origins_ptr = new std::set<GURL>(); |
145 file_task_runner()->PostTaskAndReply( | 144 file_task_runner()->PostTaskAndReply( |
146 FROM_HERE, | 145 FROM_HERE, |
147 base::Bind(&GetOriginsForTypeOnFileThread, | 146 base::Bind(&GetOriginsForTypeOnFileThread, |
148 file_system_context_, | 147 file_system_context_, |
149 storage_type, | 148 storage_type, |
150 base::Unretained(origins_ptr)), | 149 base::Unretained(origins_ptr)), |
151 base::Bind(&DidGetOrigins, | 150 base::Bind(&DidGetOrigins, |
152 callback, | 151 callback, |
153 base::Owned(origins_ptr), | 152 base::Owned(origins_ptr))); |
154 storage_type)); | |
155 } | 153 } |
156 | 154 |
157 void FileSystemQuotaClient::GetOriginsForHost( | 155 void FileSystemQuotaClient::GetOriginsForHost( |
158 StorageType storage_type, | 156 StorageType storage_type, |
159 const std::string& host, | 157 const std::string& host, |
160 const GetOriginsCallback& callback) { | 158 const GetOriginsCallback& callback) { |
161 DCHECK(!callback.is_null()); | 159 DCHECK(!callback.is_null()); |
162 | 160 |
163 if (is_incognito_) { | 161 if (is_incognito_) { |
164 // We don't support FileSystem in incognito mode yet. | 162 // We don't support FileSystem in incognito mode yet. |
165 std::set<GURL> origins; | 163 std::set<GURL> origins; |
166 callback.Run(origins, storage_type); | 164 callback.Run(origins); |
167 return; | 165 return; |
168 } | 166 } |
169 | 167 |
170 std::set<GURL>* origins_ptr = new std::set<GURL>(); | 168 std::set<GURL>* origins_ptr = new std::set<GURL>(); |
171 file_task_runner()->PostTaskAndReply( | 169 file_task_runner()->PostTaskAndReply( |
172 FROM_HERE, | 170 FROM_HERE, |
173 base::Bind(&GetOriginsForHostOnFileThread, | 171 base::Bind(&GetOriginsForHostOnFileThread, |
174 file_system_context_, | 172 file_system_context_, |
175 storage_type, | 173 storage_type, |
176 host, | 174 host, |
177 base::Unretained(origins_ptr)), | 175 base::Unretained(origins_ptr)), |
178 base::Bind(&DidGetOrigins, | 176 base::Bind(&DidGetOrigins, |
179 callback, | 177 callback, |
180 base::Owned(origins_ptr), | 178 base::Owned(origins_ptr))); |
181 storage_type)); | |
182 } | 179 } |
183 | 180 |
184 void FileSystemQuotaClient::DeleteOriginData( | 181 void FileSystemQuotaClient::DeleteOriginData( |
185 const GURL& origin, | 182 const GURL& origin, |
186 StorageType type, | 183 StorageType type, |
187 const DeletionCallback& callback) { | 184 const DeletionCallback& callback) { |
188 FileSystemType fs_type = QuotaStorageTypeToFileSystemType(type); | 185 FileSystemType fs_type = QuotaStorageTypeToFileSystemType(type); |
189 DCHECK(fs_type != kFileSystemTypeUnknown); | 186 DCHECK(fs_type != kFileSystemTypeUnknown); |
190 | 187 |
191 base::PostTaskAndReplyWithResult( | 188 base::PostTaskAndReplyWithResult( |
192 file_task_runner(), | 189 file_task_runner(), |
193 FROM_HERE, | 190 FROM_HERE, |
194 base::Bind(&DeleteOriginOnFileThread, | 191 base::Bind(&DeleteOriginOnFileThread, |
195 file_system_context_, | 192 file_system_context_, |
196 origin, | 193 origin, |
197 fs_type), | 194 fs_type), |
198 callback); | 195 callback); |
199 } | 196 } |
200 | 197 |
201 base::SequencedTaskRunner* FileSystemQuotaClient::file_task_runner() const { | 198 base::SequencedTaskRunner* FileSystemQuotaClient::file_task_runner() const { |
202 return file_system_context_->task_runners()->file_task_runner(); | 199 return file_system_context_->task_runners()->file_task_runner(); |
203 } | 200 } |
204 | 201 |
205 } // namespace fileapi | 202 } // namespace fileapi |
OLD | NEW |