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

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

Issue 539143002: Migrate webkit/browser/ to storage/browser/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months 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
OLDNEW
(Empty)
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 "webkit/browser/fileapi/quota/quota_reservation_manager.h"
6
7 #include "webkit/browser/fileapi/quota/quota_reservation.h"
8 #include "webkit/browser/fileapi/quota/quota_reservation_buffer.h"
9
10 namespace storage {
11
12 QuotaReservationManager::QuotaReservationManager(
13 scoped_ptr<QuotaBackend> backend)
14 : backend_(backend.Pass()),
15 weak_ptr_factory_(this) {
16 sequence_checker_.DetachFromSequence();
17 }
18
19 QuotaReservationManager::~QuotaReservationManager() {
20 DCHECK(sequence_checker_.CalledOnValidSequencedThread());
21 }
22
23 void QuotaReservationManager::ReserveQuota(
24 const GURL& origin,
25 FileSystemType type,
26 int64 size,
27 const ReserveQuotaCallback& callback) {
28 DCHECK(origin.is_valid());
29 backend_->ReserveQuota(origin, type, size, callback);
30 }
31
32 void QuotaReservationManager::ReleaseReservedQuota(
33 const GURL& origin,
34 FileSystemType type,
35 int64 size) {
36 DCHECK(origin.is_valid());
37 backend_->ReleaseReservedQuota(origin, type, size);
38 }
39
40 void QuotaReservationManager::CommitQuotaUsage(
41 const GURL& origin,
42 FileSystemType type,
43 int64 delta) {
44 DCHECK(origin.is_valid());
45 backend_->CommitQuotaUsage(origin, type, delta);
46 }
47
48 void QuotaReservationManager::IncrementDirtyCount(const GURL& origin,
49 FileSystemType type) {
50 DCHECK(origin.is_valid());
51 backend_->IncrementDirtyCount(origin, type);
52 }
53
54 void QuotaReservationManager::DecrementDirtyCount(const GURL& origin,
55 FileSystemType type) {
56 DCHECK(origin.is_valid());
57 backend_->DecrementDirtyCount(origin, type);
58 }
59
60 scoped_refptr<QuotaReservationBuffer>
61 QuotaReservationManager::GetReservationBuffer(
62 const GURL& origin,
63 FileSystemType type) {
64 DCHECK(sequence_checker_.CalledOnValidSequencedThread());
65 DCHECK(origin.is_valid());
66 QuotaReservationBuffer** buffer =
67 &reservation_buffers_[std::make_pair(origin, type)];
68 if (!*buffer) {
69 *buffer = new QuotaReservationBuffer(
70 weak_ptr_factory_.GetWeakPtr(), origin, type);
71 }
72 return make_scoped_refptr(*buffer);
73 }
74
75 void QuotaReservationManager::ReleaseReservationBuffer(
76 QuotaReservationBuffer* reservation_buffer) {
77 DCHECK(sequence_checker_.CalledOnValidSequencedThread());
78 std::pair<GURL, FileSystemType> key(reservation_buffer->origin(),
79 reservation_buffer->type());
80 DCHECK_EQ(reservation_buffers_[key], reservation_buffer);
81 reservation_buffers_.erase(key);
82 }
83
84 scoped_refptr<QuotaReservation> QuotaReservationManager::CreateReservation(
85 const GURL& origin,
86 FileSystemType type) {
87 DCHECK(origin.is_valid());
88 return GetReservationBuffer(origin, type)->CreateReservation();;
89 }
90
91 } // namespace storage
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698