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

Unified Diff: chrome/browser/sync/util/extensions_activity_monitor.h

Issue 325001: Introduce browser_sync::ExtensionsActivityMonitor to collect extensions API u... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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
« no previous file with comments | « chrome/browser/sync/protocol/sync.proto ('k') | chrome/browser/sync/util/extensions_activity_monitor.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/util/extensions_activity_monitor.h
===================================================================
--- chrome/browser/sync/util/extensions_activity_monitor.h (revision 0)
+++ chrome/browser/sync/util/extensions_activity_monitor.h (revision 0)
@@ -0,0 +1,74 @@
+// Copyright (c) 2009 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_SYNC_UTIL_EXTENSIONS_ACTIVITY_MONITOR_H_
+#define CHROME_BROWSER_SYNC_UTIL_EXTENSIONS_ACTIVITY_MONITOR_H_
+
+#include "base/lock.h"
+#include "base/message_loop.h"
+#include "base/ref_counted.h"
+#include "chrome/common/notification_observer.h"
+#include "chrome/common/notification_registrar.h"
+
+namespace browser_sync {
+
+// A class to monitor usage of extensions APIs to send to sync servers, with
+// the ability to purge data once sync servers have acknowledged it (successful
+// commit response).
+//
+// This can be used from any thread (it is a 'monitor' in the synchronization
+// sense as well), HOWEVER
+//
+// *** IT MUST BE DELETED FROM THE UI LOOP ***
+//
+// Consider using MessageLoop::DeleteSoon. (Yes, this means if you allocate
+// an ExtensionsActivityMonitor on a thread other than UI, you must 'new' it).
+class ExtensionsActivityMonitor : public NotificationObserver {
+ public:
+ // A data record of activity performed by extension |extension_id|.
+ struct Record {
+ Record() : bookmark_write_count(0U) {}
+
+ // The human-readable ID identifying the extension responsible
+ // for the activity reported in this Record.
+ std::string extension_id;
+
+ // How many times the extension successfully invoked a write
+ // operation through the bookmarks API since the last CommitMessage.
+ uint32 bookmark_write_count;
+ };
+
+ typedef std::map<std::string, Record> Records;
+
+ // Creates an ExtensionsActivityMonitor to monitor extensions activities on
+ // |ui_loop|.
+ explicit ExtensionsActivityMonitor(MessageLoop* ui_loop);
+ ~ExtensionsActivityMonitor();
+
+ // Fills |buffer| with snapshot of current records in constant time by
+ // swapping. This is done mutually exclusively w.r.t methods of this class.
+ void GetAndClearRecords(Records* buffer);
+
+ // Add |records| piece-wise (by extension id) to the set of active records.
+ // This is done mutually exclusively w.r.t the methods of this class.
+ void PutRecords(const Records& records);
+
+ // NotificationObserver implementation. Called on |ui_loop_|.
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+ private:
+ Records records_;
+ mutable Lock records_lock_;
+
+ // Kept for convenience.
+ MessageLoop* const ui_loop_;
+
+ // Used only from UI loop.
+ NotificationRegistrar registrar_;
+};
+
+} // namespace browser_sync
+
+#endif // CHROME_BROWSER_SYNC_UTIL_EXTENSIONS_ACTIVITY_MONITOR_H_
Property changes on: chrome\browser\sync\util\extensions_activity_monitor.h
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « chrome/browser/sync/protocol/sync.proto ('k') | chrome/browser/sync/util/extensions_activity_monitor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698