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

Unified Diff: webkit/browser/fileapi/quota/quota_reservation_buffer.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 side-by-side diff with in-line comments
Download patch
Index: webkit/browser/fileapi/quota/quota_reservation_buffer.cc
diff --git a/webkit/browser/fileapi/quota/quota_reservation_buffer.cc b/webkit/browser/fileapi/quota/quota_reservation_buffer.cc
deleted file mode 100644
index cfa567fc53330d7a2b168091661de44237be1e60..0000000000000000000000000000000000000000
--- a/webkit/browser/fileapi/quota/quota_reservation_buffer.cc
+++ /dev/null
@@ -1,105 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "webkit/browser/fileapi/quota/quota_reservation_buffer.h"
-
-#include "base/bind.h"
-#include "webkit/browser/fileapi/quota/open_file_handle.h"
-#include "webkit/browser/fileapi/quota/open_file_handle_context.h"
-#include "webkit/browser/fileapi/quota/quota_reservation.h"
-
-namespace storage {
-
-QuotaReservationBuffer::QuotaReservationBuffer(
- base::WeakPtr<QuotaReservationManager> reservation_manager,
- const GURL& origin,
- FileSystemType type)
- : reservation_manager_(reservation_manager),
- origin_(origin),
- type_(type),
- reserved_quota_(0) {
- DCHECK(origin.is_valid());
- DCHECK(sequence_checker_.CalledOnValidSequencedThread());
- reservation_manager_->IncrementDirtyCount(origin, type);
-}
-
-scoped_refptr<QuotaReservation> QuotaReservationBuffer::CreateReservation() {
- DCHECK(sequence_checker_.CalledOnValidSequencedThread());
- return make_scoped_refptr(new QuotaReservation(this));
-}
-
-scoped_ptr<OpenFileHandle> QuotaReservationBuffer::GetOpenFileHandle(
- QuotaReservation* reservation,
- const base::FilePath& platform_path) {
- DCHECK(sequence_checker_.CalledOnValidSequencedThread());
- OpenFileHandleContext** open_file = &open_files_[platform_path];
- if (!*open_file)
- *open_file = new OpenFileHandleContext(platform_path, this);
- return make_scoped_ptr(new OpenFileHandle(reservation, *open_file));
-}
-
-void QuotaReservationBuffer::CommitFileGrowth(int64 reserved_quota_consumption,
- int64 usage_delta) {
- DCHECK(sequence_checker_.CalledOnValidSequencedThread());
- if (!reservation_manager_)
- return;
- reservation_manager_->CommitQuotaUsage(origin_, type_, usage_delta);
-
- if (reserved_quota_consumption > 0) {
- if (reserved_quota_consumption > reserved_quota_) {
- LOG(ERROR) << "Detected over consumption of the storage quota beyond its"
- << " reservation";
- reserved_quota_consumption = reserved_quota_;
- }
-
- reserved_quota_ -= reserved_quota_consumption;
- reservation_manager_->ReleaseReservedQuota(
- origin_, type_, reserved_quota_consumption);
- }
-}
-
-void QuotaReservationBuffer::DetachOpenFileHandleContext(
- OpenFileHandleContext* open_file) {
- DCHECK(sequence_checker_.CalledOnValidSequencedThread());
- DCHECK_EQ(open_file, open_files_[open_file->platform_path()]);
- open_files_.erase(open_file->platform_path());
-}
-
-void QuotaReservationBuffer::PutReservationToBuffer(int64 reservation) {
- DCHECK(sequence_checker_.CalledOnValidSequencedThread());
- DCHECK_LE(0, reservation);
- reserved_quota_ += reservation;
-}
-
-QuotaReservationBuffer::~QuotaReservationBuffer() {
- DCHECK(sequence_checker_.CalledOnValidSequencedThread());
- if (!reservation_manager_)
- return;
-
- DCHECK_LE(0, reserved_quota_);
- if (reserved_quota_ && reservation_manager_) {
- reservation_manager_->ReserveQuota(
- origin_, type_, -reserved_quota_,
- base::Bind(&QuotaReservationBuffer::DecrementDirtyCount,
- reservation_manager_, origin_, type_));
- }
- reservation_manager_->ReleaseReservationBuffer(this);
-}
-
-// static
-bool QuotaReservationBuffer::DecrementDirtyCount(
- base::WeakPtr<QuotaReservationManager> reservation_manager,
- const GURL& origin,
- FileSystemType type,
- base::File::Error error,
- int64 delta_unused) {
- DCHECK(origin.is_valid());
- if (error == base::File::FILE_OK && reservation_manager) {
- reservation_manager->DecrementDirtyCount(origin, type);
- return true;
- }
- return false;
-}
-
-} // namespace storage

Powered by Google App Engine
This is Rietveld 408576698