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

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

Issue 9005036: [sql] WARN_UNUSED_RESULT on Execute(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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
« no previous file with comments | « chrome/browser/history/visitsegment_database.cc ('k') | sql/connection.h » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/net/sqlite_persistent_cookie_store.h" 5 #include "chrome/browser/net/sqlite_persistent_cookie_store.h"
6 6
7 #include <list> 7 #include <list>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 "expires_utc INTEGER NOT NULL," 287 "expires_utc INTEGER NOT NULL,"
288 "secure INTEGER NOT NULL," 288 "secure INTEGER NOT NULL,"
289 "httponly INTEGER NOT NULL," 289 "httponly INTEGER NOT NULL,"
290 "last_access_utc INTEGER NOT NULL, " 290 "last_access_utc INTEGER NOT NULL, "
291 "has_expires INTEGER NOT NULL DEFAULT 1, " 291 "has_expires INTEGER NOT NULL DEFAULT 1, "
292 "persistent INTEGER NOT NULL DEFAULT 1)")) 292 "persistent INTEGER NOT NULL DEFAULT 1)"))
293 return false; 293 return false;
294 } 294 }
295 295
296 // Try to create the index every time. Older versions did not have this index, 296 // Try to create the index every time. Older versions did not have this index,
297 // so we want those people to get it. Ignore errors, since it may exist. 297 // so we want those people to get it.
wtc 2011/12/21 01:16:17 shess: please confirm that you want this function
Scott Hess - ex-Googler 2011/12/21 02:41:01 Yeah, the "CREATE INDEX IF NOT EXISTS" will succee
298 db->Execute("CREATE INDEX IF NOT EXISTS cookie_times ON cookies" 298 if (!db->Execute("CREATE INDEX IF NOT EXISTS cookie_times ON cookies"
299 " (creation_utc)"); 299 " (creation_utc)"))
300 return false;
300 301
301 db->Execute("CREATE INDEX IF NOT EXISTS domain ON cookies(host_key)"); 302 if (!db->Execute("CREATE INDEX IF NOT EXISTS domain ON cookies(host_key)"))
303 return false;
302 304
303 return true; 305 return true;
304 } 306 }
305 307
306 } // namespace 308 } // namespace
307 309
308 void SQLitePersistentCookieStore::Backend::Load( 310 void SQLitePersistentCookieStore::Backend::Load(
309 const LoadedCallback& loaded_callback) { 311 const LoadedCallback& loaded_callback) {
310 // This function should be called only once per instance. 312 // This function should be called only once per instance.
311 DCHECK(!db_.get()); 313 DCHECK(!db_.get());
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 if (cur_version == 3) { 666 if (cur_version == 3) {
665 // The time epoch changed for Mac & Linux in this version to match Windows. 667 // The time epoch changed for Mac & Linux in this version to match Windows.
666 // This patch came after the main epoch change happened, so some 668 // This patch came after the main epoch change happened, so some
667 // developers have "good" times for cookies added by the more recent 669 // developers have "good" times for cookies added by the more recent
668 // versions. So we have to be careful to only update times that are under 670 // versions. So we have to be careful to only update times that are under
669 // the old system (which will appear to be from before 1970 in the new 671 // the old system (which will appear to be from before 1970 in the new
670 // system). The magic number used below is 1970 in our time units. 672 // system). The magic number used below is 1970 in our time units.
671 sql::Transaction transaction(db_.get()); 673 sql::Transaction transaction(db_.get());
672 transaction.Begin(); 674 transaction.Begin();
673 #if !defined(OS_WIN) 675 #if !defined(OS_WIN)
674 db_->Execute( 676 ignore_result(db_->Execute(
675 "UPDATE cookies " 677 "UPDATE cookies "
676 "SET creation_utc = creation_utc + 11644473600000000 " 678 "SET creation_utc = creation_utc + 11644473600000000 "
677 "WHERE rowid IN " 679 "WHERE rowid IN "
678 "(SELECT rowid FROM cookies WHERE " 680 "(SELECT rowid FROM cookies WHERE "
679 "creation_utc > 0 AND creation_utc < 11644473600000000)"); 681 "creation_utc > 0 AND creation_utc < 11644473600000000)"));
680 db_->Execute( 682 ignore_result(db_->Execute(
681 "UPDATE cookies " 683 "UPDATE cookies "
682 "SET expires_utc = expires_utc + 11644473600000000 " 684 "SET expires_utc = expires_utc + 11644473600000000 "
683 "WHERE rowid IN " 685 "WHERE rowid IN "
684 "(SELECT rowid FROM cookies WHERE " 686 "(SELECT rowid FROM cookies WHERE "
685 "expires_utc > 0 AND expires_utc < 11644473600000000)"); 687 "expires_utc > 0 AND expires_utc < 11644473600000000)"));
686 db_->Execute( 688 ignore_result(db_->Execute(
687 "UPDATE cookies " 689 "UPDATE cookies "
688 "SET last_access_utc = last_access_utc + 11644473600000000 " 690 "SET last_access_utc = last_access_utc + 11644473600000000 "
689 "WHERE rowid IN " 691 "WHERE rowid IN "
690 "(SELECT rowid FROM cookies WHERE " 692 "(SELECT rowid FROM cookies WHERE "
691 "last_access_utc > 0 AND last_access_utc < 11644473600000000)"); 693 "last_access_utc > 0 AND last_access_utc < 11644473600000000)"));
692 #endif 694 #endif
693 ++cur_version; 695 ++cur_version;
694 meta_table_.SetVersionNumber(cur_version); 696 meta_table_.SetVersionNumber(cur_version);
695 transaction.Commit(); 697 transaction.Commit();
696 } 698 }
697 699
698 if (cur_version == 4) { 700 if (cur_version == 4) {
699 const base::TimeTicks start_time = base::TimeTicks::Now(); 701 const base::TimeTicks start_time = base::TimeTicks::Now();
700 sql::Transaction transaction(db_.get()); 702 sql::Transaction transaction(db_.get());
701 if (!transaction.Begin()) 703 if (!transaction.Begin())
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 if (backend_.get()) 965 if (backend_.get())
964 backend_->SetClearLocalStateOnExit(clear_local_state); 966 backend_->SetClearLocalStateOnExit(clear_local_state);
965 } 967 }
966 968
967 void SQLitePersistentCookieStore::Flush(const base::Closure& callback) { 969 void SQLitePersistentCookieStore::Flush(const base::Closure& callback) {
968 if (backend_.get()) 970 if (backend_.get())
969 backend_->Flush(callback); 971 backend_->Flush(callback);
970 else if (!callback.is_null()) 972 else if (!callback.is_null())
971 MessageLoop::current()->PostTask(FROM_HERE, callback); 973 MessageLoop::current()->PostTask(FROM_HERE, callback);
972 } 974 }
OLDNEW
« no previous file with comments | « chrome/browser/history/visitsegment_database.cc ('k') | sql/connection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698