OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/sync/syncable/directory_unittest.h" | 5 #include "components/sync/syncable/directory_unittest.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <cstdlib> | 9 #include <cstdlib> |
10 | 10 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 void SyncableDirectoryTest::TearDown() { | 71 void SyncableDirectoryTest::TearDown() { |
72 if (dir_) | 72 if (dir_) |
73 dir_->SaveChanges(); | 73 dir_->SaveChanges(); |
74 dir_.reset(); | 74 dir_.reset(); |
75 } | 75 } |
76 | 76 |
77 DirOpenResult SyncableDirectoryTest::ReopenDirectory() { | 77 DirOpenResult SyncableDirectoryTest::ReopenDirectory() { |
78 // Use a TestDirectoryBackingStore and sql::Connection so we can have test | 78 // Use a TestDirectoryBackingStore and sql::Connection so we can have test |
79 // data persist across Directory object lifetimes while getting the | 79 // data persist across Directory object lifetimes while getting the |
80 // performance benefits of not writing to disk. | 80 // performance benefits of not writing to disk. |
81 dir_.reset(new Directory( | 81 dir_ = base::MakeUnique<Directory>( |
82 new TestDirectoryBackingStore(kDirectoryName, &connection_), | 82 new TestDirectoryBackingStore(kDirectoryName, &connection_), |
83 MakeWeakHandle(handler_.GetWeakPtr()), base::Closure(), NULL, NULL)); | 83 MakeWeakHandle(handler_.GetWeakPtr()), base::Closure(), nullptr, nullptr); |
84 | 84 |
85 DirOpenResult open_result = | 85 DirOpenResult open_result = |
86 dir_->Open(kDirectoryName, &delegate_, NullTransactionObserver()); | 86 dir_->Open(kDirectoryName, &delegate_, NullTransactionObserver()); |
87 | 87 |
88 if (open_result != OPENED) { | 88 if (open_result != OPENED) { |
89 dir_.reset(); | 89 dir_.reset(); |
90 } | 90 } |
91 | 91 |
92 return open_result; | 92 return open_result; |
93 } | 93 } |
(...skipping 1594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1688 DISALLOW_COPY_AND_ASSIGN(StressTransactionsDelegate); | 1688 DISALLOW_COPY_AND_ASSIGN(StressTransactionsDelegate); |
1689 }; | 1689 }; |
1690 | 1690 |
1691 // Stress test Directory by accessing it from several threads concurrently. | 1691 // Stress test Directory by accessing it from several threads concurrently. |
1692 TEST_F(SyncableDirectoryTest, StressTransactions) { | 1692 TEST_F(SyncableDirectoryTest, StressTransactions) { |
1693 const int kThreadCount = 7; | 1693 const int kThreadCount = 7; |
1694 base::PlatformThreadHandle threads[kThreadCount]; | 1694 base::PlatformThreadHandle threads[kThreadCount]; |
1695 std::unique_ptr<StressTransactionsDelegate> thread_delegates[kThreadCount]; | 1695 std::unique_ptr<StressTransactionsDelegate> thread_delegates[kThreadCount]; |
1696 | 1696 |
1697 for (int i = 0; i < kThreadCount; ++i) { | 1697 for (int i = 0; i < kThreadCount; ++i) { |
1698 thread_delegates[i].reset(new StressTransactionsDelegate(dir().get(), i)); | 1698 thread_delegates[i] = |
| 1699 base::MakeUnique<StressTransactionsDelegate>(dir().get(), i); |
1699 ASSERT_TRUE(base::PlatformThread::Create(0, thread_delegates[i].get(), | 1700 ASSERT_TRUE(base::PlatformThread::Create(0, thread_delegates[i].get(), |
1700 &threads[i])); | 1701 &threads[i])); |
1701 } | 1702 } |
1702 | 1703 |
1703 for (int i = 0; i < kThreadCount; ++i) { | 1704 for (int i = 0; i < kThreadCount; ++i) { |
1704 base::PlatformThread::Join(threads[i]); | 1705 base::PlatformThread::Join(threads[i]); |
1705 } | 1706 } |
1706 } | 1707 } |
1707 | 1708 |
1708 // Verify that Directory is notifed when a MutableEntry's AttachmentMetadata | 1709 // Verify that Directory is notifed when a MutableEntry's AttachmentMetadata |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2137 | 2138 |
2138 const base::DictionaryValue* first_result; | 2139 const base::DictionaryValue* first_result; |
2139 ASSERT_TRUE(nodes->GetDictionary(0, &first_result)); | 2140 ASSERT_TRUE(nodes->GetDictionary(0, &first_result)); |
2140 EXPECT_TRUE(first_result->HasKey("ID")); | 2141 EXPECT_TRUE(first_result->HasKey("ID")); |
2141 EXPECT_TRUE(first_result->HasKey("NON_UNIQUE_NAME")); | 2142 EXPECT_TRUE(first_result->HasKey("NON_UNIQUE_NAME")); |
2142 } | 2143 } |
2143 | 2144 |
2144 } // namespace syncable | 2145 } // namespace syncable |
2145 | 2146 |
2146 } // namespace syncer | 2147 } // namespace syncer |
OLD | NEW |