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

Unified Diff: sql/connection.cc

Issue 2297243004: [WIP] histroy: Adjust cache size OnMemoryStateChange() (Closed)
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« sql/connection.h ('K') | « sql/connection.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sql/connection.cc
diff --git a/sql/connection.cc b/sql/connection.cc
index 073b032cde62157b69a91512a357ce450eb1e4d5..66b2bc1b53881fca6251c36d8e0d9ce9591cc485 100644
--- a/sql/connection.cc
+++ b/sql/connection.cc
@@ -994,6 +994,22 @@ void Connection::TrimMemory(bool aggressively) {
DLOG(WARNING) << "Could not restore cache size: " << GetErrorMessage();
}
+bool Connection::UpdateCacheSize(int new_cache_size) {
+ if (!db_)
+ return false;
+ if (cache_size_ == new_cache_size)
+ return true;
Scott Hess - ex-Googler 2016/09/01 18:29:09 I think this is fine, but might not even be worth
+
+ const std::string sql =
+ base::StringPrintf("PRAGMA cache_size=%d", new_cache_size);
+ if (!Execute(sql.c_str())) {
+ 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
+ return false;
+ }
+ cache_size_ = new_cache_size;
+ return true;
+}
+
// Create an in-memory database with the existing database's page
// size, then backup that database over the existing database.
bool Connection::Raze() {
« sql/connection.h ('K') | « sql/connection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698