| 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 "storage/browser/fileapi/quota/open_file_handle.h" | 5 #include "storage/browser/fileapi/quota/open_file_handle.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "storage/browser/fileapi/quota/open_file_handle_context.h" | 9 #include "storage/browser/fileapi/quota/open_file_handle_context.h" |
| 10 #include "storage/browser/fileapi/quota/quota_reservation.h" | 10 #include "storage/browser/fileapi/quota/quota_reservation.h" |
| 11 | 11 |
| 12 namespace storage { | 12 namespace storage { |
| 13 | 13 |
| 14 OpenFileHandle::~OpenFileHandle() { | 14 OpenFileHandle::~OpenFileHandle() { |
| 15 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 15 DCHECK(sequence_checker_.CalledOnValidSequence()); |
| 16 } | 16 } |
| 17 | 17 |
| 18 void OpenFileHandle::UpdateMaxWrittenOffset(int64_t offset) { | 18 void OpenFileHandle::UpdateMaxWrittenOffset(int64_t offset) { |
| 19 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 19 DCHECK(sequence_checker_.CalledOnValidSequence()); |
| 20 | 20 |
| 21 int64_t growth = context_->UpdateMaxWrittenOffset(offset); | 21 int64_t growth = context_->UpdateMaxWrittenOffset(offset); |
| 22 if (growth > 0) | 22 if (growth > 0) |
| 23 reservation_->ConsumeReservation(growth); | 23 reservation_->ConsumeReservation(growth); |
| 24 } | 24 } |
| 25 | 25 |
| 26 void OpenFileHandle::AddAppendModeWriteAmount(int64_t amount) { | 26 void OpenFileHandle::AddAppendModeWriteAmount(int64_t amount) { |
| 27 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 27 DCHECK(sequence_checker_.CalledOnValidSequence()); |
| 28 if (amount <= 0) | 28 if (amount <= 0) |
| 29 return; | 29 return; |
| 30 | 30 |
| 31 context_->AddAppendModeWriteAmount(amount); | 31 context_->AddAppendModeWriteAmount(amount); |
| 32 reservation_->ConsumeReservation(amount); | 32 reservation_->ConsumeReservation(amount); |
| 33 } | 33 } |
| 34 | 34 |
| 35 int64_t OpenFileHandle::GetEstimatedFileSize() const { | 35 int64_t OpenFileHandle::GetEstimatedFileSize() const { |
| 36 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 36 DCHECK(sequence_checker_.CalledOnValidSequence()); |
| 37 return context_->GetEstimatedFileSize(); | 37 return context_->GetEstimatedFileSize(); |
| 38 } | 38 } |
| 39 | 39 |
| 40 int64_t OpenFileHandle::GetMaxWrittenOffset() const { | 40 int64_t OpenFileHandle::GetMaxWrittenOffset() const { |
| 41 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 41 DCHECK(sequence_checker_.CalledOnValidSequence()); |
| 42 return context_->GetMaxWrittenOffset(); | 42 return context_->GetMaxWrittenOffset(); |
| 43 } | 43 } |
| 44 | 44 |
| 45 const base::FilePath& OpenFileHandle::platform_path() const { | 45 const base::FilePath& OpenFileHandle::platform_path() const { |
| 46 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 46 DCHECK(sequence_checker_.CalledOnValidSequence()); |
| 47 return context_->platform_path(); | 47 return context_->platform_path(); |
| 48 } | 48 } |
| 49 | 49 |
| 50 OpenFileHandle::OpenFileHandle(QuotaReservation* reservation, | 50 OpenFileHandle::OpenFileHandle(QuotaReservation* reservation, |
| 51 OpenFileHandleContext* context) | 51 OpenFileHandleContext* context) |
| 52 : reservation_(reservation), | 52 : reservation_(reservation), |
| 53 context_(context) { | 53 context_(context) { |
| 54 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 54 DCHECK(sequence_checker_.CalledOnValidSequence()); |
| 55 } | 55 } |
| 56 | 56 |
| 57 } // namespace storage | 57 } // namespace storage |
| OLD | NEW |