| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 batching_period_ = base::TimeDelta::FromMinutes(2); | 50 batching_period_ = base::TimeDelta::FromMinutes(2); |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 | 53 |
| 54 ActivityDatabase::~ActivityDatabase() {} | 54 ActivityDatabase::~ActivityDatabase() {} |
| 55 | 55 |
| 56 void ActivityDatabase::Init(const base::FilePath& db_name) { | 56 void ActivityDatabase::Init(const base::FilePath& db_name) { |
| 57 if (did_init_) return; | 57 if (did_init_) return; |
| 58 did_init_ = true; | 58 did_init_ = true; |
| 59 if (BrowserThread::IsMessageLoopValid(BrowserThread::DB)) | 59 if (BrowserThread::IsMessageLoopValid(BrowserThread::DB)) |
| 60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 60 DCHECK_CURRENTLY_ON(BrowserThread::DB); |
| 61 db_.set_histogram_tag("Activity"); | 61 db_.set_histogram_tag("Activity"); |
| 62 db_.set_error_callback( | 62 db_.set_error_callback( |
| 63 base::Bind(&ActivityDatabase::DatabaseErrorCallback, | 63 base::Bind(&ActivityDatabase::DatabaseErrorCallback, |
| 64 base::Unretained(this))); | 64 base::Unretained(this))); |
| 65 db_.set_page_size(4096); | 65 db_.set_page_size(4096); |
| 66 db_.set_cache_size(32); | 66 db_.set_cache_size(32); |
| 67 | 67 |
| 68 if (!db_.Open(db_name)) { | 68 if (!db_.Open(db_name)) { |
| 69 LOG(ERROR) << db_.GetErrorMessage(); | 69 LOG(ERROR) << db_.GetErrorMessage(); |
| 70 return LogInitFailure(); | 70 return LogInitFailure(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 &ActivityDatabase::RecordBatchedActions); | 129 &ActivityDatabase::RecordBatchedActions); |
| 130 } else if (!batch_mode && batch_mode_) { | 130 } else if (!batch_mode && batch_mode_) { |
| 131 timer_.Stop(); | 131 timer_.Stop(); |
| 132 RecordBatchedActions(); | 132 RecordBatchedActions(); |
| 133 } | 133 } |
| 134 batch_mode_ = batch_mode; | 134 batch_mode_ = batch_mode; |
| 135 } | 135 } |
| 136 | 136 |
| 137 sql::Connection* ActivityDatabase::GetSqlConnection() { | 137 sql::Connection* ActivityDatabase::GetSqlConnection() { |
| 138 if (BrowserThread::IsMessageLoopValid(BrowserThread::DB)) | 138 if (BrowserThread::IsMessageLoopValid(BrowserThread::DB)) |
| 139 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 139 DCHECK_CURRENTLY_ON(BrowserThread::DB); |
| 140 if (valid_db_) { | 140 if (valid_db_) { |
| 141 return &db_; | 141 return &db_; |
| 142 } else { | 142 } else { |
| 143 LOG(WARNING) << "Activity log database is not valid"; | 143 LOG(WARNING) << "Activity log database is not valid"; |
| 144 return NULL; | 144 return NULL; |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 | 147 |
| 148 void ActivityDatabase::Close() { | 148 void ActivityDatabase::Close() { |
| 149 timer_.Stop(); | 149 timer_.Stop(); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 field_types[i]); | 229 field_types[i]); |
| 230 if (!db->Execute(table_updater.c_str())) | 230 if (!db->Execute(table_updater.c_str())) |
| 231 return false; | 231 return false; |
| 232 } | 232 } |
| 233 } | 233 } |
| 234 } | 234 } |
| 235 return true; | 235 return true; |
| 236 } | 236 } |
| 237 | 237 |
| 238 } // namespace extensions | 238 } // namespace extensions |
| OLD | NEW |