| 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/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 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 void IndexedDBTransaction::CloseOpenCursors() { | 461 void IndexedDBTransaction::CloseOpenCursors() { |
| 462 IDB_TRACE1("IndexedDBTransaction::CloseOpenCursors", "txn.id", id()); | 462 IDB_TRACE1("IndexedDBTransaction::CloseOpenCursors", "txn.id", id()); |
| 463 for (auto* cursor : open_cursors_) | 463 for (auto* cursor : open_cursors_) |
| 464 cursor->Close(); | 464 cursor->Close(); |
| 465 open_cursors_.clear(); | 465 open_cursors_.clear(); |
| 466 } | 466 } |
| 467 | 467 |
| 468 void IndexedDBTransaction::AddPendingObserver( | 468 void IndexedDBTransaction::AddPendingObserver( |
| 469 int32_t observer_id, | 469 int32_t observer_id, |
| 470 const IndexedDBObserver::Options& options) { | 470 const IndexedDBObserver::Options& options) { |
| 471 pending_observers_.push_back(base::WrapUnique( | 471 pending_observers_.push_back(base::MakeUnique<IndexedDBObserver>( |
| 472 new IndexedDBObserver(observer_id, object_store_ids_, options))); | 472 observer_id, object_store_ids_, options)); |
| 473 } | 473 } |
| 474 | 474 |
| 475 void IndexedDBTransaction::RemovePendingObservers( | 475 void IndexedDBTransaction::RemovePendingObservers( |
| 476 const std::vector<int32_t>& pending_observer_ids) { | 476 const std::vector<int32_t>& pending_observer_ids) { |
| 477 const auto& it = std::remove_if( | 477 const auto& it = std::remove_if( |
| 478 pending_observers_.begin(), pending_observers_.end(), | 478 pending_observers_.begin(), pending_observers_.end(), |
| 479 [&pending_observer_ids](const std::unique_ptr<IndexedDBObserver>& o) { | 479 [&pending_observer_ids](const std::unique_ptr<IndexedDBObserver>& o) { |
| 480 return base::ContainsValue(pending_observer_ids, o->id()); | 480 return base::ContainsValue(pending_observer_ids, o->id()); |
| 481 }); | 481 }); |
| 482 if (it != pending_observers_.end()) | 482 if (it != pending_observers_.end()) |
| 483 pending_observers_.erase(it, pending_observers_.end()); | 483 pending_observers_.erase(it, pending_observers_.end()); |
| 484 } | 484 } |
| 485 | 485 |
| 486 void IndexedDBTransaction::AddObservation( | 486 void IndexedDBTransaction::AddObservation( |
| 487 int32_t connection_id, | 487 int32_t connection_id, |
| 488 std::unique_ptr<IndexedDBObservation> observation) { | 488 std::unique_ptr<IndexedDBObservation> observation) { |
| 489 auto it = connection_changes_map_.find(connection_id); | 489 auto it = connection_changes_map_.find(connection_id); |
| 490 if (it == connection_changes_map_.end()) { | 490 if (it == connection_changes_map_.end()) { |
| 491 it = connection_changes_map_ | 491 it = connection_changes_map_ |
| 492 .insert(std::make_pair( | 492 .insert(std::make_pair( |
| 493 connection_id, | 493 connection_id, base::MakeUnique<IndexedDBObserverChanges>())) |
| 494 base::WrapUnique(new IndexedDBObserverChanges()))) | |
| 495 .first; | 494 .first; |
| 496 } | 495 } |
| 497 it->second->AddObservation(std::move(observation)); | 496 it->second->AddObservation(std::move(observation)); |
| 498 } | 497 } |
| 499 | 498 |
| 500 void IndexedDBTransaction::RecordObserverForLastObservation( | 499 void IndexedDBTransaction::RecordObserverForLastObservation( |
| 501 int32_t connection_id, | 500 int32_t connection_id, |
| 502 int32_t observer_id) { | 501 int32_t observer_id) { |
| 503 auto it = connection_changes_map_.find(connection_id); | 502 auto it = connection_changes_map_.find(connection_id); |
| 504 DCHECK(it != connection_changes_map_.end()); | 503 DCHECK(it != connection_changes_map_.end()); |
| 505 it->second->RecordObserverForLastObservation(observer_id); | 504 it->second->RecordObserverForLastObservation(observer_id); |
| 506 } | 505 } |
| 507 | 506 |
| 508 } // namespace content | 507 } // namespace content |
| OLD | NEW |