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

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

Issue 2322843002: Propagate connection info to Blimp android UI. (Closed)
Patch Set: git cl format.... 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()
11 : is_connected_(false), weak_factory_(this) {}
12 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.
13
14 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.
15 return engine_endpoint_;
16 }
17
18 bool ConnectionStatus::IsConnected() const {
19 return is_connected_;
20 }
21
22 void ConnectionStatus::AddObserver(NetworkEventObserver* observer) {
23 connection_observers_.AddObserver(observer);
24 }
25
26 void ConnectionStatus::RemoveObserver(NetworkEventObserver* observer) {
27 connection_observers_.RemoveObserver(observer);
28 }
29
30 void ConnectionStatus::OnAssignmentResult(int result,
31 const Assignment& assignment) {
32 if (result == AssignmentRequestResult::ASSIGNMENT_REQUEST_RESULT_OK) {
33 engine_endpoint_ = assignment.engine_endpoint;
34 }
35 }
36
37 base::WeakPtr<ConnectionStatus> ConnectionStatus::GetWeakPtr() {
38 return weak_factory_.GetWeakPtr();
39 }
40
41 void ConnectionStatus::OnConnected() {
42 is_connected_ = true;
43 FOR_EACH_OBSERVER(NetworkEventObserver, connection_observers_, OnConnected());
44 }
45
46 void ConnectionStatus::OnDisconnected(int result) {
47 is_connected_ = false;
48 FOR_EACH_OBSERVER(NetworkEventObserver, connection_observers_,
49 OnDisconnected(result));
50 }
51
52 } // namespace client
53 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698