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

Side by Side Diff: chromeos/dbus/fake_bluetooth_profile_manager_client.cc

Issue 982593002: Fix BluetoothAdapterProfileChromeOS lifecycle management (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address nits, remove test debug logging Created 5 years, 9 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "chromeos/dbus/fake_bluetooth_profile_manager_client.h" 5 #include "chromeos/dbus/fake_bluetooth_profile_manager_client.h"
6 6
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "chromeos/dbus/fake_bluetooth_profile_service_provider.h" 10 #include "chromeos/dbus/fake_bluetooth_profile_service_provider.h"
11 #include "dbus/bus.h" 11 #include "dbus/bus.h"
12 #include "dbus/message.h" 12 #include "dbus/message.h"
13 #include "dbus/object_proxy.h" 13 #include "dbus/object_proxy.h"
14 #include "third_party/cros_system_api/dbus/service_constants.h" 14 #include "third_party/cros_system_api/dbus/service_constants.h"
15 15
16 namespace chromeos { 16 namespace chromeos {
17 17
18 const char FakeBluetoothProfileManagerClient::kL2capUuid[] = 18 const char FakeBluetoothProfileManagerClient::kL2capUuid[] =
19 "4d995052-33cc-4fdf-b446-75f32942a076"; 19 "4d995052-33cc-4fdf-b446-75f32942a076";
20 const char FakeBluetoothProfileManagerClient::kRfcommUuid[] = 20 const char FakeBluetoothProfileManagerClient::kRfcommUuid[] =
21 "3f6d6dbf-a6ad-45fc-9653-47dc912ef70e"; 21 "3f6d6dbf-a6ad-45fc-9653-47dc912ef70e";
22 const char FakeBluetoothProfileManagerClient::kUnregisterableUuid[] =
23 "00000000-0000-0000-0000-000000000000";
22 24
23 FakeBluetoothProfileManagerClient::FakeBluetoothProfileManagerClient() { 25 FakeBluetoothProfileManagerClient::FakeBluetoothProfileManagerClient() {
24 } 26 }
25 27
26 FakeBluetoothProfileManagerClient::~FakeBluetoothProfileManagerClient() { 28 FakeBluetoothProfileManagerClient::~FakeBluetoothProfileManagerClient() {
27 } 29 }
28 30
29 void FakeBluetoothProfileManagerClient::Init(dbus::Bus* bus) { 31 void FakeBluetoothProfileManagerClient::Init(dbus::Bus* bus) {
30 } 32 }
31 33
32 void FakeBluetoothProfileManagerClient::RegisterProfile( 34 void FakeBluetoothProfileManagerClient::RegisterProfile(
33 const dbus::ObjectPath& profile_path, 35 const dbus::ObjectPath& profile_path,
34 const std::string& uuid, 36 const std::string& uuid,
35 const Options& options, 37 const Options& options,
36 const base::Closure& callback, 38 const base::Closure& callback,
37 const ErrorCallback& error_callback) { 39 const ErrorCallback& error_callback) {
38 VLOG(1) << "RegisterProfile: " << profile_path.value() << ": " << uuid; 40 VLOG(1) << "RegisterProfile: " << profile_path.value() << ": " << uuid;
39 41
42 if (uuid == kUnregisterableUuid) {
43 base::MessageLoop::current()->PostTask(
44 FROM_HERE, base::Bind(error_callback,
45 bluetooth_profile_manager::kErrorInvalidArguments,
46 "Can't register this UUID"));
47 return;
48 }
49
40 // check options for channel & psm 50 // check options for channel & psm
41 51
42 ServiceProviderMap::iterator iter = service_provider_map_.find(profile_path); 52 ServiceProviderMap::iterator iter = service_provider_map_.find(profile_path);
43 if (iter == service_provider_map_.end()) { 53 if (iter == service_provider_map_.end()) {
44 error_callback.Run(bluetooth_profile_manager::kErrorInvalidArguments, 54 error_callback.Run(bluetooth_profile_manager::kErrorInvalidArguments,
45 "No profile created"); 55 "No profile created");
46 } else { 56 } else {
47 ProfileMap::iterator piter = profile_map_.find(uuid); 57 ProfileMap::iterator piter = profile_map_.find(uuid);
48 if (piter != profile_map_.end()) { 58 if (piter != profile_map_.end()) {
49 error_callback.Run(bluetooth_profile_manager::kErrorAlreadyExists, 59 error_callback.Run(bluetooth_profile_manager::kErrorAlreadyExists,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 FakeBluetoothProfileServiceProvider* 104 FakeBluetoothProfileServiceProvider*
95 FakeBluetoothProfileManagerClient::GetProfileServiceProvider( 105 FakeBluetoothProfileManagerClient::GetProfileServiceProvider(
96 const std::string& uuid) { 106 const std::string& uuid) {
97 ProfileMap::iterator iter = profile_map_.find(uuid); 107 ProfileMap::iterator iter = profile_map_.find(uuid);
98 if (iter == profile_map_.end()) 108 if (iter == profile_map_.end())
99 return NULL; 109 return NULL;
100 return service_provider_map_[iter->second]; 110 return service_provider_map_[iter->second];
101 } 111 }
102 112
103 } // namespace chromeos 113 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/fake_bluetooth_profile_manager_client.h ('k') | device/bluetooth/bluetooth_adapter_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698