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

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

Issue 2851173004: Eliminate bind callback that doesn't take a BindSourceInfo parameter. (Closed)
Patch Set: . Created 3 years, 7 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 | « device/bluetooth/adapter_factory.h ('k') | device/bluetooth/test/fake_bluetooth.h » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <utility> 5 #include <utility>
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "device/bluetooth/adapter.h" 8 #include "device/bluetooth/adapter.h"
9 #include "device/bluetooth/adapter_factory.h" 9 #include "device/bluetooth/adapter_factory.h"
10 #include "device/bluetooth/bluetooth_adapter_factory.h" 10 #include "device/bluetooth/bluetooth_adapter_factory.h"
11 #include "mojo/public/cpp/bindings/strong_binding.h" 11 #include "mojo/public/cpp/bindings/strong_binding.h"
12 12
13 namespace bluetooth { 13 namespace bluetooth {
14 14
15 AdapterFactory::AdapterFactory() : weak_ptr_factory_(this) {} 15 AdapterFactory::AdapterFactory() : weak_ptr_factory_(this) {}
16 AdapterFactory::~AdapterFactory() {} 16 AdapterFactory::~AdapterFactory() {}
17 17
18 // static 18 // static
19 void AdapterFactory::Create(mojom::AdapterFactoryRequest request) { 19 void AdapterFactory::Create(const service_manager::BindSourceInfo& source_info,
20 mojom::AdapterFactoryRequest request) {
20 mojo::MakeStrongBinding(base::MakeUnique<AdapterFactory>(), 21 mojo::MakeStrongBinding(base::MakeUnique<AdapterFactory>(),
21 std::move(request)); 22 std::move(request));
22 } 23 }
23 24
24 void AdapterFactory::GetAdapter(const GetAdapterCallback& callback) { 25 void AdapterFactory::GetAdapter(const GetAdapterCallback& callback) {
25 if (device::BluetoothAdapterFactory::IsBluetoothSupported()) { 26 if (device::BluetoothAdapterFactory::IsBluetoothSupported()) {
26 device::BluetoothAdapterFactory::GetAdapter( 27 device::BluetoothAdapterFactory::GetAdapter(
27 base::Bind(&AdapterFactory::OnGetAdapter, 28 base::Bind(&AdapterFactory::OnGetAdapter,
28 weak_ptr_factory_.GetWeakPtr(), callback)); 29 weak_ptr_factory_.GetWeakPtr(), callback));
29 } else { 30 } else {
30 callback.Run(nullptr /* AdapterPtr */); 31 callback.Run(nullptr /* AdapterPtr */);
31 } 32 }
32 } 33 }
33 34
34 void AdapterFactory::OnGetAdapter( 35 void AdapterFactory::OnGetAdapter(
35 const GetAdapterCallback& callback, 36 const GetAdapterCallback& callback,
36 scoped_refptr<device::BluetoothAdapter> adapter) { 37 scoped_refptr<device::BluetoothAdapter> adapter) {
37 mojom::AdapterPtr adapter_ptr; 38 mojom::AdapterPtr adapter_ptr;
38 mojo::MakeStrongBinding(base::MakeUnique<Adapter>(adapter), 39 mojo::MakeStrongBinding(base::MakeUnique<Adapter>(adapter),
39 mojo::MakeRequest(&adapter_ptr)); 40 mojo::MakeRequest(&adapter_ptr));
40 callback.Run(std::move(adapter_ptr)); 41 callback.Run(std::move(adapter_ptr));
41 } 42 }
42 43
43 } // namespace bluetooth 44 } // namespace bluetooth
OLDNEW
« no previous file with comments | « device/bluetooth/adapter_factory.h ('k') | device/bluetooth/test/fake_bluetooth.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698