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

Side by Side Diff: device/bluetooth/test/mock_bluetooth_device.cc

Issue 2567903004: Replace ScopedVector/ScopedPtrHashMap with std::vector and std::unordered_map (Closed)
Patch Set: Mac bustage Created 3 years, 12 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "device/bluetooth/test/mock_bluetooth_device.h" 5 #include "device/bluetooth/test/mock_bluetooth_device.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 MockBluetoothDevice::~MockBluetoothDevice() {} 66 MockBluetoothDevice::~MockBluetoothDevice() {}
67 67
68 void MockBluetoothDevice::AddMockService( 68 void MockBluetoothDevice::AddMockService(
69 std::unique_ptr<MockBluetoothGattService> mock_service) { 69 std::unique_ptr<MockBluetoothGattService> mock_service) {
70 mock_services_.push_back(std::move(mock_service)); 70 mock_services_.push_back(std::move(mock_service));
71 } 71 }
72 72
73 std::vector<BluetoothRemoteGattService*> MockBluetoothDevice::GetMockServices() 73 std::vector<BluetoothRemoteGattService*> MockBluetoothDevice::GetMockServices()
74 const { 74 const {
75 std::vector<BluetoothRemoteGattService*> services; 75 std::vector<BluetoothRemoteGattService*> services;
76 for (BluetoothRemoteGattService* service : mock_services_) { 76 for (const auto& service : mock_services_) {
77 services.push_back(service); 77 services.push_back(service.get());
78 } 78 }
79 return services; 79 return services;
80 } 80 }
81 81
82 BluetoothRemoteGattService* MockBluetoothDevice::GetMockService( 82 BluetoothRemoteGattService* MockBluetoothDevice::GetMockService(
83 const std::string& identifier) const { 83 const std::string& identifier) const {
84 for (BluetoothRemoteGattService* service : mock_services_) { 84 for (const auto& service : mock_services_) {
85 if (service->GetIdentifier() == identifier) 85 if (service->GetIdentifier() == identifier)
86 return service; 86 return service.get();
87 } 87 }
88 return nullptr; 88 return nullptr;
89 } 89 }
90 90
91 void MockBluetoothDevice::PushPendingCallback(const base::Closure& callback) { 91 void MockBluetoothDevice::PushPendingCallback(const base::Closure& callback) {
92 pending_callbacks_.push(callback); 92 pending_callbacks_.push(callback);
93 } 93 }
94 94
95 void MockBluetoothDevice::RunPendingCallbacks() { 95 void MockBluetoothDevice::RunPendingCallbacks() {
96 while (!pending_callbacks_.empty()) { 96 while (!pending_callbacks_.empty()) {
97 pending_callbacks_.front().Run(); 97 pending_callbacks_.front().Run();
98 pending_callbacks_.pop(); 98 pending_callbacks_.pop();
99 } 99 }
100 } 100 }
101 101
102 } // namespace device 102 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698