OLD | NEW |
---|---|
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 "sql/connection.h" | 5 #include "sql/connection.h" |
6 | 6 |
7 #include <limits.h> | 7 #include <limits.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
987 if (!Execute(sql_shrink.c_str())) | 987 if (!Execute(sql_shrink.c_str())) |
988 DLOG(WARNING) << "Could not shrink cache size: " << GetErrorMessage(); | 988 DLOG(WARNING) << "Could not shrink cache size: " << GetErrorMessage(); |
989 | 989 |
990 // Restore cache size. | 990 // Restore cache size. |
991 const std::string sql_restore = | 991 const std::string sql_restore = |
992 base::StringPrintf("PRAGMA cache_size=%d", original_cache_size); | 992 base::StringPrintf("PRAGMA cache_size=%d", original_cache_size); |
993 if (!Execute(sql_restore.c_str())) | 993 if (!Execute(sql_restore.c_str())) |
994 DLOG(WARNING) << "Could not restore cache size: " << GetErrorMessage(); | 994 DLOG(WARNING) << "Could not restore cache size: " << GetErrorMessage(); |
995 } | 995 } |
996 | 996 |
997 bool Connection::UpdateCacheSize(int new_cache_size) { | |
998 if (!db_) | |
999 return false; | |
1000 if (cache_size_ == new_cache_size) | |
1001 return true; | |
Scott Hess - ex-Googler
2016/09/01 18:29:09
I think this is fine, but might not even be worth
| |
1002 | |
1003 const std::string sql = | |
1004 base::StringPrintf("PRAGMA cache_size=%d", new_cache_size); | |
1005 if (!Execute(sql.c_str())) { | |
1006 DLOG(WARNING) << "Could not update cache size: " << GetErrorMessage(); | |
Scott Hess - ex-Googler
2016/09/01 18:29:09
Execute() will already emit messages in case of er
| |
1007 return false; | |
1008 } | |
1009 cache_size_ = new_cache_size; | |
1010 return true; | |
1011 } | |
1012 | |
997 // Create an in-memory database with the existing database's page | 1013 // Create an in-memory database with the existing database's page |
998 // size, then backup that database over the existing database. | 1014 // size, then backup that database over the existing database. |
999 bool Connection::Raze() { | 1015 bool Connection::Raze() { |
1000 AssertIOAllowed(); | 1016 AssertIOAllowed(); |
1001 | 1017 |
1002 if (!db_) { | 1018 if (!db_) { |
1003 DLOG_IF(FATAL, !poisoned_) << "Cannot raze null db"; | 1019 DLOG_IF(FATAL, !poisoned_) << "Cannot raze null db"; |
1004 return false; | 1020 return false; |
1005 } | 1021 } |
1006 | 1022 |
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1987 ignore_result(Execute(kNoWritableSchema)); | 2003 ignore_result(Execute(kNoWritableSchema)); |
1988 | 2004 |
1989 return ret; | 2005 return ret; |
1990 } | 2006 } |
1991 | 2007 |
1992 base::TimeTicks TimeSource::Now() { | 2008 base::TimeTicks TimeSource::Now() { |
1993 return base::TimeTicks::Now(); | 2009 return base::TimeTicks::Now(); |
1994 } | 2010 } |
1995 | 2011 |
1996 } // namespace sql | 2012 } // namespace sql |
OLD | NEW |