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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..95393201a9842f51f007d4c56c76faaa52151349
--- /dev/null
+++ b/blimp/client/core/session/connection_status.cc
@@ -0,0 +1,50 @@
+// 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"
+
+#include "base/metrics/histogram_macros.h"
+
+namespace blimp {
+namespace client {
+
+ConnectionStatus::ConnectionStatus()
+ : is_connected_(false), weak_factory_(this) {}
+
+ConnectionStatus::~ConnectionStatus() = default;
+
+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;
+ UMA_HISTOGRAM_BOOLEAN("Blimp.Connected", true);
+ FOR_EACH_OBSERVER(NetworkEventObserver, connection_observers_, OnConnected());
+}
+
+void ConnectionStatus::OnDisconnected(int result) {
+ is_connected_ = false;
+ UMA_HISTOGRAM_BOOLEAN("Blimp.Connected", false);
+ FOR_EACH_OBSERVER(NetworkEventObserver, connection_observers_,
+ OnDisconnected(result));
+}
+
+} // namespace client
+} // namespace blimp
« 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