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

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

Issue 2784003002: [IndexedDB] Mojo testing harness. (Closed)
Patch Set: comments Created 3 years, 7 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
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/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 break; 281 break;
282 } 282 }
283 } 283 }
284 return s; 284 return s;
285 } 285 }
286 286
287 leveldb::Status IndexedDBTransaction::Commit() { 287 leveldb::Status IndexedDBTransaction::Commit() {
288 IDB_TRACE1("IndexedDBTransaction::Commit", "txn.id", id()); 288 IDB_TRACE1("IndexedDBTransaction::Commit", "txn.id", id());
289 289
290 timeout_timer_.Stop(); 290 timeout_timer_.Stop();
291
292 // In multiprocess ports, front-end may have requested a commit but 291 // In multiprocess ports, front-end may have requested a commit but
293 // an abort has already been initiated asynchronously by the 292 // an abort has already been initiated asynchronously by the
294 // back-end. 293 // back-end.
295 if (state_ == FINISHED) 294 if (state_ == FINISHED)
296 return leveldb::Status::OK(); 295 return leveldb::Status::OK();
297 DCHECK_NE(state_, COMMITTING); 296 DCHECK_NE(state_, COMMITTING);
298 297
299 DCHECK(!used_ || state_ == STARTED); 298 DCHECK(!used_ || state_ == STARTED);
300 commit_pending_ = true; 299 commit_pending_ = true;
301 300
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 processing_event_queue_ = false; 454 processing_event_queue_ = false;
456 return; 455 return;
457 } 456 }
458 457
459 DCHECK(state_ == STARTED); 458 DCHECK(state_ == STARTED);
460 459
461 // Otherwise, start a timer in case the front-end gets wedged and 460 // Otherwise, start a timer in case the front-end gets wedged and
462 // never requests further activity. Read-only transactions don't 461 // never requests further activity. Read-only transactions don't
463 // block other transactions, so don't time those out. 462 // block other transactions, so don't time those out.
464 if (mode_ != blink::kWebIDBTransactionModeReadOnly) { 463 if (mode_ != blink::kWebIDBTransactionModeReadOnly) {
465 timeout_timer_.Start( 464 // TODO(dmurph): Get this back in before submitting.
466 FROM_HERE, GetInactivityTimeout(), 465 // timeout_timer_.Start(
467 base::Bind(&IndexedDBTransaction::Timeout, ptr_factory_.GetWeakPtr())); 466 // FROM_HERE, GetInactivityTimeout(),
467 // base::Bind(&IndexedDBTransaction::Timeout,
468 // ptr_factory_.GetWeakPtr()));
468 } 469 }
469 processing_event_queue_ = false; 470 processing_event_queue_ = false;
470 } 471 }
471 472
472 base::TimeDelta IndexedDBTransaction::GetInactivityTimeout() const { 473 base::TimeDelta IndexedDBTransaction::GetInactivityTimeout() const {
473 return base::TimeDelta::FromSeconds(kInactivityTimeoutPeriodSeconds); 474 return base::TimeDelta::FromSeconds(kInactivityTimeoutPeriodSeconds);
474 } 475 }
475 476
476 void IndexedDBTransaction::Timeout() { 477 void IndexedDBTransaction::Timeout() {
478 LOG(ERROR) << "timout";
477 Abort(IndexedDBDatabaseError( 479 Abort(IndexedDBDatabaseError(
478 blink::kWebIDBDatabaseExceptionTimeoutError, 480 blink::kWebIDBDatabaseExceptionTimeoutError,
479 base::ASCIIToUTF16("Transaction timed out due to inactivity."))); 481 base::ASCIIToUTF16("Transaction timed out due to inactivity.")));
480 } 482 }
481 483
482 void IndexedDBTransaction::CloseOpenCursors() { 484 void IndexedDBTransaction::CloseOpenCursors() {
483 IDB_TRACE1("IndexedDBTransaction::CloseOpenCursors", "txn.id", id()); 485 IDB_TRACE1("IndexedDBTransaction::CloseOpenCursors", "txn.id", id());
484 for (auto* cursor : open_cursors_) 486 for (auto* cursor : open_cursors_)
485 cursor->Close(); 487 cursor->Close();
486 open_cursors_.clear(); 488 open_cursors_.clear();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 522
521 ::indexed_db::mojom::ObserverChangesPtr* 523 ::indexed_db::mojom::ObserverChangesPtr*
522 IndexedDBTransaction::GetPendingChangesForConnection(int32_t connection_id) { 524 IndexedDBTransaction::GetPendingChangesForConnection(int32_t connection_id) {
523 auto it = connection_changes_map_.find(connection_id); 525 auto it = connection_changes_map_.find(connection_id);
524 if (it != connection_changes_map_.end()) 526 if (it != connection_changes_map_.end())
525 return &it->second; 527 return &it->second;
526 return nullptr; 528 return nullptr;
527 } 529 }
528 530
529 } // namespace content 531 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698