OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/quota/quota_backend_impl.h" | 5 #include "webkit/browser/fileapi/quota/quota_backend_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 void QuotaBackendImpl::ReserveQuota(const GURL& origin, | 36 void QuotaBackendImpl::ReserveQuota(const GURL& origin, |
37 FileSystemType type, | 37 FileSystemType type, |
38 int64 delta, | 38 int64 delta, |
39 const ReserveQuotaCallback& callback) { | 39 const ReserveQuotaCallback& callback) { |
40 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); | 40 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); |
41 DCHECK(origin.is_valid()); | 41 DCHECK(origin.is_valid()); |
42 if (!delta) { | 42 if (!delta) { |
43 callback.Run(base::File::FILE_OK, 0); | 43 callback.Run(base::File::FILE_OK, 0); |
44 return; | 44 return; |
45 } | 45 } |
46 DCHECK(quota_manager_proxy_); | 46 DCHECK(quota_manager_proxy_.get()); |
47 quota_manager_proxy_->GetUsageAndQuota( | 47 quota_manager_proxy_->GetUsageAndQuota( |
48 file_task_runner_, origin, FileSystemTypeToQuotaStorageType(type), | 48 file_task_runner_.get(), |
| 49 origin, |
| 50 FileSystemTypeToQuotaStorageType(type), |
49 base::Bind(&QuotaBackendImpl::DidGetUsageAndQuotaForReserveQuota, | 51 base::Bind(&QuotaBackendImpl::DidGetUsageAndQuotaForReserveQuota, |
50 weak_ptr_factory_.GetWeakPtr(), | 52 weak_ptr_factory_.GetWeakPtr(), |
51 QuotaReservationInfo(origin, type, delta), callback)); | 53 QuotaReservationInfo(origin, type, delta), |
| 54 callback)); |
52 } | 55 } |
53 | 56 |
54 void QuotaBackendImpl::ReleaseReservedQuota(const GURL& origin, | 57 void QuotaBackendImpl::ReleaseReservedQuota(const GURL& origin, |
55 FileSystemType type, | 58 FileSystemType type, |
56 int64 size) { | 59 int64 size) { |
57 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); | 60 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); |
58 DCHECK(origin.is_valid()); | 61 DCHECK(origin.is_valid()); |
59 DCHECK_LE(0, size); | 62 DCHECK_LE(0, size); |
60 if (!size) | 63 if (!size) |
61 return; | 64 return; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 // The requester could not accept the reserved quota. Revert it. | 132 // The requester could not accept the reserved quota. Revert it. |
130 ReserveQuotaInternal( | 133 ReserveQuotaInternal( |
131 QuotaReservationInfo(normalized_info.origin, | 134 QuotaReservationInfo(normalized_info.origin, |
132 normalized_info.type, | 135 normalized_info.type, |
133 -normalized_info.delta)); | 136 -normalized_info.delta)); |
134 } | 137 } |
135 | 138 |
136 void QuotaBackendImpl::ReserveQuotaInternal(const QuotaReservationInfo& info) { | 139 void QuotaBackendImpl::ReserveQuotaInternal(const QuotaReservationInfo& info) { |
137 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); | 140 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); |
138 DCHECK(info.origin.is_valid()); | 141 DCHECK(info.origin.is_valid()); |
139 DCHECK(quota_manager_proxy_); | 142 DCHECK(quota_manager_proxy_.get()); |
140 quota_manager_proxy_->NotifyStorageModified( | 143 quota_manager_proxy_->NotifyStorageModified( |
141 storage::QuotaClient::kFileSystem, | 144 storage::QuotaClient::kFileSystem, |
142 info.origin, | 145 info.origin, |
143 FileSystemTypeToQuotaStorageType(info.type), | 146 FileSystemTypeToQuotaStorageType(info.type), |
144 info.delta); | 147 info.delta); |
145 } | 148 } |
146 | 149 |
147 base::File::Error QuotaBackendImpl::GetUsageCachePath( | 150 base::File::Error QuotaBackendImpl::GetUsageCachePath( |
148 const GURL& origin, | 151 const GURL& origin, |
149 FileSystemType type, | 152 FileSystemType type, |
(...skipping 10 matching lines...) Expand all Loading... |
160 | 163 |
161 QuotaBackendImpl::QuotaReservationInfo::QuotaReservationInfo( | 164 QuotaBackendImpl::QuotaReservationInfo::QuotaReservationInfo( |
162 const GURL& origin, FileSystemType type, int64 delta) | 165 const GURL& origin, FileSystemType type, int64 delta) |
163 : origin(origin), type(type), delta(delta) { | 166 : origin(origin), type(type), delta(delta) { |
164 } | 167 } |
165 | 168 |
166 QuotaBackendImpl::QuotaReservationInfo::~QuotaReservationInfo() { | 169 QuotaBackendImpl::QuotaReservationInfo::~QuotaReservationInfo() { |
167 } | 170 } |
168 | 171 |
169 } // namespace storage | 172 } // namespace storage |
OLD | NEW |