Chromium Code Reviews| Index: blimp/client/core/session/connection_status.cc |
| diff --git a/blimp/client/core/session/connection_status.cc b/blimp/client/core/session/connection_status.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..aea8d239ccb0da3f447176c1b387da8db32e86a8 |
| --- /dev/null |
| +++ b/blimp/client/core/session/connection_status.cc |
| @@ -0,0 +1,53 @@ |
| +// 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. |
| + |
| +#include "blimp/client/core/session/connection_status.h" |
| + |
| +namespace blimp { |
| +namespace client { |
| + |
| +ConnectionStatus::ConnectionStatus() |
| + : is_connected_(false), weak_factory_(this) {} |
| +ConnectionStatus::~ConnectionStatus() = default; |
|
David Trainor- moved to gerrit
2016/09/13 05:54:51
new line before this
xingliu
2016/09/13 18:36:15
Done.
|
| + |
| +const net::IPEndPoint& ConnectionStatus::GetIpEndPoint() { |
|
David Trainor- moved to gerrit
2016/09/13 05:54:51
inline this in header? same with is_connected()
xingliu
2016/09/13 18:36:15
Done.
|
| + return engine_endpoint_; |
| +} |
| + |
| +bool ConnectionStatus::IsConnected() const { |
| + return is_connected_; |
| +} |
| + |
| +void ConnectionStatus::AddObserver(NetworkEventObserver* observer) { |
| + connection_observers_.AddObserver(observer); |
| +} |
| + |
| +void ConnectionStatus::RemoveObserver(NetworkEventObserver* observer) { |
| + connection_observers_.RemoveObserver(observer); |
| +} |
| + |
| +void ConnectionStatus::OnAssignmentResult(int result, |
| + const Assignment& assignment) { |
| + if (result == AssignmentRequestResult::ASSIGNMENT_REQUEST_RESULT_OK) { |
| + engine_endpoint_ = assignment.engine_endpoint; |
| + } |
| +} |
| + |
| +base::WeakPtr<ConnectionStatus> ConnectionStatus::GetWeakPtr() { |
| + return weak_factory_.GetWeakPtr(); |
| +} |
| + |
| +void ConnectionStatus::OnConnected() { |
| + is_connected_ = true; |
| + FOR_EACH_OBSERVER(NetworkEventObserver, connection_observers_, OnConnected()); |
| +} |
| + |
| +void ConnectionStatus::OnDisconnected(int result) { |
| + is_connected_ = false; |
| + FOR_EACH_OBSERVER(NetworkEventObserver, connection_observers_, |
| + OnDisconnected(result)); |
| +} |
| + |
| +} // namespace client |
| +} // namespace blimp |