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

Unified Diff: blimp/client/core/session/connection_status.h

Issue 2322843002: Propagate connection info to Blimp android UI. (Closed)
Patch Set: Merge conflicts. Created 4 years, 3 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 | « blimp/client/core/session/BUILD.gn ('k') | blimp/client/core/session/connection_status.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: blimp/client/core/session/connection_status.h
diff --git a/blimp/client/core/session/connection_status.h b/blimp/client/core/session/connection_status.h
new file mode 100644
index 0000000000000000000000000000000000000000..4655e66e442b701feee60082dadd4448afc54ef5
--- /dev/null
+++ b/blimp/client/core/session/connection_status.h
@@ -0,0 +1,62 @@
+// Copyright 2016 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 BLIMP_CLIENT_CORE_SESSION_CONNECTION_STATUS_H_
+#define BLIMP_CLIENT_CORE_SESSION_CONNECTION_STATUS_H_
+
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "base/observer_list.h"
+#include "blimp/client/core/session/network_event_observer.h"
+#include "blimp/client/public/session/assignment.h"
+#include "net/base/ip_endpoint.h"
+
+namespace blimp {
+namespace client {
+
+// Provides Blimp engine connection status, and also broadcasts connection
+// events to observers on main thread.
+class ConnectionStatus : public NetworkEventObserver {
+ public:
+ ConnectionStatus();
+ ~ConnectionStatus() override;
+
+ // Return if we connected to the engine.
+ bool is_connected() const { return is_connected_; }
+
+ // Get engine IP and port.
+ const net::IPEndPoint& engine_endpoint() const { return engine_endpoint_; }
+
+ // Broadcast network events.
+ void AddObserver(NetworkEventObserver* observer);
+ void RemoveObserver(NetworkEventObserver* observer);
+
+ // Set connection states.
+ void OnAssignmentResult(int result, const Assignment& assignment);
+
+ base::WeakPtr<ConnectionStatus> GetWeakPtr();
+
+ private:
+ // NetworkEventObserver implementation.
+ void OnConnected() override;
+ void OnDisconnected(int result) override;
+
+ // Observers listen to session events.
+ base::ObserverList<NetworkEventObserver> connection_observers_;
+
+ // IP address and port of the engine.
+ net::IPEndPoint engine_endpoint_;
+
+ // If the client is currently connected.
+ bool is_connected_;
+
+ base::WeakPtrFactory<ConnectionStatus> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(ConnectionStatus);
+};
+
+} // namespace client
+} // namespace blimp
+
+#endif // BLIMP_CLIENT_CORE_SESSION_CONNECTION_STATUS_H_
« no previous file with comments | « blimp/client/core/session/BUILD.gn ('k') | blimp/client/core/session/connection_status.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698