| 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 "webkit/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 "webkit/browser/fileapi/quota/open_file_handle.h" |
| 9 #include "webkit/browser/fileapi/quota/open_file_handle_context.h" | 9 #include "webkit/browser/fileapi/quota/open_file_handle_context.h" |
| 10 #include "webkit/browser/fileapi/quota/quota_reservation.h" | 10 #include "webkit/browser/fileapi/quota/quota_reservation.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 return make_scoped_ptr(new OpenFileHandle(reservation, *open_file)); | 39 return make_scoped_ptr(new OpenFileHandle(reservation, *open_file)); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void QuotaReservationBuffer::CommitFileGrowth(int64 quota_consumption, | 42 void QuotaReservationBuffer::CommitFileGrowth(int64 quota_consumption, |
| 43 int64 usage_delta) { | 43 int64 usage_delta) { |
| 44 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 44 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); |
| 45 if (!reservation_manager_) | 45 if (!reservation_manager_) |
| 46 return; | 46 return; |
| 47 reservation_manager_->CommitQuotaUsage(origin_, type_, usage_delta); | 47 reservation_manager_->CommitQuotaUsage(origin_, type_, usage_delta); |
| 48 | 48 |
| 49 DCHECK_LE(quota_consumption, reserved_quota_); | |
| 50 if (quota_consumption > 0) { | 49 if (quota_consumption > 0) { |
| 50 if (quota_consumption > reserved_quota_) { |
| 51 LOG(ERROR) << "Detected over consumption of the storage quota beyond its" |
| 52 << " reservation"; |
| 53 quota_consumption = reserved_quota_; |
| 54 } |
| 55 |
| 51 reserved_quota_ -= quota_consumption; | 56 reserved_quota_ -= quota_consumption; |
| 52 reservation_manager_->ReleaseReservedQuota( | 57 reservation_manager_->ReleaseReservedQuota( |
| 53 origin_, type_, quota_consumption); | 58 origin_, type_, quota_consumption); |
| 54 } | 59 } |
| 55 } | 60 } |
| 56 | 61 |
| 57 void QuotaReservationBuffer::DetachOpenFileHandleContext( | 62 void QuotaReservationBuffer::DetachOpenFileHandleContext( |
| 58 OpenFileHandleContext* open_file) { | 63 OpenFileHandleContext* open_file) { |
| 59 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 64 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); |
| 60 DCHECK_EQ(open_file, open_files_[open_file->platform_path()]); | 65 DCHECK_EQ(open_file, open_files_[open_file->platform_path()]); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 91 DCHECK(origin.is_valid()); | 96 DCHECK(origin.is_valid()); |
| 92 if (error == base::PLATFORM_FILE_OK && reservation_manager) { | 97 if (error == base::PLATFORM_FILE_OK && reservation_manager) { |
| 93 reservation_manager->DecrementDirtyCount(origin, type); | 98 reservation_manager->DecrementDirtyCount(origin, type); |
| 94 return true; | 99 return true; |
| 95 } | 100 } |
| 96 return false; | 101 return false; |
| 97 } | 102 } |
| 98 | 103 |
| 99 | 104 |
| 100 } // namespace fileapi | 105 } // namespace fileapi |
| OLD | NEW |