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

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

Issue 2322843002: Propagate connection info to Blimp android UI. (Closed)
Patch Set: Remove BlimpStringUtil after discussion of string res files. 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
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..4a1357016f88bff10c76a3a2de27e46a9479d39f
--- /dev/null
+++ b/blimp/client/core/session/connection_status.h
@@ -0,0 +1,58 @@
+// 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/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 handles observers
+// that listen to network connection events on main thread.
+class ConnectionStatus {
David Trainor- moved to gerrit 2016/09/09 19:33:47 Should this be a NetworkEventObserver and BlimpCli
xingliu 2016/09/10 22:45:47 Done.
+ public:
+ ConnectionStatus();
+ ~ConnectionStatus();
+
+ // Return if the engine IP and port is valid.
+ bool IsValid() const;
+
+ // Get engine IP and port.
+ const net::IPEndPoint& GetIpEndPoint();
+
+ // Return if we connected to the engine.
+ bool IsConnected() const;
+
+ // Broadcast network events.
+ void AddObserver(NetworkEventObserver* observer);
+ void RemoveObserver(NetworkEventObserver* observer);
+
+ // Set connection states.
+ void onAssignmentResult(int result, const Assignment& assignment);
David Trainor- moved to gerrit 2016/09/09 19:33:47 on -> On
xingliu 2016/09/10 22:45:46 Done.
+ void OnConnected();
+ void OnDisconnected(int result);
+
+ private:
+ // 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_;
+
+ DISALLOW_COPY_AND_ASSIGN(ConnectionStatus);
+};
+
+} // namespace client
+} // namespace blimp
+
+#endif // BLIMP_CLIENT_CORE_SESSION_CONNECTION_STATUS_H_

Powered by Google App Engine
This is Rietveld 408576698