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

Side by Side Diff: components/proximity_auth/bluetooth_connection_finder.cc

Issue 663693002: [Easy Unlock] Port the BluetoothThrottler class to native code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Windows compilation error, take 2 Created 5 years, 8 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
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
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
OLDNEW
« no previous file with comments | « components/proximity_auth/bluetooth_connection_finder.h ('k') | components/proximity_auth/bluetooth_throttler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698