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

Side by Side Diff: blimp/client/core/session/connection_status.cc

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 unified diff | Download patch
OLDNEW
(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 #include "blimp/client/core/session/connection_status.h"
6
7 namespace blimp {
8 namespace client {
9
10 ConnectionStatus::ConnectionStatus() : is_connected_(false) {}
11 ConnectionStatus::~ConnectionStatus() = default;
12
13 bool ConnectionStatus::IsValid() const {
14 return !engine_endpoint_.address().empty() && engine_endpoint_.port() != 0;
15 }
16
17 const net::IPEndPoint& ConnectionStatus::GetIpEndPoint() {
18 return engine_endpoint_;
19 }
20
21 bool ConnectionStatus::IsConnected() const {
22 return is_connected_;
23 }
24
25 void ConnectionStatus::AddObserver(NetworkEventObserver* observer) {
26 connection_observers_.AddObserver(observer);
27 }
28
29 void ConnectionStatus::RemoveObserver(NetworkEventObserver* observer) {
30 connection_observers_.RemoveObserver(observer);
31 }
32
33 void ConnectionStatus::onAssignmentResult(int result,
34 const Assignment& assignment) {
35 if (result == AssignmentRequestResult::ASSIGNMENT_REQUEST_RESULT_OK) {
36 engine_endpoint_ = assignment.engine_endpoint;
37 }
38 }
39
40 void ConnectionStatus::OnConnected() {
41 is_connected_ = true;
42 FOR_EACH_OBSERVER(NetworkEventObserver, connection_observers_, OnConnected());
43 }
44
45 void ConnectionStatus::OnDisconnected(int result) {
46 is_connected_ = false;
47 FOR_EACH_OBSERVER(NetworkEventObserver, connection_observers_,
48 OnDisconnected(result));
49 }
50
51 } // namespace client
52 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698