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

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

Issue 2231753002: components: Use stl utilities from the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: One more call site Created 4 years, 4 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 | « components/prefs/pref_registry.cc ('k') | components/query_parser/query_parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_throttler_impl.h" 5 #include "components/proximity_auth/bluetooth_throttler_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/time/tick_clock.h" 10 #include "base/time/tick_clock.h"
(...skipping 24 matching lines...) Expand all
35 base::TimeTicks now = clock_->NowTicks(); 35 base::TimeTicks now = clock_->NowTicks();
36 base::TimeTicks throttled_start_time = 36 base::TimeTicks throttled_start_time =
37 last_disconnect_time_ + GetCooldownTimeDelta(); 37 last_disconnect_time_ + GetCooldownTimeDelta();
38 if (now >= throttled_start_time) 38 if (now >= throttled_start_time)
39 return base::TimeDelta(); 39 return base::TimeDelta();
40 40
41 return throttled_start_time - now; 41 return throttled_start_time - now;
42 } 42 }
43 43
44 void BluetoothThrottlerImpl::OnConnection(Connection* connection) { 44 void BluetoothThrottlerImpl::OnConnection(Connection* connection) {
45 DCHECK(!ContainsKey(connections_, connection)); 45 DCHECK(!base::ContainsKey(connections_, connection));
46 connections_.insert(connection); 46 connections_.insert(connection);
47 connection->AddObserver(this); 47 connection->AddObserver(this);
48 } 48 }
49 49
50 base::TimeDelta BluetoothThrottlerImpl::GetCooldownTimeDelta() const { 50 base::TimeDelta BluetoothThrottlerImpl::GetCooldownTimeDelta() const {
51 return base::TimeDelta::FromSeconds(kCooldownTimeSecs); 51 return base::TimeDelta::FromSeconds(kCooldownTimeSecs);
52 } 52 }
53 53
54 void BluetoothThrottlerImpl::OnConnectionStatusChanged( 54 void BluetoothThrottlerImpl::OnConnectionStatusChanged(
55 Connection* connection, 55 Connection* connection,
56 Connection::Status old_status, 56 Connection::Status old_status,
57 Connection::Status new_status) { 57 Connection::Status new_status) {
58 DCHECK(ContainsKey(connections_, connection)); 58 DCHECK(base::ContainsKey(connections_, connection));
59 if (new_status == Connection::DISCONNECTED) { 59 if (new_status == Connection::DISCONNECTED) {
60 last_disconnect_time_ = clock_->NowTicks(); 60 last_disconnect_time_ = clock_->NowTicks();
61 connection->RemoveObserver(this); 61 connection->RemoveObserver(this);
62 connections_.erase(connection); 62 connections_.erase(connection);
63 } 63 }
64 } 64 }
65 65
66 } // namespace proximity_auth 66 } // namespace proximity_auth
OLDNEW
« no previous file with comments | « components/prefs/pref_registry.cc ('k') | components/query_parser/query_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698