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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 where_next = " AND "; | 435 where_next = " AND "; |
436 } | 436 } |
437 if (!page_url.empty()) { | 437 if (!page_url.empty()) { |
438 where_str += where_next + "page_url LIKE ?"; | 438 where_str += where_next + "page_url LIKE ?"; |
439 where_next = " AND "; | 439 where_next = " AND "; |
440 } | 440 } |
441 if (!arg_url.empty()) | 441 if (!arg_url.empty()) |
442 where_str += where_next + "arg_url LIKE ?"; | 442 where_str += where_next + "arg_url LIKE ?"; |
443 std::string query_str = base::StringPrintf( | 443 std::string query_str = base::StringPrintf( |
444 "SELECT extension_id,time, action_type, api_name, args, page_url," | 444 "SELECT extension_id,time, action_type, api_name, args, page_url," |
445 "page_title, arg_url, other, count FROM %s WHERE %s ORDER BY time DESC", | 445 "page_title, arg_url, other, count FROM %s WHERE %s ORDER BY count DESC " |
| 446 "LIMIT 300", |
446 kReadViewName, | 447 kReadViewName, |
447 where_str.c_str()); | 448 where_str.c_str()); |
448 sql::Statement query(db->GetUniqueStatement(query_str.c_str())); | 449 sql::Statement query(db->GetUniqueStatement(query_str.c_str())); |
449 int i = -1; | 450 int i = -1; |
450 if (!extension_id.empty()) | 451 if (!extension_id.empty()) |
451 query.BindString(++i, extension_id); | 452 query.BindString(++i, extension_id); |
452 if (!api_name.empty()) | 453 if (!api_name.empty()) |
453 query.BindString(++i, api_name); | 454 query.BindString(++i, api_name); |
454 if (type != Action::ACTION_ANY) | 455 if (type != Action::ACTION_ANY) |
455 query.BindInt(++i, static_cast<int>(type)); | 456 query.BindInt(++i, static_cast<int>(type)); |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 return true; | 720 return true; |
720 } | 721 } |
721 | 722 |
722 void CountingPolicy::Close() { | 723 void CountingPolicy::Close() { |
723 // The policy object should have never been created if there's no DB thread. | 724 // The policy object should have never been created if there's no DB thread. |
724 DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::DB)); | 725 DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::DB)); |
725 ScheduleAndForget(activity_database(), &ActivityDatabase::Close); | 726 ScheduleAndForget(activity_database(), &ActivityDatabase::Close); |
726 } | 727 } |
727 | 728 |
728 } // namespace extensions | 729 } // namespace extensions |
OLD | NEW |