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

Side by Side Diff: device/bluetooth/bluetooth_remote_gatt_service_android.cc

Issue 2606823002: Remove base::ScopedPtrHashMap from device/. (Closed)
Patch Set: one last fix Created 3 years, 11 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 "device/bluetooth/bluetooth_remote_gatt_service_android.h" 5 #include "device/bluetooth/bluetooth_remote_gatt_service_android.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_string.h" 10 #include "base/android/jni_string.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 128
129 device::BluetoothDevice* BluetoothRemoteGattServiceAndroid::GetDevice() const { 129 device::BluetoothDevice* BluetoothRemoteGattServiceAndroid::GetDevice() const {
130 return device_; 130 return device_;
131 } 131 }
132 132
133 std::vector<device::BluetoothRemoteGattCharacteristic*> 133 std::vector<device::BluetoothRemoteGattCharacteristic*>
134 BluetoothRemoteGattServiceAndroid::GetCharacteristics() const { 134 BluetoothRemoteGattServiceAndroid::GetCharacteristics() const {
135 EnsureCharacteristicsCreated(); 135 EnsureCharacteristicsCreated();
136 std::vector<device::BluetoothRemoteGattCharacteristic*> characteristics; 136 std::vector<device::BluetoothRemoteGattCharacteristic*> characteristics;
137 for (const auto& map_iter : characteristics_) 137 for (const auto& map_iter : characteristics_)
138 characteristics.push_back(map_iter.second); 138 characteristics.push_back(map_iter.second.get());
139 return characteristics; 139 return characteristics;
140 } 140 }
141 141
142 std::vector<device::BluetoothRemoteGattService*> 142 std::vector<device::BluetoothRemoteGattService*>
143 BluetoothRemoteGattServiceAndroid::GetIncludedServices() const { 143 BluetoothRemoteGattServiceAndroid::GetIncludedServices() const {
144 NOTIMPLEMENTED(); 144 NOTIMPLEMENTED();
145 return std::vector<device::BluetoothRemoteGattService*>(); 145 return std::vector<device::BluetoothRemoteGattService*>();
146 } 146 }
147 147
148 device::BluetoothRemoteGattCharacteristic* 148 device::BluetoothRemoteGattCharacteristic*
149 BluetoothRemoteGattServiceAndroid::GetCharacteristic( 149 BluetoothRemoteGattServiceAndroid::GetCharacteristic(
150 const std::string& identifier) const { 150 const std::string& identifier) const {
151 EnsureCharacteristicsCreated(); 151 EnsureCharacteristicsCreated();
152 const auto& iter = characteristics_.find(identifier); 152 const auto& iter = characteristics_.find(identifier);
153 if (iter == characteristics_.end()) 153 if (iter == characteristics_.end())
154 return nullptr; 154 return nullptr;
155 return iter->second; 155 return iter->second.get();
156 } 156 }
157 157
158 void BluetoothRemoteGattServiceAndroid::CreateGattRemoteCharacteristic( 158 void BluetoothRemoteGattServiceAndroid::CreateGattRemoteCharacteristic(
159 JNIEnv* env, 159 JNIEnv* env,
160 const JavaParamRef<jobject>& caller, 160 const JavaParamRef<jobject>& caller,
161 const JavaParamRef<jstring>& instance_id, 161 const JavaParamRef<jstring>& instance_id,
162 const JavaParamRef<jobject>& /* BluetoothGattCharacteristicWrapper */ 162 const JavaParamRef<jobject>& /* BluetoothGattCharacteristicWrapper */
163 bluetooth_gatt_characteristic_wrapper, 163 bluetooth_gatt_characteristic_wrapper,
164 const JavaParamRef< 164 const JavaParamRef<
165 jobject>& /* ChromeBluetoothDevice */ chrome_bluetooth_device) { 165 jobject>& /* ChromeBluetoothDevice */ chrome_bluetooth_device) {
166 std::string instance_id_string = 166 std::string instance_id_string =
167 base::android::ConvertJavaStringToUTF8(env, instance_id); 167 base::android::ConvertJavaStringToUTF8(env, instance_id);
168 168
169 DCHECK(!characteristics_.contains(instance_id_string)); 169 DCHECK(characteristics_.find(instance_id_string) == characteristics_.end());
Reilly Grant (use Gerrit) 2016/12/28 22:48:01 !base::ContainsKey
Avi (use Gerrit) 2017/01/02 19:42:26 Done.
170 170
171 characteristics_.set( 171 characteristics_[instance_id_string] =
172 instance_id_string,
173 BluetoothRemoteGattCharacteristicAndroid::Create( 172 BluetoothRemoteGattCharacteristicAndroid::Create(
174 adapter_, this, instance_id_string, 173 adapter_, this, instance_id_string,
175 bluetooth_gatt_characteristic_wrapper, chrome_bluetooth_device)); 174 bluetooth_gatt_characteristic_wrapper, chrome_bluetooth_device);
176 } 175 }
177 176
178 BluetoothRemoteGattServiceAndroid::BluetoothRemoteGattServiceAndroid( 177 BluetoothRemoteGattServiceAndroid::BluetoothRemoteGattServiceAndroid(
179 BluetoothAdapterAndroid* adapter, 178 BluetoothAdapterAndroid* adapter,
180 BluetoothDeviceAndroid* device, 179 BluetoothDeviceAndroid* device,
181 const std::string& instance_id) 180 const std::string& instance_id)
182 : adapter_(adapter), device_(device), instance_id_(instance_id) {} 181 : adapter_(adapter), device_(device), instance_id_(instance_id) {}
183 182
184 void BluetoothRemoteGattServiceAndroid::EnsureCharacteristicsCreated() const { 183 void BluetoothRemoteGattServiceAndroid::EnsureCharacteristicsCreated() const {
185 if (!characteristics_.empty()) 184 if (!characteristics_.empty())
186 return; 185 return;
187 186
188 // Java call 187 // Java call
189 Java_ChromeBluetoothRemoteGattService_createCharacteristics( 188 Java_ChromeBluetoothRemoteGattService_createCharacteristics(
190 AttachCurrentThread(), j_service_); 189 AttachCurrentThread(), j_service_);
191 } 190 }
192 191
193 } // namespace device 192 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698