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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/activity_log/fullstream_ui_policy.h
diff --git a/chrome/browser/extensions/activity_log/fullstream_ui_policy.h b/chrome/browser/extensions/activity_log/fullstream_ui_policy.h
new file mode 100644
index 0000000000000000000000000000000000000000..a7087f07b6ad09b243f99bf5ccf7e532a9e57d16
--- /dev/null
+++ b/chrome/browser/extensions/activity_log/fullstream_ui_policy.h
@@ -0,0 +1,90 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_
+#define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_
+
+#include <sstream>
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "chrome/browser/extensions/activity_log/activity_log_policy.h"
+#include "content/public/browser/browser_thread.h"
+
+class GURL;
+
+namespace extensions {
+
+class ActivityDatabase;
+
+class FullStreamUIPolicy : public ActivityLogPolicy {
+ public:
+
+ // For more info about these member functions, see the super class.
+ explicit FullStreamUIPolicy(Profile*);
+
+ virtual ~FullStreamUIPolicy();
+
+ virtual void SaveState() OVERRIDE {}
+
+ // 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.
+ virtual void ReadData(const std::string&, const int,
+ const
+ base::Callback<void(scoped_ptr<std::vector<scoped_refptr<Action> > >)>&)
+ const OVERRIDE;
+
+ // Returns the actual key for a given key type
+ 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.
+
+ // An error has happened; we want to rollback and close the db.
+ // Needs to be public so the error delegate can call it.
+ virtual void KillActivityLogDatabase();
+
+ protected:
+ // Concatenates arguments efficiently using stringstream
+ virtual void ProcessArguments(const base::ListValue*, std::stringstream&)
+ const;
+
+ // The Schedule methods dispatch the calls to the database on a
+ // separate thread. We dispatch to the UI thread if the DB thread doesn't
+ // exist, which should only happen in tests where there is no DB thread.
+ template<typename DatabaseFunc>
+ void ScheduleAndForget(DatabaseFunc func) {
+ content::BrowserThread::PostTask(dispatch_thread_,
+ FROM_HERE,
+ base::Bind(func, base::Unretained(db_)));
+ }
+
+ template<typename DatabaseFunc, typename ArgA>
+ void ScheduleAndForget(DatabaseFunc func, ArgA a) {
+ content::BrowserThread::PostTask(dispatch_thread_,
+ FROM_HERE,
+ base::Bind(func, base::Unretained(db_), a));
+ }
+
+ template<typename DatabaseFunc, typename ArgA, typename ArgB>
+ void ScheduleAndForget(DatabaseFunc func, ArgA a, ArgB b) {
+ content::BrowserThread::PostTask(dispatch_thread_,
+ FROM_HERE,
+ base::Bind(func, base::Unretained(db_), a, b));
+ }
+
+ // We initialize this on the same thread as the ActivityLog, but then
+ // subsequent operations occur on the DB thread. Instead of destructing the
+ // ActivityDatabase, we call its Close() method on the DB thread and it
+ // commits suicide.
+ ActivityDatabase* db_;
+
+ // Normally the DB thread. In some cases (tests), it might not exist
+ // we dispatch to the UI thread.
+ 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.
+
+ private:
+ virtual void DoProcessAction(ActionType, const Extension&,
+ const std::string&, const GURL*, const base::ListValue*,
+ const base::DictionaryValue*) OVERRIDE;
+};
+
+} // End of the extensions namespace
+
+#endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_

Powered by Google App Engine
This is Rietveld 408576698