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

Side by Side Diff: content/browser/indexed_db/leveldb/leveldb_unittest.cc

Issue 594403005: Use reset() to delete the contents of a scoped_ptr, not Pass(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <algorithm> 5 #include <algorithm>
6 #include <cstring> 6 #include <cstring>
7 #include <string> 7 #include <string>
8 8
9 #include "base/files/file.h" 9 #include "base/files/file.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 std::string put_value; 44 std::string put_value;
45 std::string got_value; 45 std::string got_value;
46 SimpleComparator comparator; 46 SimpleComparator comparator;
47 47
48 scoped_ptr<LevelDBDatabase> leveldb; 48 scoped_ptr<LevelDBDatabase> leveldb;
49 LevelDBDatabase::Open(temp_directory.path(), &comparator, &leveldb); 49 LevelDBDatabase::Open(temp_directory.path(), &comparator, &leveldb);
50 EXPECT_TRUE(leveldb); 50 EXPECT_TRUE(leveldb);
51 put_value = value; 51 put_value = value;
52 leveldb::Status status = leveldb->Put(key, &put_value); 52 leveldb::Status status = leveldb->Put(key, &put_value);
53 EXPECT_TRUE(status.ok()); 53 EXPECT_TRUE(status.ok());
54 leveldb.Pass(); 54 leveldb.reset();
55 EXPECT_FALSE(leveldb); 55 EXPECT_FALSE(leveldb);
56 56
57 LevelDBDatabase::Open(temp_directory.path(), &comparator, &leveldb); 57 LevelDBDatabase::Open(temp_directory.path(), &comparator, &leveldb);
58 EXPECT_TRUE(leveldb); 58 EXPECT_TRUE(leveldb);
59 bool found = false; 59 bool found = false;
60 status = leveldb->Get(key, &got_value, &found); 60 status = leveldb->Get(key, &got_value, &found);
61 EXPECT_TRUE(status.ok()); 61 EXPECT_TRUE(status.ok());
62 EXPECT_TRUE(found); 62 EXPECT_TRUE(found);
63 EXPECT_EQ(value, got_value); 63 EXPECT_EQ(value, got_value);
64 leveldb.Pass(); 64 leveldb.reset();
65 EXPECT_FALSE(leveldb); 65 EXPECT_FALSE(leveldb);
66 66
67 base::FilePath file_path = temp_directory.path().AppendASCII("CURRENT"); 67 base::FilePath file_path = temp_directory.path().AppendASCII("CURRENT");
68 base::File file(file_path, base::File::FLAG_OPEN | base::File::FLAG_WRITE); 68 base::File file(file_path, base::File::FLAG_OPEN | base::File::FLAG_WRITE);
69 file.SetLength(0); 69 file.SetLength(0);
70 file.Close(); 70 file.Close();
71 71
72 status = LevelDBDatabase::Open(temp_directory.path(), &comparator, &leveldb); 72 status = LevelDBDatabase::Open(temp_directory.path(), &comparator, &leveldb);
73 EXPECT_FALSE(leveldb); 73 EXPECT_FALSE(leveldb);
74 EXPECT_FALSE(status.ok()); 74 EXPECT_FALSE(status.ok());
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 258
259 leveldb::FileLock* lock2; 259 leveldb::FileLock* lock2;
260 status = env->LockFile(file.AsUTF8Unsafe(), &lock2); 260 status = env->LockFile(file.AsUTF8Unsafe(), &lock2);
261 EXPECT_FALSE(status.ok()); 261 EXPECT_FALSE(status.ok());
262 262
263 status = env->UnlockFile(lock); 263 status = env->UnlockFile(lock);
264 EXPECT_TRUE(status.ok()); 264 EXPECT_TRUE(status.ok());
265 } 265 }
266 266
267 } // namespace content 267 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698