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

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

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

Powered by Google App Engine
This is Rietveld 408576698