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

Side by Side Diff: chrome/browser/net/sqlite_persistent_cookie_store_unittest.cc

Issue 9592026: Create meta table atomically. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/scoped_temp_dir.h" 10 #include "base/scoped_temp_dir.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 ASSERT_STREQ("B", cookies[0]->Value().c_str()); 153 ASSERT_STREQ("B", cookies[0]->Value().c_str());
154 DestroyStore(); 154 DestroyStore();
155 STLDeleteContainerPointers(cookies.begin(), cookies.end()); 155 STLDeleteContainerPointers(cookies.begin(), cookies.end());
156 cookies.clear(); 156 cookies.clear();
157 157
158 // Now corrupt the meta table. 158 // Now corrupt the meta table.
159 { 159 {
160 sql::Connection db; 160 sql::Connection db;
161 ASSERT_TRUE(db.Open(temp_dir_.path().Append(chrome::kCookieFilename))); 161 ASSERT_TRUE(db.Open(temp_dir_.path().Append(chrome::kCookieFilename)));
162 sql::MetaTable meta_table_; 162 sql::MetaTable meta_table_;
163 meta_table_.Init(&db, 0, 0); 163 meta_table_.Init(&db, 1, 1);
164 meta_table_.SetVersionNumber(0); 164 ASSERT_TRUE(db.Execute("DELETE FROM meta"));
erikwright (departed) 2012/03/07 14:57:34 I'd prefer if MetaTable either exposed a 'Delete'
Scott Hess - ex-Googler 2012/03/07 15:24:27 I would not be happy exposing such information as
165 meta_table_.SetCompatibleVersionNumber(0);
166 db.Close(); 165 db.Close();
167 } 166 }
168 167
169 // Upon loading, the database should be reset to a good, blank state. 168 // Upon loading, the database should be reset to a good, blank state.
170 CreateAndLoad(false, &cookies); 169 CreateAndLoad(false, &cookies);
171 ASSERT_EQ(0U, cookies.size()); 170 ASSERT_EQ(0U, cookies.size());
172 171
173 // Verify that, after, recovery, the database persists properly. 172 // Verify that, after, recovery, the database persists properly.
174 AddCookie("X", "Y", "http://foo.bar", "/", base::Time::Now()); 173 AddCookie("X", "Y", "http://foo.bar", "/", base::Time::Now());
175 DestroyStore(); 174 DestroyStore();
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 445
447 EXPECT_FALSE(cookie_map["session-noexpires"]->DoesExpire()); 446 EXPECT_FALSE(cookie_map["session-noexpires"]->DoesExpire());
448 EXPECT_FALSE(cookie_map["session-noexpires"]->IsPersistent()); 447 EXPECT_FALSE(cookie_map["session-noexpires"]->IsPersistent());
449 448
450 EXPECT_TRUE(cookie_map["persistent"]->DoesExpire()); 449 EXPECT_TRUE(cookie_map["persistent"]->DoesExpire());
451 EXPECT_TRUE(cookie_map["persistent"]->IsPersistent()); 450 EXPECT_TRUE(cookie_map["persistent"]->IsPersistent());
452 451
453 STLDeleteContainerPointers(cookies.begin(), cookies.end()); 452 STLDeleteContainerPointers(cookies.begin(), cookies.end());
454 cookies.clear(); 453 cookies.clear();
455 } 454 }
OLDNEW
« no previous file with comments | « chrome/browser/history/history_database.cc ('k') | sql/meta_table.h » ('j') | sql/meta_table.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698