OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // A policy for storing activity log data to a database that performs | 5 // A policy for storing activity log data to a database that performs |
6 // aggregation to reduce the size of the database. The database layout is | 6 // aggregation to reduce the size of the database. The database layout is |
7 // nearly the same as FullStreamUIPolicy, which stores a complete log, with a | 7 // nearly the same as FullStreamUIPolicy, which stores a complete log, with a |
8 // few changes: | 8 // few changes: |
9 // - a "count" column is added to track how many log records were merged | 9 // - a "count" column is added to track how many log records were merged |
10 // together into this row | 10 // together into this row |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 retention_time_(base::TimeDelta::FromHours(60)) { | 172 retention_time_(base::TimeDelta::FromHours(60)) { |
173 for (size_t i = 0; i < arraysize(kAlwaysLog); i++) { | 173 for (size_t i = 0; i < arraysize(kAlwaysLog); i++) { |
174 api_arg_whitelist_.insert( | 174 api_arg_whitelist_.insert( |
175 std::make_pair(kAlwaysLog[i].type, kAlwaysLog[i].name)); | 175 std::make_pair(kAlwaysLog[i].type, kAlwaysLog[i].name)); |
176 } | 176 } |
177 } | 177 } |
178 | 178 |
179 CountingPolicy::~CountingPolicy() {} | 179 CountingPolicy::~CountingPolicy() {} |
180 | 180 |
181 bool CountingPolicy::InitDatabase(sql::Connection* db) { | 181 bool CountingPolicy::InitDatabase(sql::Connection* db) { |
182 if (!Util::DropObsoleteTables(db)) | |
183 return false; | |
184 | |
185 if (!string_table_.Initialize(db)) | 182 if (!string_table_.Initialize(db)) |
186 return false; | 183 return false; |
187 if (!url_table_.Initialize(db)) | 184 if (!url_table_.Initialize(db)) |
188 return false; | 185 return false; |
189 | 186 |
190 // Create the unified activity log entry table. | 187 // Create the unified activity log entry table. |
191 if (!ActivityDatabase::InitializeTable(db, | 188 if (!ActivityDatabase::InitializeTable(db, |
192 kTableName, | 189 kTableName, |
193 kTableContentFields, | 190 kTableContentFields, |
194 kTableFieldTypes, | 191 kTableFieldTypes, |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 return true; | 795 return true; |
799 } | 796 } |
800 | 797 |
801 void CountingPolicy::Close() { | 798 void CountingPolicy::Close() { |
802 // The policy object should have never been created if there's no DB thread. | 799 // The policy object should have never been created if there's no DB thread. |
803 DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::DB)); | 800 DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::DB)); |
804 ScheduleAndForget(activity_database(), &ActivityDatabase::Close); | 801 ScheduleAndForget(activity_database(), &ActivityDatabase::Close); |
805 } | 802 } |
806 | 803 |
807 } // namespace extensions | 804 } // namespace extensions |
OLD | NEW |