OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "content/browser/indexed_db/indexed_db_transaction.h" | 5 #include "content/browser/indexed_db/indexed_db_transaction.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "content/browser/indexed_db/indexed_db_backing_store.h" | 11 #include "content/browser/indexed_db/indexed_db_backing_store.h" |
12 #include "content/browser/indexed_db/indexed_db_cursor.h" | 12 #include "content/browser/indexed_db/indexed_db_cursor.h" |
13 #include "content/browser/indexed_db/indexed_db_database.h" | 13 #include "content/browser/indexed_db/indexed_db_database.h" |
14 #include "content/browser/indexed_db/indexed_db_database_callbacks.h" | 14 #include "content/browser/indexed_db/indexed_db_database_callbacks.h" |
15 #include "content/browser/indexed_db/indexed_db_tracing.h" | 15 #include "content/browser/indexed_db/indexed_db_tracing.h" |
16 #include "content/browser/indexed_db/indexed_db_transaction_coordinator.h" | 16 #include "content/browser/indexed_db/indexed_db_transaction_coordinator.h" |
17 #include "third_party/WebKit/public/platform/WebIDBDatabaseException.h" | 17 #include "third_party/WebKit/public/platform/WebIDBDatabaseException.h" |
| 18 #include "third_party/leveldatabase/env_chromium.h" |
18 | 19 |
19 namespace content { | 20 namespace content { |
20 | 21 |
21 const int64 kInactivityTimeoutPeriodSeconds = 60; | 22 const int64 kInactivityTimeoutPeriodSeconds = 60; |
22 | 23 |
23 IndexedDBTransaction::TaskQueue::TaskQueue() {} | 24 IndexedDBTransaction::TaskQueue::TaskQueue() {} |
24 IndexedDBTransaction::TaskQueue::~TaskQueue() { clear(); } | 25 IndexedDBTransaction::TaskQueue::~TaskQueue() { clear(); } |
25 | 26 |
26 void IndexedDBTransaction::TaskQueue::clear() { | 27 void IndexedDBTransaction::TaskQueue::clear() { |
27 while (!queue_.empty()) | 28 while (!queue_.empty()) |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 database_->transaction_coordinator().DidFinishTransaction(this); | 312 database_->transaction_coordinator().DidFinishTransaction(this); |
312 | 313 |
313 if (committed) { | 314 if (committed) { |
314 abort_task_stack_.clear(); | 315 abort_task_stack_.clear(); |
315 callbacks_->OnComplete(id_); | 316 callbacks_->OnComplete(id_); |
316 database_->TransactionFinished(this, true); | 317 database_->TransactionFinished(this, true); |
317 } else { | 318 } else { |
318 while (!abort_task_stack_.empty()) | 319 while (!abort_task_stack_.empty()) |
319 abort_task_stack_.pop().Run(NULL); | 320 abort_task_stack_.pop().Run(NULL); |
320 | 321 |
321 callbacks_->OnAbort( | 322 IndexedDBDatabaseError error; |
322 id_, | 323 if (leveldb_env::IndicatesDiskFull(s)) { |
323 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionUnknownError, | 324 error = IndexedDBDatabaseError( |
324 "Internal error committing transaction.")); | 325 blink::WebIDBDatabaseExceptionQuotaError, |
| 326 "Encountered disk full while committing transaction."); |
| 327 } else { |
| 328 error = IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionUnknownError, |
| 329 "Internal error committing transaction."); |
| 330 } |
| 331 callbacks_->OnAbort(id_, error); |
| 332 |
325 database_->TransactionFinished(this, false); | 333 database_->TransactionFinished(this, false); |
326 database_->TransactionCommitFailed(s); | 334 database_->TransactionCommitFailed(s); |
327 } | 335 } |
328 | 336 |
329 database_ = NULL; | 337 database_ = NULL; |
330 return s; | 338 return s; |
331 } | 339 } |
332 | 340 |
333 void IndexedDBTransaction::ProcessTaskQueue() { | 341 void IndexedDBTransaction::ProcessTaskQueue() { |
334 IDB_TRACE1("IndexedDBTransaction::ProcessTaskQueue", "txn.id", id()); | 342 IDB_TRACE1("IndexedDBTransaction::ProcessTaskQueue", "txn.id", id()); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 base::ASCIIToUTF16("Transaction timed out due to inactivity."))); | 404 base::ASCIIToUTF16("Transaction timed out due to inactivity."))); |
397 } | 405 } |
398 | 406 |
399 void IndexedDBTransaction::CloseOpenCursors() { | 407 void IndexedDBTransaction::CloseOpenCursors() { |
400 for (auto* cursor : open_cursors_) | 408 for (auto* cursor : open_cursors_) |
401 cursor->Close(); | 409 cursor->Close(); |
402 open_cursors_.clear(); | 410 open_cursors_.clear(); |
403 } | 411 } |
404 | 412 |
405 } // namespace content | 413 } // namespace content |
OLD | NEW |