Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: webkit/browser/fileapi/quota/quota_reservation_buffer.cc

Issue 61593002: Quota: Implement QuotaBackendImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix build and test Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 11
12 namespace fileapi { 12 namespace fileapi {
13 13
14 namespace { 14 namespace {
15 15
16 void IgnoreResult(base::PlatformFileError error) {} 16 void IgnoreResult(base::PlatformFileError error) {}
17 17
18 } // namespace 18 } // namespace
19 19
20 QuotaReservationBuffer::QuotaReservationBuffer( 20 QuotaReservationBuffer::QuotaReservationBuffer(
21 base::WeakPtr<QuotaReservationManager> reservation_manager, 21 base::WeakPtr<QuotaReservationManager> reservation_manager,
22 const GURL& origin, 22 const GURL& origin,
23 FileSystemType type) 23 FileSystemType type)
24 : reservation_manager_(reservation_manager), 24 : reservation_manager_(reservation_manager),
25 origin_(origin), 25 origin_(origin),
26 type_(type), 26 type_(type),
27 reserved_quota_(0) { 27 reserved_quota_(0) {
28 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); 28 DCHECK(sequence_checker_.CalledOnValidSequencedThread());
29 reservation_manager_->IncreaseDirtyCount(origin, type); 29 reservation_manager_->IncrementDirtyCount(origin, type);
30 } 30 }
31 31
32 scoped_refptr<QuotaReservation> QuotaReservationBuffer::CreateReservation() { 32 scoped_refptr<QuotaReservation> QuotaReservationBuffer::CreateReservation() {
33 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); 33 DCHECK(sequence_checker_.CalledOnValidSequencedThread());
34 return make_scoped_refptr(new QuotaReservation(this)); 34 return make_scoped_refptr(new QuotaReservation(this));
35 } 35 }
36 36
37 scoped_ptr<OpenFileHandle> QuotaReservationBuffer::GetOpenFileHandle( 37 scoped_ptr<OpenFileHandle> QuotaReservationBuffer::GetOpenFileHandle(
38 QuotaReservation* reservation, 38 QuotaReservation* reservation,
39 const base::FilePath& platform_path) { 39 const base::FilePath& platform_path) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 QuotaReservationBuffer::~QuotaReservationBuffer() { 78 QuotaReservationBuffer::~QuotaReservationBuffer() {
79 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); 79 DCHECK(sequence_checker_.CalledOnValidSequencedThread());
80 if (!reservation_manager_) 80 if (!reservation_manager_)
81 return; 81 return;
82 82
83 DCHECK_LE(0, reserved_quota_); 83 DCHECK_LE(0, reserved_quota_);
84 if (reserved_quota_ && reservation_manager_) { 84 if (reserved_quota_ && reservation_manager_) {
85 reservation_manager_->ReserveQuota( 85 reservation_manager_->ReserveQuota(
86 origin_, type_, -reserved_quota_, 86 origin_, type_, -reserved_quota_,
87 base::Bind(&QuotaReservationBuffer::DecreaseDirtyCount, 87 base::Bind(&QuotaReservationBuffer::DecrementDirtyCount,
88 reservation_manager_, origin_, type_)); 88 reservation_manager_, origin_, type_));
89 } 89 }
90 reservation_manager_->ReleaseReservationBuffer(this); 90 reservation_manager_->ReleaseReservationBuffer(this);
91 } 91 }
92 92
93 // static 93 // static
94 bool QuotaReservationBuffer::DecreaseDirtyCount( 94 bool QuotaReservationBuffer::DecrementDirtyCount(
95 base::WeakPtr<QuotaReservationManager> reservation_manager, 95 base::WeakPtr<QuotaReservationManager> reservation_manager,
96 const GURL& origin, 96 const GURL& origin,
97 FileSystemType type, 97 FileSystemType type,
98 base::PlatformFileError error) { 98 base::PlatformFileError error) {
99 if (error == base::PLATFORM_FILE_OK && reservation_manager) { 99 if (error == base::PLATFORM_FILE_OK && reservation_manager) {
100 reservation_manager->DecreaseDirtyCount(origin, type); 100 reservation_manager->DecrementDirtyCount(origin, type);
101 return true; 101 return true;
102 } 102 }
103 return false; 103 return false;
104 } 104 }
105 105
106 106
107 } // namespace fileapi 107 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698