• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #include "storage/browser/fileapi/quota/open_file_handle.h"
6 
7 #include "storage/browser/fileapi/quota/open_file_handle_context.h"
8 #include "storage/browser/fileapi/quota/quota_reservation.h"
9 
10 namespace storage {
11 
~OpenFileHandle()12 OpenFileHandle::~OpenFileHandle() {
13   DCHECK(sequence_checker_.CalledOnValidSequencedThread());
14 }
15 
UpdateMaxWrittenOffset(int64 offset)16 void OpenFileHandle::UpdateMaxWrittenOffset(int64 offset) {
17   DCHECK(sequence_checker_.CalledOnValidSequencedThread());
18 
19   int64 growth = context_->UpdateMaxWrittenOffset(offset);
20   if (growth > 0)
21     reservation_->ConsumeReservation(growth);
22 }
23 
AddAppendModeWriteAmount(int64 amount)24 void OpenFileHandle::AddAppendModeWriteAmount(int64 amount) {
25   DCHECK(sequence_checker_.CalledOnValidSequencedThread());
26   if (amount <= 0)
27     return;
28 
29   context_->AddAppendModeWriteAmount(amount);
30   reservation_->ConsumeReservation(amount);
31 }
32 
GetEstimatedFileSize() const33 int64 OpenFileHandle::GetEstimatedFileSize() const {
34   DCHECK(sequence_checker_.CalledOnValidSequencedThread());
35   return context_->GetEstimatedFileSize();
36 }
37 
GetMaxWrittenOffset() const38 int64 OpenFileHandle::GetMaxWrittenOffset() const {
39   DCHECK(sequence_checker_.CalledOnValidSequencedThread());
40   return context_->GetMaxWrittenOffset();
41 }
42 
platform_path() const43 const base::FilePath& OpenFileHandle::platform_path() const {
44   DCHECK(sequence_checker_.CalledOnValidSequencedThread());
45   return context_->platform_path();
46 }
47 
OpenFileHandle(QuotaReservation * reservation,OpenFileHandleContext * context)48 OpenFileHandle::OpenFileHandle(QuotaReservation* reservation,
49                                OpenFileHandleContext* context)
50     : reservation_(reservation),
51       context_(context) {
52   DCHECK(sequence_checker_.CalledOnValidSequencedThread());
53 }
54 
55 }  // namespace storage
56