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

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

Issue 501183003: Remove implicit conversions from scoped_refptr to T* in content/browser/indexed_db/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 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_factory_impl.h" 5 #include "content/browser/indexed_db/indexed_db_factory_impl.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 scoped_refptr<IndexedDBBackingStore> disk_store1 = 103 scoped_refptr<IndexedDBBackingStore> disk_store1 =
104 factory()->TestOpenBackingStore(origin1, temp_directory.path()); 104 factory()->TestOpenBackingStore(origin1, temp_directory.path());
105 105
106 scoped_refptr<IndexedDBBackingStore> disk_store2 = 106 scoped_refptr<IndexedDBBackingStore> disk_store2 =
107 factory()->TestOpenBackingStore(origin1, temp_directory.path()); 107 factory()->TestOpenBackingStore(origin1, temp_directory.path());
108 EXPECT_EQ(disk_store1.get(), disk_store2.get()); 108 EXPECT_EQ(disk_store1.get(), disk_store2.get());
109 109
110 scoped_refptr<IndexedDBBackingStore> disk_store3 = 110 scoped_refptr<IndexedDBBackingStore> disk_store3 =
111 factory()->TestOpenBackingStore(origin2, temp_directory.path()); 111 factory()->TestOpenBackingStore(origin2, temp_directory.path());
112 112
113 factory()->TestCloseBackingStore(disk_store1); 113 factory()->TestCloseBackingStore(disk_store1.get());
114 factory()->TestCloseBackingStore(disk_store3); 114 factory()->TestCloseBackingStore(disk_store3.get());
115 115
116 EXPECT_FALSE(disk_store1->HasOneRef()); 116 EXPECT_FALSE(disk_store1->HasOneRef());
117 EXPECT_FALSE(disk_store2->HasOneRef()); 117 EXPECT_FALSE(disk_store2->HasOneRef());
118 EXPECT_TRUE(disk_store3->HasOneRef()); 118 EXPECT_TRUE(disk_store3->HasOneRef());
119 119
120 disk_store2 = NULL; 120 disk_store2 = NULL;
121 EXPECT_TRUE(disk_store1->HasOneRef()); 121 EXPECT_TRUE(disk_store1->HasOneRef());
122 } 122 }
123 123
124 TEST_F(IndexedDBFactoryTest, BackingStoreLazyClose) { 124 TEST_F(IndexedDBFactoryTest, BackingStoreLazyClose) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 scoped_refptr<IndexedDBBackingStore> mem_store1 = 156 scoped_refptr<IndexedDBBackingStore> mem_store1 =
157 factory()->TestOpenBackingStore(origin1, base::FilePath()); 157 factory()->TestOpenBackingStore(origin1, base::FilePath());
158 158
159 scoped_refptr<IndexedDBBackingStore> mem_store2 = 159 scoped_refptr<IndexedDBBackingStore> mem_store2 =
160 factory()->TestOpenBackingStore(origin1, base::FilePath()); 160 factory()->TestOpenBackingStore(origin1, base::FilePath());
161 EXPECT_EQ(mem_store1.get(), mem_store2.get()); 161 EXPECT_EQ(mem_store1.get(), mem_store2.get());
162 162
163 scoped_refptr<IndexedDBBackingStore> mem_store3 = 163 scoped_refptr<IndexedDBBackingStore> mem_store3 =
164 factory()->TestOpenBackingStore(origin2, base::FilePath()); 164 factory()->TestOpenBackingStore(origin2, base::FilePath());
165 165
166 factory()->TestCloseBackingStore(mem_store1); 166 factory()->TestCloseBackingStore(mem_store1.get());
167 factory()->TestCloseBackingStore(mem_store3); 167 factory()->TestCloseBackingStore(mem_store3.get());
168 168
169 EXPECT_FALSE(mem_store1->HasOneRef()); 169 EXPECT_FALSE(mem_store1->HasOneRef());
170 EXPECT_FALSE(mem_store2->HasOneRef()); 170 EXPECT_FALSE(mem_store2->HasOneRef());
171 EXPECT_FALSE(mem_store3->HasOneRef()); 171 EXPECT_FALSE(mem_store3->HasOneRef());
172 172
173 clear_factory(); 173 clear_factory();
174 EXPECT_FALSE(mem_store1->HasOneRef()); // mem_store1 and 2 174 EXPECT_FALSE(mem_store1->HasOneRef()); // mem_store1 and 2
175 EXPECT_FALSE(mem_store2->HasOneRef()); // mem_store1 and 2 175 EXPECT_FALSE(mem_store2->HasOneRef()); // mem_store1 and 2
176 EXPECT_TRUE(mem_store3->HasOneRef()); 176 EXPECT_TRUE(mem_store3->HasOneRef());
177 177
178 mem_store2 = NULL; 178 mem_store2 = NULL;
179 EXPECT_TRUE(mem_store1->HasOneRef()); 179 EXPECT_TRUE(mem_store1->HasOneRef());
180 } 180 }
181 181
182 TEST_F(IndexedDBFactoryTest, RejectLongOrigins) { 182 TEST_F(IndexedDBFactoryTest, RejectLongOrigins) {
183 base::ScopedTempDir temp_directory; 183 base::ScopedTempDir temp_directory;
184 ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); 184 ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
185 const base::FilePath base_path = temp_directory.path(); 185 const base::FilePath base_path = temp_directory.path();
186 186
187 int limit = base::GetMaximumPathComponentLength(base_path); 187 int limit = base::GetMaximumPathComponentLength(base_path);
188 EXPECT_GT(limit, 0); 188 EXPECT_GT(limit, 0);
189 189
190 std::string origin(limit + 1, 'x'); 190 std::string origin(limit + 1, 'x');
191 GURL too_long_origin("http://" + origin + ":81/"); 191 GURL too_long_origin("http://" + origin + ":81/");
192 scoped_refptr<IndexedDBBackingStore> diskStore1 = 192 scoped_refptr<IndexedDBBackingStore> diskStore1 =
193 factory()->TestOpenBackingStore(too_long_origin, base_path); 193 factory()->TestOpenBackingStore(too_long_origin, base_path);
194 EXPECT_FALSE(diskStore1); 194 EXPECT_FALSE(diskStore1.get());
195 195
196 GURL ok_origin("http://someorigin.com:82/"); 196 GURL ok_origin("http://someorigin.com:82/");
197 scoped_refptr<IndexedDBBackingStore> diskStore2 = 197 scoped_refptr<IndexedDBBackingStore> diskStore2 =
198 factory()->TestOpenBackingStore(ok_origin, base_path); 198 factory()->TestOpenBackingStore(ok_origin, base_path);
199 EXPECT_TRUE(diskStore2); 199 EXPECT_TRUE(diskStore2.get());
200 } 200 }
201 201
202 class DiskFullFactory : public IndexedDBFactoryImpl { 202 class DiskFullFactory : public IndexedDBFactoryImpl {
203 public: 203 public:
204 explicit DiskFullFactory(IndexedDBContextImpl* context) 204 explicit DiskFullFactory(IndexedDBContextImpl* context)
205 : IndexedDBFactoryImpl(context) {} 205 : IndexedDBFactoryImpl(context) {}
206 206
207 private: 207 private:
208 virtual ~DiskFullFactory() {} 208 virtual ~DiskFullFactory() {}
209 virtual scoped_refptr<IndexedDBBackingStore> OpenBackingStore( 209 virtual scoped_refptr<IndexedDBBackingStore> OpenBackingStore(
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 temp_directory.path()); 524 temp_directory.path());
525 EXPECT_TRUE(callbacks->saw_error()); 525 EXPECT_TRUE(callbacks->saw_error());
526 EXPECT_FALSE(factory()->IsDatabaseOpen(origin, db_name)); 526 EXPECT_FALSE(factory()->IsDatabaseOpen(origin, db_name));
527 } 527 }
528 528
529 // Terminate all pending-close timers. 529 // Terminate all pending-close timers.
530 factory()->ForceClose(origin); 530 factory()->ForceClose(origin);
531 } 531 }
532 532
533 } // namespace content 533 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_factory_impl.cc ('k') | content/browser/indexed_db/indexed_db_internals_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698