summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authortzik@chromium.org <tzik@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-17 10:17:48 +0000
committertzik@chromium.org <tzik@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-17 10:17:48 +0000
commitaf3dfe9c5cf20ffd957fc83fa23599ccf2652c73 (patch)
tree0ad917b08ce9ac01ecadf83c9d4c844d45554941 /webkit
parentd14eb5585a2a48b775d2103a4521cd3a53450f54 (diff)
downloadchromium_src-af3dfe9c5cf20ffd957fc83fa23599ccf2652c73.zip
chromium_src-af3dfe9c5cf20ffd957fc83fa23599ccf2652c73.tar.gz
chromium_src-af3dfe9c5cf20ffd957fc83fa23599ccf2652c73.tar.bz2
[FileAPI] Ignore requests after QuotaReservation::OnClientCrash call.
When a client crash detected, the associated QuotaReservation object reclaims its reserved quota. And then, in-flight operations should be ignored. Review URL: https://codereview.chromium.org/139833006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245481 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/browser/fileapi/quota/quota_reservation.cc22
-rw-r--r--webkit/browser/fileapi/quota/quota_reservation.h3
2 files changed, 19 insertions, 6 deletions
diff --git a/webkit/browser/fileapi/quota/quota_reservation.cc b/webkit/browser/fileapi/quota/quota_reservation.cc
index c5a22ab..da4ef95 100644
--- a/webkit/browser/fileapi/quota/quota_reservation.cc
+++ b/webkit/browser/fileapi/quota/quota_reservation.cc
@@ -15,6 +15,7 @@ void QuotaReservation::RefreshReservation(
const StatusCallback& callback) {
DCHECK(sequence_checker_.CalledOnValidSequencedThread());
DCHECK(!running_refresh_request_);
+ DCHECK(!client_crashed_);
if (!reservation_manager())
return;
@@ -33,11 +34,13 @@ void QuotaReservation::RefreshReservation(
scoped_ptr<OpenFileHandle> QuotaReservation::GetOpenFileHandle(
const base::FilePath& platform_path) {
DCHECK(sequence_checker_.CalledOnValidSequencedThread());
+ DCHECK(!client_crashed_);
return reservation_buffer_->GetOpenFileHandle(this, platform_path);
}
void QuotaReservation::OnClientCrash() {
DCHECK(sequence_checker_.CalledOnValidSequencedThread());
+ client_crashed_ = true;
if (remaining_quota_) {
reservation_buffer_->PutReservationToBuffer(remaining_quota_);
@@ -48,7 +51,9 @@ void QuotaReservation::OnClientCrash() {
void QuotaReservation::ConsumeReservation(int64 size) {
DCHECK(sequence_checker_.CalledOnValidSequencedThread());
DCHECK_LT(0, size);
- DCHECK_LT(size, remaining_quota_);
+ DCHECK_LE(size, remaining_quota_);
+ if (client_crashed_)
+ return;
remaining_quota_ -= size;
reservation_buffer_->PutReservationToBuffer(size);
@@ -68,7 +73,8 @@ FileSystemType QuotaReservation::type() const {
QuotaReservation::QuotaReservation(
QuotaReservationBuffer* reservation_buffer)
- : running_refresh_request_(false),
+ : client_crashed_(false),
+ running_refresh_request_(false),
remaining_quota_(0),
reservation_buffer_(reservation_buffer),
weak_ptr_factory_(this) {
@@ -93,11 +99,11 @@ bool QuotaReservation::AdaptDidUpdateReservedQuota(
if (!reservation)
return false;
- reservation->DidUpdateReservedQuota(new_reserved_size, callback, error);
- return true;
+ return reservation->DidUpdateReservedQuota(
+ new_reserved_size, callback, error);
}
-void QuotaReservation::DidUpdateReservedQuota(
+bool QuotaReservation::DidUpdateReservedQuota(
int64 new_reserved_size,
const StatusCallback& callback,
base::PlatformFileError error) {
@@ -105,9 +111,15 @@ void QuotaReservation::DidUpdateReservedQuota(
DCHECK(running_refresh_request_);
running_refresh_request_ = false;
+ if (client_crashed_) {
+ callback.Run(base::PLATFORM_FILE_ERROR_ABORT);
+ return false;
+ }
+
if (error == base::PLATFORM_FILE_OK)
remaining_quota_ = new_reserved_size;
callback.Run(error);
+ return true;
}
} // namespace fileapi
diff --git a/webkit/browser/fileapi/quota/quota_reservation.h b/webkit/browser/fileapi/quota/quota_reservation.h
index d534a0d..18fbcb4 100644
--- a/webkit/browser/fileapi/quota/quota_reservation.h
+++ b/webkit/browser/fileapi/quota/quota_reservation.h
@@ -69,10 +69,11 @@ class WEBKIT_STORAGE_BROWSER_EXPORT QuotaReservation
int64 new_reserved_size,
const StatusCallback& callback,
base::PlatformFileError error);
- void DidUpdateReservedQuota(int64 new_reserved_size,
+ bool DidUpdateReservedQuota(int64 new_reserved_size,
const StatusCallback& callback,
base::PlatformFileError error);
+ bool client_crashed_;
bool running_refresh_request_;
int64 remaining_quota_;