| 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 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 | 483 |
| 484 // Execute the query and get results. | 484 // Execute the query and get results. |
| 485 while (query.is_valid() && query.Step()) { | 485 while (query.is_valid() && query.Step()) { |
| 486 scoped_refptr<Action> action = | 486 scoped_refptr<Action> action = |
| 487 new Action(query.ColumnString(0), | 487 new Action(query.ColumnString(0), |
| 488 base::Time::FromInternalValue(query.ColumnInt64(1)), | 488 base::Time::FromInternalValue(query.ColumnInt64(1)), |
| 489 static_cast<Action::ActionType>(query.ColumnInt(2)), | 489 static_cast<Action::ActionType>(query.ColumnInt(2)), |
| 490 query.ColumnString(3)); | 490 query.ColumnString(3)); |
| 491 | 491 |
| 492 if (query.ColumnType(4) != sql::COLUMN_TYPE_NULL) { | 492 if (query.ColumnType(4) != sql::COLUMN_TYPE_NULL) { |
| 493 scoped_ptr<Value> parsed_value( | 493 scoped_ptr<base::Value> parsed_value( |
| 494 base::JSONReader::Read(query.ColumnString(4))); | 494 base::JSONReader::Read(query.ColumnString(4))); |
| 495 if (parsed_value && parsed_value->IsType(Value::TYPE_LIST)) { | 495 if (parsed_value && parsed_value->IsType(base::Value::TYPE_LIST)) { |
| 496 action->set_args( | 496 action->set_args(make_scoped_ptr( |
| 497 make_scoped_ptr(static_cast<ListValue*>(parsed_value.release()))); | 497 static_cast<base::ListValue*>(parsed_value.release()))); |
| 498 } | 498 } |
| 499 } | 499 } |
| 500 | 500 |
| 501 action->ParsePageUrl(query.ColumnString(5)); | 501 action->ParsePageUrl(query.ColumnString(5)); |
| 502 action->set_page_title(query.ColumnString(6)); | 502 action->set_page_title(query.ColumnString(6)); |
| 503 action->ParseArgUrl(query.ColumnString(7)); | 503 action->ParseArgUrl(query.ColumnString(7)); |
| 504 | 504 |
| 505 if (query.ColumnType(8) != sql::COLUMN_TYPE_NULL) { | 505 if (query.ColumnType(8) != sql::COLUMN_TYPE_NULL) { |
| 506 scoped_ptr<Value> parsed_value( | 506 scoped_ptr<base::Value> parsed_value( |
| 507 base::JSONReader::Read(query.ColumnString(8))); | 507 base::JSONReader::Read(query.ColumnString(8))); |
| 508 if (parsed_value && parsed_value->IsType(Value::TYPE_DICTIONARY)) { | 508 if (parsed_value && parsed_value->IsType(base::Value::TYPE_DICTIONARY)) { |
| 509 action->set_other(make_scoped_ptr( | 509 action->set_other(make_scoped_ptr( |
| 510 static_cast<DictionaryValue*>(parsed_value.release()))); | 510 static_cast<base::DictionaryValue*>(parsed_value.release()))); |
| 511 } | 511 } |
| 512 } | 512 } |
| 513 action->set_count(query.ColumnInt(9)); | 513 action->set_count(query.ColumnInt(9)); |
| 514 actions->push_back(action); | 514 actions->push_back(action); |
| 515 } | 515 } |
| 516 | 516 |
| 517 return actions.Pass(); | 517 return actions.Pass(); |
| 518 } | 518 } |
| 519 | 519 |
| 520 void CountingPolicy::DoRemoveURLs(const std::vector<GURL>& restrict_urls) { | 520 void CountingPolicy::DoRemoveURLs(const std::vector<GURL>& restrict_urls) { |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 return true; | 744 return true; |
| 745 } | 745 } |
| 746 | 746 |
| 747 void CountingPolicy::Close() { | 747 void CountingPolicy::Close() { |
| 748 // The policy object should have never been created if there's no DB thread. | 748 // The policy object should have never been created if there's no DB thread. |
| 749 DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::DB)); | 749 DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::DB)); |
| 750 ScheduleAndForget(activity_database(), &ActivityDatabase::Close); | 750 ScheduleAndForget(activity_database(), &ActivityDatabase::Close); |
| 751 } | 751 } |
| 752 | 752 |
| 753 } // namespace extensions | 753 } // namespace extensions |
| OLD | NEW |