OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "content/browser/indexed_db/indexed_db_connection.h" | 15 #include "content/browser/indexed_db/indexed_db_connection.h" |
16 #include "content/browser/indexed_db/indexed_db_fake_backing_store.h" | 16 #include "content/browser/indexed_db/indexed_db_fake_backing_store.h" |
| 17 #include "content/browser/indexed_db/indexed_db_observer.h" |
17 #include "content/browser/indexed_db/mock_indexed_db_database_callbacks.h" | 18 #include "content/browser/indexed_db/mock_indexed_db_database_callbacks.h" |
18 #include "content/browser/indexed_db/mock_indexed_db_factory.h" | 19 #include "content/browser/indexed_db/mock_indexed_db_factory.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
20 | 21 |
21 namespace content { | 22 namespace content { |
22 | 23 |
23 class AbortObserver { | 24 class AbortObserver { |
24 public: | 25 public: |
25 AbortObserver() : abort_task_called_(false) {} | 26 AbortObserver() : abort_task_called_(false) {} |
26 | 27 |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 id, connection->GetWeakPtr(), scope, | 364 id, connection->GetWeakPtr(), scope, |
364 blink::WebIDBTransactionModeReadWrite, | 365 blink::WebIDBTransactionModeReadWrite, |
365 new IndexedDBFakeBackingStore::FakeTransaction(commit_success)); | 366 new IndexedDBFakeBackingStore::FakeTransaction(commit_success)); |
366 db_->TransactionCreated(transaction.get()); | 367 db_->TransactionCreated(transaction.get()); |
367 | 368 |
368 EXPECT_EQ(0UL, transaction->pending_observers_.size()); | 369 EXPECT_EQ(0UL, transaction->pending_observers_.size()); |
369 EXPECT_EQ(0UL, connection->active_observers().size()); | 370 EXPECT_EQ(0UL, connection->active_observers().size()); |
370 | 371 |
371 // Add observers to pending observer list. | 372 // Add observers to pending observer list. |
372 const int32_t observer_id1 = 1, observer_id2 = 2; | 373 const int32_t observer_id1 = 1, observer_id2 = 2; |
373 transaction->AddPendingObserver(observer_id1); | 374 IndexedDBObserver::Options options(false, false, false, 0U); |
374 transaction->AddPendingObserver(observer_id2); | 375 transaction->AddPendingObserver(observer_id1, options); |
| 376 transaction->AddPendingObserver(observer_id2, options); |
375 EXPECT_EQ(2UL, transaction->pending_observers_.size()); | 377 EXPECT_EQ(2UL, transaction->pending_observers_.size()); |
376 EXPECT_EQ(0UL, connection->active_observers().size()); | 378 EXPECT_EQ(0UL, connection->active_observers().size()); |
377 | 379 |
378 // Before commit, observer would be in pending list of transaction. | 380 // Before commit, observer would be in pending list of transaction. |
379 std::vector<int32_t> observer_to_remove1 = {observer_id1}; | 381 std::vector<int32_t> observer_to_remove1 = {observer_id1}; |
380 connection->RemoveObservers(observer_to_remove1); | 382 connection->RemoveObservers(observer_to_remove1); |
381 EXPECT_EQ(1UL, transaction->pending_observers_.size()); | 383 EXPECT_EQ(1UL, transaction->pending_observers_.size()); |
382 EXPECT_EQ(0UL, connection->active_observers().size()); | 384 EXPECT_EQ(0UL, connection->active_observers().size()); |
383 | 385 |
384 // After commit, observer moved to connection's active observer. | 386 // After commit, observer moved to connection's active observer. |
(...skipping 13 matching lines...) Expand all Loading... |
398 | 400 |
399 static const blink::WebIDBTransactionMode kTestModes[] = { | 401 static const blink::WebIDBTransactionMode kTestModes[] = { |
400 blink::WebIDBTransactionModeReadOnly, blink::WebIDBTransactionModeReadWrite, | 402 blink::WebIDBTransactionModeReadOnly, blink::WebIDBTransactionModeReadWrite, |
401 blink::WebIDBTransactionModeVersionChange}; | 403 blink::WebIDBTransactionModeVersionChange}; |
402 | 404 |
403 INSTANTIATE_TEST_CASE_P(IndexedDBTransactions, | 405 INSTANTIATE_TEST_CASE_P(IndexedDBTransactions, |
404 IndexedDBTransactionTestMode, | 406 IndexedDBTransactionTestMode, |
405 ::testing::ValuesIn(kTestModes)); | 407 ::testing::ValuesIn(kTestModes)); |
406 | 408 |
407 } // namespace content | 409 } // namespace content |
OLD | NEW |