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

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

Issue 2233153002: IndexedDB: WrapUnique(new T(args..)) -> MakeUnique<T>(args...) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review feedback Created 4 years, 4 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <stdint.h> 5 #include <stdint.h>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 129
130 // No data was cleared because of SetForceKeepSessionState. 130 // No data was cleared because of SetForceKeepSessionState.
131 EXPECT_TRUE(base::DirectoryExists(normal_path)); 131 EXPECT_TRUE(base::DirectoryExists(normal_path));
132 EXPECT_TRUE(base::DirectoryExists(session_only_path)); 132 EXPECT_TRUE(base::DirectoryExists(session_only_path));
133 } 133 }
134 134
135 class ForceCloseDBCallbacks : public IndexedDBCallbacks { 135 class ForceCloseDBCallbacks : public IndexedDBCallbacks {
136 public: 136 public:
137 ForceCloseDBCallbacks(scoped_refptr<IndexedDBContextImpl> idb_context, 137 ForceCloseDBCallbacks(scoped_refptr<IndexedDBContextImpl> idb_context,
138 const Origin& origin) 138 const Origin& origin)
139 : IndexedDBCallbacks(NULL, 0, 0), 139 : IndexedDBCallbacks(nullptr, 0, 0),
140 idb_context_(idb_context), 140 idb_context_(idb_context),
141 origin_(origin) {} 141 origin_(origin) {}
142 142
143 void OnSuccess() override {} 143 void OnSuccess() override {}
144 void OnSuccess(const std::vector<base::string16>&) override {} 144 void OnSuccess(const std::vector<base::string16>&) override {}
145 void OnSuccess(std::unique_ptr<IndexedDBConnection> connection, 145 void OnSuccess(std::unique_ptr<IndexedDBConnection> connection,
146 const IndexedDBDatabaseMetadata& metadata) override { 146 const IndexedDBDatabaseMetadata& metadata) override {
147 connection_ = std::move(connection); 147 connection_ = std::move(connection);
148 idb_context_->ConnectionOpened(origin_, connection_.get()); 148 idb_context_->ConnectionOpened(origin_, connection_.get());
149 } 149 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 new ForceCloseDBCallbacks(idb_context, kTestOrigin); 187 new ForceCloseDBCallbacks(idb_context, kTestOrigin);
188 188
189 scoped_refptr<ForceCloseDBCallbacks> closed_callbacks = 189 scoped_refptr<ForceCloseDBCallbacks> closed_callbacks =
190 new ForceCloseDBCallbacks(idb_context, kTestOrigin); 190 new ForceCloseDBCallbacks(idb_context, kTestOrigin);
191 191
192 IndexedDBFactory* factory = idb_context->GetIDBFactory(); 192 IndexedDBFactory* factory = idb_context->GetIDBFactory();
193 193
194 test_path = idb_context->GetFilePathForTesting(kTestOrigin); 194 test_path = idb_context->GetFilePathForTesting(kTestOrigin);
195 195
196 std::unique_ptr<IndexedDBPendingConnection> open_connection( 196 std::unique_ptr<IndexedDBPendingConnection> open_connection(
197 new IndexedDBPendingConnection( 197 base::MakeUnique<IndexedDBPendingConnection>(
198 open_callbacks, open_db_callbacks, 0 /* child_process_id */, 198 open_callbacks, open_db_callbacks, 0 /* child_process_id */,
199 0 /* host_transaction_id */, 0 /* version */)); 199 0 /* host_transaction_id */, 0 /* version */));
200 factory->Open(base::ASCIIToUTF16("opendb"), std::move(open_connection), 200 factory->Open(base::ASCIIToUTF16("opendb"), std::move(open_connection),
201 NULL /* request_context */, Origin(kTestOrigin), 201 nullptr /* request_context */, Origin(kTestOrigin),
202 idb_context->data_path()); 202 idb_context->data_path());
203 std::unique_ptr<IndexedDBPendingConnection> closed_connection( 203 std::unique_ptr<IndexedDBPendingConnection> closed_connection(
204 new IndexedDBPendingConnection( 204 base::MakeUnique<IndexedDBPendingConnection>(
205 closed_callbacks, closed_db_callbacks, 0 /* child_process_id */, 205 closed_callbacks, closed_db_callbacks, 0 /* child_process_id */,
206 0 /* host_transaction_id */, 0 /* version */)); 206 0 /* host_transaction_id */, 0 /* version */));
207 factory->Open(base::ASCIIToUTF16("closeddb"), std::move(closed_connection), 207 factory->Open(base::ASCIIToUTF16("closeddb"), std::move(closed_connection),
208 NULL /* request_context */, Origin(kTestOrigin), 208 nullptr /* request_context */, Origin(kTestOrigin),
209 idb_context->data_path()); 209 idb_context->data_path());
210 210
211 closed_callbacks->connection()->Close(); 211 closed_callbacks->connection()->Close();
212 212
213 // TODO(jsbell): Remove static_cast<> when overloads are eliminated. 213 // TODO(jsbell): Remove static_cast<> when overloads are eliminated.
214 idb_context->TaskRunner()->PostTask( 214 idb_context->TaskRunner()->PostTask(
215 FROM_HERE, 215 FROM_HERE,
216 base::Bind(static_cast<void (IndexedDBContextImpl::*)(const Origin&)>( 216 base::Bind(static_cast<void (IndexedDBContextImpl::*)(const Origin&)>(
217 &IndexedDBContextImpl::DeleteForOrigin), 217 &IndexedDBContextImpl::DeleteForOrigin),
218 idb_context, kTestOrigin)); 218 idb_context, kTestOrigin));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 quota_manager_proxy_.get(), task_runner_.get()); 266 quota_manager_proxy_.get(), task_runner_.get());
267 267
268 scoped_refptr<IndexedDBFactoryImpl> factory = 268 scoped_refptr<IndexedDBFactoryImpl> factory =
269 static_cast<IndexedDBFactoryImpl*>(context->GetIDBFactory()); 269 static_cast<IndexedDBFactoryImpl*>(context->GetIDBFactory());
270 270
271 scoped_refptr<MockIndexedDBCallbacks> callbacks(new MockIndexedDBCallbacks()); 271 scoped_refptr<MockIndexedDBCallbacks> callbacks(new MockIndexedDBCallbacks());
272 scoped_refptr<MockIndexedDBDatabaseCallbacks> db_callbacks( 272 scoped_refptr<MockIndexedDBDatabaseCallbacks> db_callbacks(
273 new MockIndexedDBDatabaseCallbacks()); 273 new MockIndexedDBDatabaseCallbacks());
274 const int64_t transaction_id = 1; 274 const int64_t transaction_id = 1;
275 std::unique_ptr<IndexedDBPendingConnection> connection( 275 std::unique_ptr<IndexedDBPendingConnection> connection(
276 new IndexedDBPendingConnection( 276 base::MakeUnique<IndexedDBPendingConnection>(
277 callbacks, db_callbacks, 0 /* child_process_id */, transaction_id, 277 callbacks, db_callbacks, 0 /* child_process_id */, transaction_id,
278 IndexedDBDatabaseMetadata::DEFAULT_VERSION)); 278 IndexedDBDatabaseMetadata::DEFAULT_VERSION));
279 factory->Open(base::ASCIIToUTF16("db"), std::move(connection), 279 factory->Open(base::ASCIIToUTF16("db"), std::move(connection),
280 NULL /* request_context */, Origin(kTestOrigin), 280 nullptr /* request_context */, Origin(kTestOrigin),
281 temp_dir.path()); 281 temp_dir.path());
282 282
283 EXPECT_TRUE(callbacks->connection()); 283 EXPECT_TRUE(callbacks->connection());
284 284
285 // ConnectionOpened() is usually called by the dispatcher. 285 // ConnectionOpened() is usually called by the dispatcher.
286 context->ConnectionOpened(kTestOrigin, callbacks->connection()); 286 context->ConnectionOpened(kTestOrigin, callbacks->connection());
287 287
288 EXPECT_TRUE(factory->IsBackingStoreOpen(kTestOrigin)); 288 EXPECT_TRUE(factory->IsBackingStoreOpen(kTestOrigin));
289 289
290 // Simulate the write failure. 290 // Simulate the write failure.
291 leveldb::Status status = leveldb::Status::IOError("Simulated failure"); 291 leveldb::Status status = leveldb::Status::IOError("Simulated failure");
292 callbacks->connection()->database()->TransactionCommitFailed(status); 292 callbacks->connection()->database()->TransactionCommitFailed(status);
293 293
294 EXPECT_TRUE(db_callbacks->forced_close_called()); 294 EXPECT_TRUE(db_callbacks->forced_close_called());
295 EXPECT_FALSE(factory->IsBackingStoreOpen(kTestOrigin)); 295 EXPECT_FALSE(factory->IsBackingStoreOpen(kTestOrigin));
296 } 296 }
297 297
298 } // namespace content 298 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_transaction_unittest.cc ('k') | content/browser/indexed_db/leveldb/leveldb_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698