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

Unified Diff: components/copresence/public/copresence_state.h

Issue 764673003: Adding CopresenceState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing overzealous DCHECK Created 6 years 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: components/copresence/public/copresence_state.h
diff --git a/components/copresence/public/copresence_state.h b/components/copresence/public/copresence_state.h
new file mode 100644
index 0000000000000000000000000000000000000000..1ca8769d091349c465ce9e8978d4e29656a74c84
--- /dev/null
+++ b/components/copresence/public/copresence_state.h
@@ -0,0 +1,49 @@
+// Copyright 2014 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 COMPONENTS_COPRESENCE_PUBLIC_COPRESENCE_STATE_H_
+#define COMPONENTS_COPRESENCE_PUBLIC_COPRESENCE_STATE_H_
+
+#include <map>
+#include <string>
+#include <vector>
+
+namespace copresence {
+
+class CopresenceObserver;
+class Directive;
+struct TransmittedToken;
+struct ReceivedToken;
+
+// This class tracks the state of the copresence component and can notify
+// interested parties when it changes. This is useful for debugging purposes.
+class CopresenceState {
+ public:
+ CopresenceState() {}
+ virtual ~CopresenceState() {}
+
+ // Add a listener for future state changes. |observer| is owned by the caller,
+ // and must be valid until removed (or the CopresenceState is destroyed).
+ virtual void AddObserver(CopresenceObserver* observer) = 0;
+
+ // Remove a state change listener.
+ virtual void RemoveObserver(CopresenceObserver* observer) = 0;
+
+ // Accessor for the currently active directives.
+ virtual const std::vector<Directive>& active_directives() = 0;
xiyuan 2014/12/18 18:10:52 nit: Can this and the two accessors below be const
Charlie 2014/12/19 03:53:33 Done.
+
+ // Accessor for recently transmitted tokens.
+ virtual const std::map<std::string, TransmittedToken>&
+ transmitted_tokens() = 0;
+
+ // Accessor for recently received tokens.
+ virtual const std::map<std::string, ReceivedToken>& received_tokens() = 0;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(CopresenceState);
+};
+
+} // namespace copresence
+
+#endif // COMPONENTS_COPRESENCE_PUBLIC_COPRESENCE_STATE_H_

Powered by Google App Engine
This is Rietveld 408576698