Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(382)

Side by Side Diff: chrome/browser/extensions/activity_log/counting_policy.h

Issue 23980002: Activity Log: allow searching by day (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed error from last rebase Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_COUNTING_POLICY_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_COUNTING_POLICY_H_
6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_COUNTING_POLICY_H_ 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_COUNTING_POLICY_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
11 #include "chrome/browser/extensions/activity_log/activity_database.h" 11 #include "chrome/browser/extensions/activity_log/activity_database.h"
12 #include "chrome/browser/extensions/activity_log/activity_log_policy.h" 12 #include "chrome/browser/extensions/activity_log/activity_log_policy.h"
13 #include "chrome/browser/extensions/activity_log/database_string_table.h" 13 #include "chrome/browser/extensions/activity_log/database_string_table.h"
14 14
15 namespace extensions { 15 namespace extensions {
16 16
17 // A policy for logging the stream of actions, but without arguments. 17 // A policy for logging the stream of actions, but without arguments.
18 class CountingPolicy : public ActivityLogDatabasePolicy { 18 class CountingPolicy : public ActivityLogDatabasePolicy {
19 public: 19 public:
20 explicit CountingPolicy(Profile* profile); 20 explicit CountingPolicy(Profile* profile);
21 virtual ~CountingPolicy(); 21 virtual ~CountingPolicy();
22 22
23 virtual void ProcessAction(scoped_refptr<Action> action) OVERRIDE; 23 virtual void ProcessAction(scoped_refptr<Action> action) OVERRIDE;
24 24
25 virtual void ReadData(
26 const std::string& extension_id,
27 const int day,
28 const base::Callback
29 <void(scoped_ptr<Action::ActionVector>)>& callback) OVERRIDE;
30
31 virtual void ReadFilteredData( 25 virtual void ReadFilteredData(
32 const std::string& extension_id, 26 const std::string& extension_id,
33 const Action::ActionType type, 27 const Action::ActionType type,
34 const std::string& api_name, 28 const std::string& api_name,
35 const std::string& page_url, 29 const std::string& page_url,
36 const std::string& arg_url, 30 const std::string& arg_url,
31 const int days_ago,
37 const base::Callback 32 const base::Callback
38 <void(scoped_ptr<Action::ActionVector>)>& callback) OVERRIDE; 33 <void(scoped_ptr<Action::ActionVector>)>& callback) OVERRIDE;
39 34
40 virtual void Close() OVERRIDE; 35 virtual void Close() OVERRIDE;
41 36
42 // Gets or sets the amount of time that old records are kept in the database. 37 // Gets or sets the amount of time that old records are kept in the database.
43 const base::TimeDelta& retention_time() const { return retention_time_; } 38 const base::TimeDelta& retention_time() const { return retention_time_; }
44 void set_retention_time(const base::TimeDelta& delta) { 39 void set_retention_time(const base::TimeDelta& delta) {
45 retention_time_ = delta; 40 retention_time_ = delta;
46 } 41 }
(...skipping 23 matching lines...) Expand all
70 // incremented in the database. 65 // incremented in the database.
71 typedef std::map<scoped_refptr<Action>, int, ActionComparatorExcludingTime> 66 typedef std::map<scoped_refptr<Action>, int, ActionComparatorExcludingTime>
72 ActionQueue; 67 ActionQueue;
73 68
74 // Adds an Action to those to be written out; this is an internal method used 69 // Adds an Action to those to be written out; this is an internal method used
75 // by ProcessAction and is called on the database thread. 70 // by ProcessAction and is called on the database thread.
76 void QueueAction(scoped_refptr<Action> action); 71 void QueueAction(scoped_refptr<Action> action);
77 72
78 // Internal method to read data from the database; called on the database 73 // Internal method to read data from the database; called on the database
79 // thread. 74 // thread.
80 scoped_ptr<Action::ActionVector> DoReadData(
81 const std::string& extension_id,
82 const int days_ago);
83
84 // Internal method to read data from the database; called on the database
85 // thread.
86 scoped_ptr<Action::ActionVector> DoReadFilteredData( 75 scoped_ptr<Action::ActionVector> DoReadFilteredData(
87 const std::string& extension_id, 76 const std::string& extension_id,
88 const Action::ActionType type, 77 const Action::ActionType type,
89 const std::string& api_name, 78 const std::string& api_name,
90 const std::string& page_url, 79 const std::string& page_url,
91 const std::string& arg_url); 80 const std::string& arg_url,
81 const int days_ago);
92 82
93 // The implementation of RemoveURLs; this must only run on the database 83 // The implementation of RemoveURLs; this must only run on the database
94 // thread. 84 // thread.
95 void DoRemoveURLs(const std::vector<GURL>& restrict_urls); 85 void DoRemoveURLs(const std::vector<GURL>& restrict_urls);
96 86
97 // The implementation of DeleteDatabase; called on the database thread. 87 // The implementation of DeleteDatabase; called on the database thread.
98 void DoDeleteDatabase(); 88 void DoDeleteDatabase();
99 89
100 // Cleans old records from the activity log database. 90 // Cleans old records from the activity log database.
101 bool CleanOlderThan(sql::Connection* db, const base::Time& cutoff); 91 bool CleanOlderThan(sql::Connection* db, const base::Time& cutoff);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 126
137 friend class CountingPolicyTest; 127 friend class CountingPolicyTest;
138 FRIEND_TEST_ALL_PREFIXES(CountingPolicyTest, EarlyFlush); 128 FRIEND_TEST_ALL_PREFIXES(CountingPolicyTest, EarlyFlush);
139 FRIEND_TEST_ALL_PREFIXES(CountingPolicyTest, MergingAndExpiring); 129 FRIEND_TEST_ALL_PREFIXES(CountingPolicyTest, MergingAndExpiring);
140 FRIEND_TEST_ALL_PREFIXES(CountingPolicyTest, StringTableCleaning); 130 FRIEND_TEST_ALL_PREFIXES(CountingPolicyTest, StringTableCleaning);
141 }; 131 };
142 132
143 } // namespace extensions 133 } // namespace extensions
144 134
145 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_COUNTING_POLICY_H_ 135 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_COUNTING_POLICY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698