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

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

Issue 15573003: New architecture of the activity logging: Policies for summarization (and compression) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed compiler errors on different platforms (at least I hope so). Created 7 years, 7 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
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_
6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_
7
8 #include <sstream>
9 #include "base/bind.h"
10 #include "base/bind_helpers.h"
11 #include "chrome/browser/extensions/activity_log/activity_log_policy.h"
12 #include "content/public/browser/browser_thread.h"
13
14 class GURL;
15
16 namespace extensions {
17
18 class ActivityDatabase;
19
20 class FullStreamUIPolicy : public ActivityLogPolicy {
21 public:
22
23 // For more info about these member functions, see the super class.
24 explicit FullStreamUIPolicy(Profile*);
25
26 virtual ~FullStreamUIPolicy();
27
28 virtual void SaveState() OVERRIDE {}
29
30 // TODO(felt,dbabic) This is overly specific to FullStreamUIPolicy.
felt 2013/05/22 21:17:59 I don't understand why this too specific. Can you
dbabic 2013/05/23 01:35:04 It assumes that the callback can return a sorted v
felt 2013/05/23 04:20:01 Ahhh, OK. Can you add this to the comment so that
dbabic 2013/05/24 00:35:07 Done.
31 virtual void ReadData(const std::string&, const int,
32 const
33 base::Callback<void(scoped_ptr<std::vector<scoped_refptr<Action> > >)>&)
34 const OVERRIDE;
35
36 // Returns the actual key for a given key type
37 virtual void GetKey(ActivityLogPolicy::KeyType, std::string&) const OVERRIDE ;
felt 2013/05/22 21:17:59 Line too long?
dbabic 2013/05/23 01:35:04 Done.
38
39 // An error has happened; we want to rollback and close the db.
40 // Needs to be public so the error delegate can call it.
41 virtual void KillActivityLogDatabase();
42
43 protected:
44 // Concatenates arguments efficiently using stringstream
45 virtual void ProcessArguments(const base::ListValue*, std::stringstream&)
46 const;
47
48 // The Schedule methods dispatch the calls to the database on a
49 // separate thread. We dispatch to the UI thread if the DB thread doesn't
50 // exist, which should only happen in tests where there is no DB thread.
51 template<typename DatabaseFunc>
52 void ScheduleAndForget(DatabaseFunc func) {
53 content::BrowserThread::PostTask(dispatch_thread_,
54 FROM_HERE,
55 base::Bind(func, base::Unretained(db_)));
56 }
57
58 template<typename DatabaseFunc, typename ArgA>
59 void ScheduleAndForget(DatabaseFunc func, ArgA a) {
60 content::BrowserThread::PostTask(dispatch_thread_,
61 FROM_HERE,
62 base::Bind(func, base::Unretained(db_), a));
63 }
64
65 template<typename DatabaseFunc, typename ArgA, typename ArgB>
66 void ScheduleAndForget(DatabaseFunc func, ArgA a, ArgB b) {
67 content::BrowserThread::PostTask(dispatch_thread_,
68 FROM_HERE,
69 base::Bind(func, base::Unretained(db_), a, b));
70 }
71
72 // We initialize this on the same thread as the ActivityLog, but then
73 // subsequent operations occur on the DB thread. Instead of destructing the
74 // ActivityDatabase, we call its Close() method on the DB thread and it
75 // commits suicide.
76 ActivityDatabase* db_;
77
78 // Normally the DB thread. In some cases (tests), it might not exist
79 // we dispatch to the UI thread.
80 content::BrowserThread::ID dispatch_thread_;
felt 2013/05/22 21:17:59 Could the Activity Log specify the thread, instead
dbabic 2013/05/23 01:35:04 Sure, it could be easily passed as a param. Sorry
felt 2013/05/23 04:20:01 Sorry to be unclear: by "the templating" I meant t
dbabic 2013/05/24 00:35:07 Done.
81
82 private:
83 virtual void DoProcessAction(ActionType, const Extension&,
84 const std::string&, const GURL*, const base::ListValue*,
85 const base::DictionaryValue*) OVERRIDE;
86 };
87
88 } // End of the extensions namespace
89
90 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698