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

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

Issue 2322843002: Propagate connection info to Blimp android UI. (Closed)
Patch Set: Merge conflicts. 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
« no previous file with comments | « blimp/client/core/session/connection_status.h ('k') | blimp/client/core/settings/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "base/metrics/histogram_macros.h"
8
9 namespace blimp {
10 namespace client {
11
12 ConnectionStatus::ConnectionStatus()
13 : is_connected_(false), weak_factory_(this) {}
14
15 ConnectionStatus::~ConnectionStatus() = default;
16
17 void ConnectionStatus::AddObserver(NetworkEventObserver* observer) {
18 connection_observers_.AddObserver(observer);
19 }
20
21 void ConnectionStatus::RemoveObserver(NetworkEventObserver* observer) {
22 connection_observers_.RemoveObserver(observer);
23 }
24
25 void ConnectionStatus::OnAssignmentResult(int result,
26 const Assignment& assignment) {
27 if (result == AssignmentRequestResult::ASSIGNMENT_REQUEST_RESULT_OK) {
28 engine_endpoint_ = assignment.engine_endpoint;
29 }
30 }
31
32 base::WeakPtr<ConnectionStatus> ConnectionStatus::GetWeakPtr() {
33 return weak_factory_.GetWeakPtr();
34 }
35
36 void ConnectionStatus::OnConnected() {
37 is_connected_ = true;
38 UMA_HISTOGRAM_BOOLEAN("Blimp.Connected", true);
39 FOR_EACH_OBSERVER(NetworkEventObserver, connection_observers_, OnConnected());
40 }
41
42 void ConnectionStatus::OnDisconnected(int result) {
43 is_connected_ = false;
44 UMA_HISTOGRAM_BOOLEAN("Blimp.Connected", false);
45 FOR_EACH_OBSERVER(NetworkEventObserver, connection_observers_,
46 OnDisconnected(result));
47 }
48
49 } // namespace client
50 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/client/core/session/connection_status.h ('k') | blimp/client/core/settings/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698