Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef BLIMP_CLIENT_CORE_SESSION_CONNECTION_STATUS_H_ | |
| 6 #define BLIMP_CLIENT_CORE_SESSION_CONNECTION_STATUS_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "base/observer_list.h" | |
| 10 #include "blimp/client/core/session/network_event_observer.h" | |
| 11 #include "blimp/client/public/session/assignment.h" | |
| 12 #include "net/base/ip_endpoint.h" | |
| 13 | |
| 14 namespace blimp { | |
| 15 namespace client { | |
| 16 | |
| 17 // Provides Blimp engine connection status, and also handles observers | |
| 18 // that listen to network connection events on main thread. | |
| 19 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.
| |
| 20 public: | |
| 21 ConnectionStatus(); | |
| 22 ~ConnectionStatus(); | |
| 23 | |
| 24 // Return if the engine IP and port is valid. | |
| 25 bool IsValid() const; | |
| 26 | |
| 27 // Get engine IP and port. | |
| 28 const net::IPEndPoint& GetIpEndPoint(); | |
| 29 | |
| 30 // Return if we connected to the engine. | |
| 31 bool IsConnected() const; | |
| 32 | |
| 33 // Broadcast network events. | |
| 34 void AddObserver(NetworkEventObserver* observer); | |
| 35 void RemoveObserver(NetworkEventObserver* observer); | |
| 36 | |
| 37 // Set connection states. | |
| 38 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.
| |
| 39 void OnConnected(); | |
| 40 void OnDisconnected(int result); | |
| 41 | |
| 42 private: | |
| 43 // Observers listen to session events. | |
| 44 base::ObserverList<NetworkEventObserver> connection_observers_; | |
| 45 | |
| 46 // IP address and port of the engine. | |
| 47 net::IPEndPoint engine_endpoint_; | |
| 48 | |
| 49 // If the client is currently connected. | |
| 50 bool is_connected_; | |
| 51 | |
| 52 DISALLOW_COPY_AND_ASSIGN(ConnectionStatus); | |
| 53 }; | |
| 54 | |
| 55 } // namespace client | |
| 56 } // namespace blimp | |
| 57 | |
| 58 #endif // BLIMP_CLIENT_CORE_SESSION_CONNECTION_STATUS_H_ | |
| OLD | NEW |