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

Side by Side Diff: content/browser/indexed_db/indexed_db_transaction.cc

Issue 180163010: IndexedDB: Don't timeout read-only transactions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Abort the transaction to avoid leaks Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/indexed_db/indexed_db_transaction_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 if (!HasPendingTasks() && state_ != FINISHED && commit_pending_) { 311 if (!HasPendingTasks() && state_ != FINISHED && commit_pending_) {
312 Commit(); 312 Commit();
313 return; 313 return;
314 } 314 }
315 315
316 // The transaction may have been aborted while processing tasks. 316 // The transaction may have been aborted while processing tasks.
317 if (state_ == FINISHED) 317 if (state_ == FINISHED)
318 return; 318 return;
319 319
320 // Otherwise, start a timer in case the front-end gets wedged and 320 // Otherwise, start a timer in case the front-end gets wedged and
321 // never requests further activity. 321 // never requests further activity. Read-only transactions don't
322 timeout_timer_.Start( 322 // block other transactions, so don't time those out.
323 FROM_HERE, 323 if (mode_ != indexed_db::TRANSACTION_READ_ONLY) {
324 base::TimeDelta::FromSeconds(kInactivityTimeoutPeriodSeconds), 324 timeout_timer_.Start(
325 base::Bind(&IndexedDBTransaction::Timeout, this)); 325 FROM_HERE,
326 base::TimeDelta::FromSeconds(kInactivityTimeoutPeriodSeconds),
327 base::Bind(&IndexedDBTransaction::Timeout, this));
328 }
326 } 329 }
327 330
328 void IndexedDBTransaction::Timeout() { 331 void IndexedDBTransaction::Timeout() {
329 Abort(IndexedDBDatabaseError( 332 Abort(IndexedDBDatabaseError(
330 blink::WebIDBDatabaseExceptionTimeoutError, 333 blink::WebIDBDatabaseExceptionTimeoutError,
331 base::ASCIIToUTF16("Transaction timed out due to inactivity."))); 334 base::ASCIIToUTF16("Transaction timed out due to inactivity.")));
332 } 335 }
333 336
334 void IndexedDBTransaction::CloseOpenCursors() { 337 void IndexedDBTransaction::CloseOpenCursors() {
335 for (std::set<IndexedDBCursor*>::iterator i = open_cursors_.begin(); 338 for (std::set<IndexedDBCursor*>::iterator i = open_cursors_.begin();
336 i != open_cursors_.end(); 339 i != open_cursors_.end();
337 ++i) 340 ++i)
338 (*i)->Close(); 341 (*i)->Close();
339 open_cursors_.clear(); 342 open_cursors_.clear();
340 } 343 }
341 344
342 } // namespace content 345 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/indexed_db/indexed_db_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698