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

Side by Side Diff: third_party/WebKit/Source/modules/indexeddb/IDBTransactionTest.cpp

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from Kent; merge. Created 4 years, 6 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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 21 matching lines...) Expand all
32 32
33 #include "bindings/core/v8/V8BindingForTesting.h" 33 #include "bindings/core/v8/V8BindingForTesting.h"
34 #include "core/dom/DOMException.h" 34 #include "core/dom/DOMException.h"
35 #include "core/dom/Document.h" 35 #include "core/dom/Document.h"
36 #include "core/dom/ExceptionCode.h" 36 #include "core/dom/ExceptionCode.h"
37 #include "modules/indexeddb/IDBDatabase.h" 37 #include "modules/indexeddb/IDBDatabase.h"
38 #include "modules/indexeddb/IDBDatabaseCallbacks.h" 38 #include "modules/indexeddb/IDBDatabaseCallbacks.h"
39 #include "modules/indexeddb/MockWebIDBDatabase.h" 39 #include "modules/indexeddb/MockWebIDBDatabase.h"
40 #include "platform/SharedBuffer.h" 40 #include "platform/SharedBuffer.h"
41 #include "testing/gtest/include/gtest/gtest.h" 41 #include "testing/gtest/include/gtest/gtest.h"
42 #include <memory>
42 #include <v8.h> 43 #include <v8.h>
43 44
44 namespace blink { 45 namespace blink {
45 namespace { 46 namespace {
46 47
47 class IDBTransactionTest : public testing::Test { 48 class IDBTransactionTest : public testing::Test {
48 public: 49 public:
49 IDBTransactionTest() 50 IDBTransactionTest()
50 : m_scope(v8::Isolate::GetCurrent()) 51 : m_scope(v8::Isolate::GetCurrent())
51 { 52 {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 void onVersionChange(int64_t oldVersion, int64_t newVersion) override { } 84 void onVersionChange(int64_t oldVersion, int64_t newVersion) override { }
84 void onForcedClose() override { } 85 void onForcedClose() override { }
85 void onAbort(int64_t transactionId, DOMException* error) override { } 86 void onAbort(int64_t transactionId, DOMException* error) override { }
86 void onComplete(int64_t transactionId) override { } 87 void onComplete(int64_t transactionId) override { }
87 private: 88 private:
88 FakeIDBDatabaseCallbacks() { } 89 FakeIDBDatabaseCallbacks() { }
89 }; 90 };
90 91
91 TEST_F(IDBTransactionTest, EnsureLifetime) 92 TEST_F(IDBTransactionTest, EnsureLifetime)
92 { 93 {
93 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); 94 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create();
94 EXPECT_CALL(*backend, close()) 95 EXPECT_CALL(*backend, close())
95 .Times(1); 96 .Times(1);
96 Persistent<IDBDatabase> db = IDBDatabase::create(getExecutionContext(), std: :move(backend), FakeIDBDatabaseCallbacks::create()); 97 Persistent<IDBDatabase> db = IDBDatabase::create(getExecutionContext(), std: :move(backend), FakeIDBDatabaseCallbacks::create());
97 98
98 const int64_t transactionId = 1234; 99 const int64_t transactionId = 1234;
99 const HashSet<String> transactionScope = HashSet<String>(); 100 const HashSet<String> transactionScope = HashSet<String>();
100 Persistent<IDBTransaction> transaction = IDBTransaction::create(getScriptSta te(), transactionId, transactionScope, WebIDBTransactionModeReadOnly, db.get()); 101 Persistent<IDBTransaction> transaction = IDBTransaction::create(getScriptSta te(), transactionId, transactionScope, WebIDBTransactionModeReadOnly, db.get());
101 PersistentHeapHashSet<WeakMember<IDBTransaction>> set; 102 PersistentHeapHashSet<WeakMember<IDBTransaction>> set;
102 set.add(transaction); 103 set.add(transaction);
103 104
(...skipping 13 matching lines...) Expand all
117 transaction.clear(); 118 transaction.clear();
118 119
119 ThreadHeap::collectAllGarbage(); 120 ThreadHeap::collectAllGarbage();
120 EXPECT_EQ(0u, set.size()); 121 EXPECT_EQ(0u, set.size());
121 } 122 }
122 123
123 TEST_F(IDBTransactionTest, TransactionFinish) 124 TEST_F(IDBTransactionTest, TransactionFinish)
124 { 125 {
125 const int64_t transactionId = 1234; 126 const int64_t transactionId = 1234;
126 127
127 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); 128 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create();
128 EXPECT_CALL(*backend, commit(transactionId)) 129 EXPECT_CALL(*backend, commit(transactionId))
129 .Times(1); 130 .Times(1);
130 EXPECT_CALL(*backend, close()) 131 EXPECT_CALL(*backend, close())
131 .Times(1); 132 .Times(1);
132 Persistent<IDBDatabase> db = IDBDatabase::create(getExecutionContext(), std: :move(backend), FakeIDBDatabaseCallbacks::create()); 133 Persistent<IDBDatabase> db = IDBDatabase::create(getExecutionContext(), std: :move(backend), FakeIDBDatabaseCallbacks::create());
133 134
134 const HashSet<String> transactionScope = HashSet<String>(); 135 const HashSet<String> transactionScope = HashSet<String>();
135 Persistent<IDBTransaction> transaction = IDBTransaction::create(getScriptSta te(), transactionId, transactionScope, WebIDBTransactionModeReadOnly, db.get()); 136 Persistent<IDBTransaction> transaction = IDBTransaction::create(getScriptSta te(), transactionId, transactionScope, WebIDBTransactionModeReadOnly, db.get());
136 PersistentHeapHashSet<WeakMember<IDBTransaction>> set; 137 PersistentHeapHashSet<WeakMember<IDBTransaction>> set;
137 set.add(transaction); 138 set.add(transaction);
(...skipping 18 matching lines...) Expand all
156 // will not fail if it is, but ASAN would notice the error. 157 // will not fail if it is, but ASAN would notice the error.
157 db->onAbort(transactionId, DOMException::create(AbortError, "Aborted")); 158 db->onAbort(transactionId, DOMException::create(AbortError, "Aborted"));
158 159
159 // onAbort() should have cleared the transaction's reference to the database . 160 // onAbort() should have cleared the transaction's reference to the database .
160 ThreadHeap::collectAllGarbage(); 161 ThreadHeap::collectAllGarbage();
161 EXPECT_EQ(0u, set.size()); 162 EXPECT_EQ(0u, set.size());
162 } 163 }
163 164
164 } // namespace 165 } // namespace
165 } // namespace blink 166 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698