| 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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 while (query.is_valid() && query.Step()) { | 492 while (query.is_valid() && query.Step()) { |
| 493 scoped_refptr<Action> action = | 493 scoped_refptr<Action> action = |
| 494 new Action(query.ColumnString(0), | 494 new Action(query.ColumnString(0), |
| 495 base::Time::FromInternalValue(query.ColumnInt64(1)), | 495 base::Time::FromInternalValue(query.ColumnInt64(1)), |
| 496 static_cast<Action::ActionType>(query.ColumnInt(2)), | 496 static_cast<Action::ActionType>(query.ColumnInt(2)), |
| 497 query.ColumnString(3), query.ColumnInt64(10)); | 497 query.ColumnString(3), query.ColumnInt64(10)); |
| 498 | 498 |
| 499 if (query.ColumnType(4) != sql::COLUMN_TYPE_NULL) { | 499 if (query.ColumnType(4) != sql::COLUMN_TYPE_NULL) { |
| 500 std::unique_ptr<base::Value> parsed_value = | 500 std::unique_ptr<base::Value> parsed_value = |
| 501 base::JSONReader::Read(query.ColumnString(4)); | 501 base::JSONReader::Read(query.ColumnString(4)); |
| 502 if (parsed_value && parsed_value->IsType(base::Value::TYPE_LIST)) { | 502 if (parsed_value && parsed_value->IsType(base::Value::Type::LIST)) { |
| 503 action->set_args(base::WrapUnique( | 503 action->set_args(base::WrapUnique( |
| 504 static_cast<base::ListValue*>(parsed_value.release()))); | 504 static_cast<base::ListValue*>(parsed_value.release()))); |
| 505 } | 505 } |
| 506 } | 506 } |
| 507 | 507 |
| 508 action->ParsePageUrl(query.ColumnString(5)); | 508 action->ParsePageUrl(query.ColumnString(5)); |
| 509 action->set_page_title(query.ColumnString(6)); | 509 action->set_page_title(query.ColumnString(6)); |
| 510 action->ParseArgUrl(query.ColumnString(7)); | 510 action->ParseArgUrl(query.ColumnString(7)); |
| 511 | 511 |
| 512 if (query.ColumnType(8) != sql::COLUMN_TYPE_NULL) { | 512 if (query.ColumnType(8) != sql::COLUMN_TYPE_NULL) { |
| 513 std::unique_ptr<base::Value> parsed_value = | 513 std::unique_ptr<base::Value> parsed_value = |
| 514 base::JSONReader::Read(query.ColumnString(8)); | 514 base::JSONReader::Read(query.ColumnString(8)); |
| 515 if (parsed_value && parsed_value->IsType(base::Value::TYPE_DICTIONARY)) { | 515 if (parsed_value && parsed_value->IsType(base::Value::Type::DICTIONARY)) { |
| 516 action->set_other(base::WrapUnique( | 516 action->set_other(base::WrapUnique( |
| 517 static_cast<base::DictionaryValue*>(parsed_value.release()))); | 517 static_cast<base::DictionaryValue*>(parsed_value.release()))); |
| 518 } | 518 } |
| 519 } | 519 } |
| 520 action->set_count(query.ColumnInt(9)); | 520 action->set_count(query.ColumnInt(9)); |
| 521 actions->push_back(action); | 521 actions->push_back(action); |
| 522 } | 522 } |
| 523 | 523 |
| 524 return actions; | 524 return actions; |
| 525 } | 525 } |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 return true; | 795 return true; |
| 796 } | 796 } |
| 797 | 797 |
| 798 void CountingPolicy::Close() { | 798 void CountingPolicy::Close() { |
| 799 // 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. |
| 800 DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::DB)); | 800 DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::DB)); |
| 801 ScheduleAndForget(activity_database(), &ActivityDatabase::Close); | 801 ScheduleAndForget(activity_database(), &ActivityDatabase::Close); |
| 802 } | 802 } |
| 803 | 803 |
| 804 } // namespace extensions | 804 } // namespace extensions |
| OLD | NEW |