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

Side by Side Diff: extensions/browser/api/bluetooth/bluetooth_private_api.cc

Issue 1902873002: Convert //extensions/browser/api from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 "extensions/browser/api/bluetooth/bluetooth_private_api.h" 5 #include "extensions/browser/api/bluetooth/bluetooth_private_api.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 //////////////////////////////////////////////////////////////////////////////// 135 ////////////////////////////////////////////////////////////////////////////////
136 136
137 BluetoothPrivateSetAdapterStateFunction:: 137 BluetoothPrivateSetAdapterStateFunction::
138 BluetoothPrivateSetAdapterStateFunction() {} 138 BluetoothPrivateSetAdapterStateFunction() {}
139 139
140 BluetoothPrivateSetAdapterStateFunction:: 140 BluetoothPrivateSetAdapterStateFunction::
141 ~BluetoothPrivateSetAdapterStateFunction() {} 141 ~BluetoothPrivateSetAdapterStateFunction() {}
142 142
143 bool BluetoothPrivateSetAdapterStateFunction::DoWork( 143 bool BluetoothPrivateSetAdapterStateFunction::DoWork(
144 scoped_refptr<device::BluetoothAdapter> adapter) { 144 scoped_refptr<device::BluetoothAdapter> adapter) {
145 scoped_ptr<bt_private::SetAdapterState::Params> params( 145 std::unique_ptr<bt_private::SetAdapterState::Params> params(
146 bt_private::SetAdapterState::Params::Create(*args_)); 146 bt_private::SetAdapterState::Params::Create(*args_));
147 EXTENSION_FUNCTION_VALIDATE(params.get()); 147 EXTENSION_FUNCTION_VALIDATE(params.get());
148 148
149 if (!adapter->IsPresent()) { 149 if (!adapter->IsPresent()) {
150 SetError(kAdapterNotPresent); 150 SetError(kAdapterNotPresent);
151 SendResponse(false); 151 SendResponse(false);
152 return true; 152 return true;
153 } 153 }
154 154
155 const bt_private::NewAdapterState& new_state = params->adapter_state; 155 const bt_private::NewAdapterState& new_state = params->adapter_state;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 //////////////////////////////////////////////////////////////////////////////// 243 ////////////////////////////////////////////////////////////////////////////////
244 244
245 BluetoothPrivateSetPairingResponseFunction:: 245 BluetoothPrivateSetPairingResponseFunction::
246 BluetoothPrivateSetPairingResponseFunction() {} 246 BluetoothPrivateSetPairingResponseFunction() {}
247 247
248 BluetoothPrivateSetPairingResponseFunction:: 248 BluetoothPrivateSetPairingResponseFunction::
249 ~BluetoothPrivateSetPairingResponseFunction() {} 249 ~BluetoothPrivateSetPairingResponseFunction() {}
250 250
251 bool BluetoothPrivateSetPairingResponseFunction::DoWork( 251 bool BluetoothPrivateSetPairingResponseFunction::DoWork(
252 scoped_refptr<device::BluetoothAdapter> adapter) { 252 scoped_refptr<device::BluetoothAdapter> adapter) {
253 scoped_ptr<bt_private::SetPairingResponse::Params> params( 253 std::unique_ptr<bt_private::SetPairingResponse::Params> params(
254 bt_private::SetPairingResponse::Params::Create(*args_)); 254 bt_private::SetPairingResponse::Params::Create(*args_));
255 EXTENSION_FUNCTION_VALIDATE(params.get()); 255 EXTENSION_FUNCTION_VALIDATE(params.get());
256 const bt_private::SetPairingResponseOptions& options = params->options; 256 const bt_private::SetPairingResponseOptions& options = params->options;
257 257
258 BluetoothEventRouter* router = 258 BluetoothEventRouter* router =
259 BluetoothAPI::Get(browser_context())->event_router(); 259 BluetoothAPI::Get(browser_context())->event_router();
260 if (!router->GetPairingDelegate(GetExtensionId())) { 260 if (!router->GetPairingDelegate(GetExtensionId())) {
261 SetError(kPairingNotEnabled); 261 SetError(kPairingNotEnabled);
262 SendResponse(false); 262 SendResponse(false);
263 return true; 263 return true;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 //////////////////////////////////////////////////////////////////////////////// 304 ////////////////////////////////////////////////////////////////////////////////
305 305
306 BluetoothPrivateDisconnectAllFunction::BluetoothPrivateDisconnectAllFunction() { 306 BluetoothPrivateDisconnectAllFunction::BluetoothPrivateDisconnectAllFunction() {
307 } 307 }
308 308
309 BluetoothPrivateDisconnectAllFunction:: 309 BluetoothPrivateDisconnectAllFunction::
310 ~BluetoothPrivateDisconnectAllFunction() {} 310 ~BluetoothPrivateDisconnectAllFunction() {}
311 311
312 bool BluetoothPrivateDisconnectAllFunction::DoWork( 312 bool BluetoothPrivateDisconnectAllFunction::DoWork(
313 scoped_refptr<device::BluetoothAdapter> adapter) { 313 scoped_refptr<device::BluetoothAdapter> adapter) {
314 scoped_ptr<bt_private::DisconnectAll::Params> params( 314 std::unique_ptr<bt_private::DisconnectAll::Params> params(
315 bt_private::DisconnectAll::Params::Create(*args_)); 315 bt_private::DisconnectAll::Params::Create(*args_));
316 EXTENSION_FUNCTION_VALIDATE(params.get()); 316 EXTENSION_FUNCTION_VALIDATE(params.get());
317 317
318 device::BluetoothDevice* device = adapter->GetDevice(params->device_address); 318 device::BluetoothDevice* device = adapter->GetDevice(params->device_address);
319 if (!device) { 319 if (!device) {
320 SetError(kDeviceNotFoundError); 320 SetError(kDeviceNotFoundError);
321 SendResponse(false); 321 SendResponse(false);
322 return true; 322 return true;
323 } 323 }
324 324
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 } 357 }
358 358
359 //////////////////////////////////////////////////////////////////////////////// 359 ////////////////////////////////////////////////////////////////////////////////
360 360
361 BluetoothPrivateForgetDeviceFunction::BluetoothPrivateForgetDeviceFunction() {} 361 BluetoothPrivateForgetDeviceFunction::BluetoothPrivateForgetDeviceFunction() {}
362 362
363 BluetoothPrivateForgetDeviceFunction::~BluetoothPrivateForgetDeviceFunction() {} 363 BluetoothPrivateForgetDeviceFunction::~BluetoothPrivateForgetDeviceFunction() {}
364 364
365 bool BluetoothPrivateForgetDeviceFunction::DoWork( 365 bool BluetoothPrivateForgetDeviceFunction::DoWork(
366 scoped_refptr<device::BluetoothAdapter> adapter) { 366 scoped_refptr<device::BluetoothAdapter> adapter) {
367 scoped_ptr<bt_private::ForgetDevice::Params> params( 367 std::unique_ptr<bt_private::ForgetDevice::Params> params(
368 bt_private::ForgetDevice::Params::Create(*args_)); 368 bt_private::ForgetDevice::Params::Create(*args_));
369 EXTENSION_FUNCTION_VALIDATE(params.get()); 369 EXTENSION_FUNCTION_VALIDATE(params.get());
370 370
371 device::BluetoothDevice* device = adapter->GetDevice(params->device_address); 371 device::BluetoothDevice* device = adapter->GetDevice(params->device_address);
372 if (!device) { 372 if (!device) {
373 SetError(kDeviceNotFoundError); 373 SetError(kDeviceNotFoundError);
374 SendResponse(false); 374 SendResponse(false);
375 return true; 375 return true;
376 } 376 }
377 377
(...skipping 14 matching lines...) Expand all
392 scoped_refptr<device::BluetoothAdapter> adapter, 392 scoped_refptr<device::BluetoothAdapter> adapter,
393 const std::string& device_address) { 393 const std::string& device_address) {
394 SetError(kForgetDeviceError); 394 SetError(kForgetDeviceError);
395 SendResponse(false); 395 SendResponse(false);
396 } 396 }
397 397
398 //////////////////////////////////////////////////////////////////////////////// 398 ////////////////////////////////////////////////////////////////////////////////
399 399
400 bool BluetoothPrivateSetDiscoveryFilterFunction::DoWork( 400 bool BluetoothPrivateSetDiscoveryFilterFunction::DoWork(
401 scoped_refptr<device::BluetoothAdapter> adapter) { 401 scoped_refptr<device::BluetoothAdapter> adapter) {
402 scoped_ptr<SetDiscoveryFilter::Params> params( 402 std::unique_ptr<SetDiscoveryFilter::Params> params(
403 SetDiscoveryFilter::Params::Create(*args_)); 403 SetDiscoveryFilter::Params::Create(*args_));
404 auto& df_param = params->discovery_filter; 404 auto& df_param = params->discovery_filter;
405 405
406 scoped_ptr<device::BluetoothDiscoveryFilter> discovery_filter; 406 std::unique_ptr<device::BluetoothDiscoveryFilter> discovery_filter;
407 407
408 // If all filter fields are empty, we are clearing filter. If any field is 408 // If all filter fields are empty, we are clearing filter. If any field is
409 // set, then create proper filter. 409 // set, then create proper filter.
410 if (df_param.uuids.get() || df_param.rssi.get() || df_param.pathloss.get() || 410 if (df_param.uuids.get() || df_param.rssi.get() || df_param.pathloss.get() ||
411 df_param.transport != bt_private::TransportType::TRANSPORT_TYPE_NONE) { 411 df_param.transport != bt_private::TransportType::TRANSPORT_TYPE_NONE) {
412 uint8_t transport; 412 uint8_t transport;
413 413
414 switch (df_param.transport) { 414 switch (df_param.transport) {
415 case bt_private::TransportType::TRANSPORT_TYPE_LE: 415 case bt_private::TransportType::TRANSPORT_TYPE_LE:
416 transport = device::BluetoothDiscoveryFilter::Transport::TRANSPORT_LE; 416 transport = device::BluetoothDiscoveryFilter::Transport::TRANSPORT_LE;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 } 468 }
469 469
470 //////////////////////////////////////////////////////////////////////////////// 470 ////////////////////////////////////////////////////////////////////////////////
471 471
472 BluetoothPrivateConnectFunction::BluetoothPrivateConnectFunction() {} 472 BluetoothPrivateConnectFunction::BluetoothPrivateConnectFunction() {}
473 473
474 BluetoothPrivateConnectFunction::~BluetoothPrivateConnectFunction() {} 474 BluetoothPrivateConnectFunction::~BluetoothPrivateConnectFunction() {}
475 475
476 bool BluetoothPrivateConnectFunction::DoWork( 476 bool BluetoothPrivateConnectFunction::DoWork(
477 scoped_refptr<device::BluetoothAdapter> adapter) { 477 scoped_refptr<device::BluetoothAdapter> adapter) {
478 scoped_ptr<bt_private::Connect::Params> params( 478 std::unique_ptr<bt_private::Connect::Params> params(
479 bt_private::Connect::Params::Create(*args_)); 479 bt_private::Connect::Params::Create(*args_));
480 EXTENSION_FUNCTION_VALIDATE(params.get()); 480 EXTENSION_FUNCTION_VALIDATE(params.get());
481 481
482 device::BluetoothDevice* device = adapter->GetDevice(params->device_address); 482 device::BluetoothDevice* device = adapter->GetDevice(params->device_address);
483 if (!device) { 483 if (!device) {
484 SetError(kDeviceNotFoundError); 484 SetError(kDeviceNotFoundError);
485 SendResponse(false); 485 SendResponse(false);
486 return true; 486 return true;
487 } 487 }
488 488
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 } 570 }
571 571
572 //////////////////////////////////////////////////////////////////////////////// 572 ////////////////////////////////////////////////////////////////////////////////
573 573
574 BluetoothPrivatePairFunction::BluetoothPrivatePairFunction() {} 574 BluetoothPrivatePairFunction::BluetoothPrivatePairFunction() {}
575 575
576 BluetoothPrivatePairFunction::~BluetoothPrivatePairFunction() {} 576 BluetoothPrivatePairFunction::~BluetoothPrivatePairFunction() {}
577 577
578 bool BluetoothPrivatePairFunction::DoWork( 578 bool BluetoothPrivatePairFunction::DoWork(
579 scoped_refptr<device::BluetoothAdapter> adapter) { 579 scoped_refptr<device::BluetoothAdapter> adapter) {
580 scoped_ptr<bt_private::Pair::Params> params( 580 std::unique_ptr<bt_private::Pair::Params> params(
581 bt_private::Pair::Params::Create(*args_)); 581 bt_private::Pair::Params::Create(*args_));
582 EXTENSION_FUNCTION_VALIDATE(params.get()); 582 EXTENSION_FUNCTION_VALIDATE(params.get());
583 583
584 device::BluetoothDevice* device = adapter->GetDevice(params->device_address); 584 device::BluetoothDevice* device = adapter->GetDevice(params->device_address);
585 if (!device) { 585 if (!device) {
586 SetError(kDeviceNotFoundError); 586 SetError(kDeviceNotFoundError);
587 SendResponse(false); 587 SendResponse(false);
588 return true; 588 return true;
589 } 589 }
590 590
(...skipping 25 matching lines...) Expand all
616 device::BluetoothDevice::ConnectErrorCode error) { 616 device::BluetoothDevice::ConnectErrorCode error) {
617 SetError(kPairingFailed); 617 SetError(kPairingFailed);
618 SendResponse(false); 618 SendResponse(false);
619 } 619 }
620 620
621 //////////////////////////////////////////////////////////////////////////////// 621 ////////////////////////////////////////////////////////////////////////////////
622 622
623 } // namespace api 623 } // namespace api
624 624
625 } // namespace extensions 625 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698