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_ |