| 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 "chrome/browser/extensions/activity_log/activity_database.h" | 5 #include "chrome/browser/extensions/activity_log/activity_database.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 did_init_ = true; | 59 did_init_ = true; |
| 60 if (BrowserThread::IsMessageLoopValid(BrowserThread::DB)) | 60 if (BrowserThread::IsMessageLoopValid(BrowserThread::DB)) |
| 61 DCHECK_CURRENTLY_ON(BrowserThread::DB); | 61 DCHECK_CURRENTLY_ON(BrowserThread::DB); |
| 62 db_.set_histogram_tag("Activity"); | 62 db_.set_histogram_tag("Activity"); |
| 63 db_.set_error_callback( | 63 db_.set_error_callback( |
| 64 base::Bind(&ActivityDatabase::DatabaseErrorCallback, | 64 base::Bind(&ActivityDatabase::DatabaseErrorCallback, |
| 65 base::Unretained(this))); | 65 base::Unretained(this))); |
| 66 db_.set_page_size(4096); | 66 db_.set_page_size(4096); |
| 67 db_.set_cache_size(32); | 67 db_.set_cache_size(32); |
| 68 | 68 |
| 69 // TODO(shess): The current mitigation for http://crbug.com/537742 stores |
| 70 // state in the meta table, which this database does not use. |
| 71 db_.set_mmap_disabled(); |
| 72 |
| 69 if (!db_.Open(db_name)) { | 73 if (!db_.Open(db_name)) { |
| 70 LOG(ERROR) << db_.GetErrorMessage(); | 74 LOG(ERROR) << db_.GetErrorMessage(); |
| 71 return LogInitFailure(); | 75 return LogInitFailure(); |
| 72 } | 76 } |
| 73 | 77 |
| 74 // Wrap the initialization in a transaction so that the db doesn't | 78 // Wrap the initialization in a transaction so that the db doesn't |
| 75 // get corrupted if init fails/crashes. | 79 // get corrupted if init fails/crashes. |
| 76 sql::Transaction committer(&db_); | 80 sql::Transaction committer(&db_); |
| 77 if (!committer.Begin()) | 81 if (!committer.Begin()) |
| 78 return LogInitFailure(); | 82 return LogInitFailure(); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 field_types[i]); | 234 field_types[i]); |
| 231 if (!db->Execute(table_updater.c_str())) | 235 if (!db->Execute(table_updater.c_str())) |
| 232 return false; | 236 return false; |
| 233 } | 237 } |
| 234 } | 238 } |
| 235 } | 239 } |
| 236 return true; | 240 return true; |
| 237 } | 241 } |
| 238 | 242 |
| 239 } // namespace extensions | 243 } // namespace extensions |
| OLD | NEW |