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_reservation_buffer.h" | 5 #include "storage/browser/fileapi/quota/quota_reservation_buffer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "webkit/browser/fileapi/quota/open_file_handle.h" | 8 #include "storage/browser/fileapi/quota/open_file_handle.h" |
9 #include "webkit/browser/fileapi/quota/open_file_handle_context.h" | 9 #include "storage/browser/fileapi/quota/open_file_handle_context.h" |
10 #include "webkit/browser/fileapi/quota/quota_reservation.h" | 10 #include "storage/browser/fileapi/quota/quota_reservation.h" |
11 | 11 |
12 namespace fileapi { | 12 namespace storage { |
13 | 13 |
14 QuotaReservationBuffer::QuotaReservationBuffer( | 14 QuotaReservationBuffer::QuotaReservationBuffer( |
15 base::WeakPtr<QuotaReservationManager> reservation_manager, | 15 base::WeakPtr<QuotaReservationManager> reservation_manager, |
16 const GURL& origin, | 16 const GURL& origin, |
17 FileSystemType type) | 17 FileSystemType type) |
18 : reservation_manager_(reservation_manager), | 18 : reservation_manager_(reservation_manager), |
19 origin_(origin), | 19 origin_(origin), |
20 type_(type), | 20 type_(type), |
21 reserved_quota_(0) { | 21 reserved_quota_(0) { |
22 DCHECK(origin.is_valid()); | 22 DCHECK(origin.is_valid()); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 } | 73 } |
74 | 74 |
75 QuotaReservationBuffer::~QuotaReservationBuffer() { | 75 QuotaReservationBuffer::~QuotaReservationBuffer() { |
76 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 76 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); |
77 if (!reservation_manager_) | 77 if (!reservation_manager_) |
78 return; | 78 return; |
79 | 79 |
80 DCHECK_LE(0, reserved_quota_); | 80 DCHECK_LE(0, reserved_quota_); |
81 if (reserved_quota_ && reservation_manager_) { | 81 if (reserved_quota_ && reservation_manager_) { |
82 reservation_manager_->ReserveQuota( | 82 reservation_manager_->ReserveQuota( |
83 origin_, type_, -reserved_quota_, | 83 origin_, |
| 84 type_, |
| 85 -reserved_quota_, |
84 base::Bind(&QuotaReservationBuffer::DecrementDirtyCount, | 86 base::Bind(&QuotaReservationBuffer::DecrementDirtyCount, |
85 reservation_manager_, origin_, type_)); | 87 reservation_manager_, |
| 88 origin_, |
| 89 type_)); |
86 } | 90 } |
87 reservation_manager_->ReleaseReservationBuffer(this); | 91 reservation_manager_->ReleaseReservationBuffer(this); |
88 } | 92 } |
89 | 93 |
90 // static | 94 // static |
91 bool QuotaReservationBuffer::DecrementDirtyCount( | 95 bool QuotaReservationBuffer::DecrementDirtyCount( |
92 base::WeakPtr<QuotaReservationManager> reservation_manager, | 96 base::WeakPtr<QuotaReservationManager> reservation_manager, |
93 const GURL& origin, | 97 const GURL& origin, |
94 FileSystemType type, | 98 FileSystemType type, |
95 base::File::Error error, | 99 base::File::Error error, |
96 int64 delta_unused) { | 100 int64 delta_unused) { |
97 DCHECK(origin.is_valid()); | 101 DCHECK(origin.is_valid()); |
98 if (error == base::File::FILE_OK && reservation_manager) { | 102 if (error == base::File::FILE_OK && reservation_manager) { |
99 reservation_manager->DecrementDirtyCount(origin, type); | 103 reservation_manager->DecrementDirtyCount(origin, type); |
100 return true; | 104 return true; |
101 } | 105 } |
102 return false; | 106 return false; |
103 } | 107 } |
104 | 108 |
105 | 109 } // namespace storage |
106 } // namespace fileapi | |
OLD | NEW |