OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/proximity_auth/bluetooth_connection_finder.h" | 5 #include "components/proximity_auth/bluetooth_connection_finder.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 bool present) { | 112 bool present) { |
113 PollIfReady(); | 113 PollIfReady(); |
114 } | 114 } |
115 | 115 |
116 void BluetoothConnectionFinder::AdapterPoweredChanged(BluetoothAdapter* adapter, | 116 void BluetoothConnectionFinder::AdapterPoweredChanged(BluetoothAdapter* adapter, |
117 bool powered) { | 117 bool powered) { |
118 PollIfReady(); | 118 PollIfReady(); |
119 } | 119 } |
120 | 120 |
121 void BluetoothConnectionFinder::OnConnectionStatusChanged( | 121 void BluetoothConnectionFinder::OnConnectionStatusChanged( |
122 const Connection& connection, | 122 Connection* connection, |
123 Connection::Status old_status, | 123 Connection::Status old_status, |
124 Connection::Status new_status) { | 124 Connection::Status new_status) { |
125 DCHECK_EQ(&connection, connection_.get()); | 125 DCHECK_EQ(connection, connection_.get()); |
126 | 126 |
127 if (connection_->IsConnected()) { | 127 if (connection_->IsConnected()) { |
128 base::TimeDelta elapsed = base::TimeTicks::Now() - start_time_; | 128 base::TimeDelta elapsed = base::TimeTicks::Now() - start_time_; |
129 VLOG(1) << "[BCF] Connection found! Elapsed Time: " | 129 VLOG(1) << "[BCF] Connection found! Elapsed Time: " |
130 << elapsed.InMilliseconds() << "ms."; | 130 << elapsed.InMilliseconds() << "ms."; |
131 UnregisterAsObserver(); | 131 UnregisterAsObserver(); |
132 connection_callback_.Run(connection_.Pass()); | 132 connection_callback_.Run(connection_.Pass()); |
133 } else if (old_status == Connection::IN_PROGRESS) { | 133 } else if (old_status == Connection::IN_PROGRESS) { |
134 VLOG(1) << "[BCF] Connection failed! Scheduling another polling iteration."; | 134 VLOG(1) << "[BCF] Connection failed! Scheduling another polling iteration."; |
135 connection_.reset(); | 135 connection_.reset(); |
136 has_delayed_poll_scheduled_ = true; | 136 has_delayed_poll_scheduled_ = true; |
137 base::MessageLoopProxy::current()->PostDelayedTask( | 137 base::MessageLoopProxy::current()->PostDelayedTask( |
138 FROM_HERE, | 138 FROM_HERE, |
139 base::Bind(&BluetoothConnectionFinder::DelayedPollIfReady, | 139 base::Bind(&BluetoothConnectionFinder::DelayedPollIfReady, |
140 weak_ptr_factory_.GetWeakPtr()), | 140 weak_ptr_factory_.GetWeakPtr()), |
141 polling_interval_); | 141 polling_interval_); |
142 } | 142 } |
143 } | 143 } |
144 | 144 |
145 } // namespace proximity_auth | 145 } // namespace proximity_auth |
OLD | NEW |