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

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

Issue 18660004: Extension activity log database refactoring (step 1) (Closed) Base URL: http://git.chromium.org/chromium/src.git@incognito-tests
Patch Set: Fix potential null pointer dereference Created 7 years, 5 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
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_FULLSTREAM_UI_POLICY_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_
6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_ 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 #include "chrome/browser/extensions/activity_log/activity_database.h"
10 #include "chrome/browser/extensions/activity_log/activity_log_policy.h" 11 #include "chrome/browser/extensions/activity_log/activity_log_policy.h"
11 12
12 class GURL; 13 class GURL;
13 14
14 namespace extensions { 15 namespace extensions {
15 16
16 class ActivityDatabase;
17
18 // A policy for logging the full stream of actions, including all arguments. 17 // A policy for logging the full stream of actions, including all arguments.
19 // It's mostly intended to be used in testing and analysis. 18 // It's mostly intended to be used in testing and analysis.
20 class FullStreamUIPolicy : public ActivityLogPolicy { 19 class FullStreamUIPolicy : public ActivityLogPolicy,
20 public ActivityDatabaseCallbacks {
21 public: 21 public:
22 // For more info about these member functions, see the super class. 22 // For more info about these member functions, see the super class.
23 explicit FullStreamUIPolicy(Profile* profile); 23 explicit FullStreamUIPolicy(Profile* profile);
24 24
25 virtual ~FullStreamUIPolicy();
26
27 virtual void ProcessAction(ActionType action_type, 25 virtual void ProcessAction(ActionType action_type,
28 const std::string& extension_id, 26 const std::string& extension_id,
29 const std::string& name, const GURL& gurl, 27 const std::string& name, const GURL& gurl,
30 const base::ListValue* args, 28 const base::ListValue* args,
31 const base::DictionaryValue* details) OVERRIDE; 29 const base::DictionaryValue* details) OVERRIDE;
32 30
33 virtual void SaveState() OVERRIDE {}
34
35 // TODO(felt,dbabic) This is overly specific to FullStreamUIPolicy. 31 // TODO(felt,dbabic) This is overly specific to FullStreamUIPolicy.
36 // It assumes that the callback can return a sorted vector of actions. Some 32 // It assumes that the callback can return a sorted vector of actions. Some
37 // policies might not do that. For instance, imagine a trivial policy that 33 // policies might not do that. For instance, imagine a trivial policy that
38 // just counts the frequency of certain actions within some time period, 34 // just counts the frequency of certain actions within some time period,
39 // this call would be meaningless, as it couldn't return anything useful. 35 // this call would be meaningless, as it couldn't return anything useful.
40 virtual void ReadData( 36 virtual void ReadData(
41 const std::string& extension_id, 37 const std::string& extension_id,
42 const int day, 38 const int day,
43 const base::Callback 39 const base::Callback
44 <void(scoped_ptr<std::vector<scoped_refptr<Action> > >)>& callback) 40 <void(scoped_ptr<std::vector<scoped_refptr<Action> > >)>& callback)
45 const OVERRIDE; 41 const OVERRIDE;
46 42
47 virtual void SetSaveStateOnRequestOnly() OVERRIDE;
48
49 // Returns the actual key for a given key type 43 // Returns the actual key for a given key type
50 virtual std::string GetKey(ActivityLogPolicy::KeyType key_id) const OVERRIDE; 44 virtual std::string GetKey(ActivityLogPolicy::KeyType key_id) const OVERRIDE;
51 45
46 virtual void Close() OVERRIDE;
47
52 protected: 48 protected:
49 // Only ever run by DatabaseCloseCallback().
50 virtual ~FullStreamUIPolicy() {}
51
52 // The ActivityDatabaseCallbacks interface. These are always called from the
53 // database thread.
54 virtual bool DatabaseInitCallback(sql::Connection* db) OVERRIDE;
55 virtual void DatabaseCloseCallback() OVERRIDE;
56
53 // Concatenates arguments 57 // Concatenates arguments
54 virtual std::string ProcessArguments(ActionType action_type, 58 virtual std::string ProcessArguments(ActionType action_type,
55 const std::string& name, 59 const std::string& name,
56 const base::ListValue* args) const; 60 const base::ListValue* args) const;
57 61
58 virtual void ProcessWebRequestModifications( 62 virtual void ProcessWebRequestModifications(
59 base::DictionaryValue& details, 63 base::DictionaryValue& details,
60 std::string& details_string) const; 64 std::string& details_string) const;
61 65
62 // We initialize this on the same thread as the ActivityLog and policy, but 66 // We initialize this on the same thread as the ActivityLog and policy, but
63 // then subsequent operations occur on the DB thread. Instead of destructing 67 // then subsequent operations occur on the DB thread. Instead of destructing
64 // the ActivityDatabase, we call its Close() method on the DB thread and it 68 // the ActivityDatabase, we call its Close() method on the DB thread and it
65 // commits suicide. 69 // commits suicide.
66 ActivityDatabase* db_; 70 ActivityDatabase* db_;
67 }; 71 };
68 72
69 } // namespace extensions 73 } // namespace extensions
70 74
71 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_ 75 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698