OLD | NEW |
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"; | |
24 | 22 |
25 FakeBluetoothProfileManagerClient::FakeBluetoothProfileManagerClient() { | 23 FakeBluetoothProfileManagerClient::FakeBluetoothProfileManagerClient() { |
26 } | 24 } |
27 | 25 |
28 FakeBluetoothProfileManagerClient::~FakeBluetoothProfileManagerClient() { | 26 FakeBluetoothProfileManagerClient::~FakeBluetoothProfileManagerClient() { |
29 } | 27 } |
30 | 28 |
31 void FakeBluetoothProfileManagerClient::Init(dbus::Bus* bus) { | 29 void FakeBluetoothProfileManagerClient::Init(dbus::Bus* bus) { |
32 } | 30 } |
33 | 31 |
34 void FakeBluetoothProfileManagerClient::RegisterProfile( | 32 void FakeBluetoothProfileManagerClient::RegisterProfile( |
35 const dbus::ObjectPath& profile_path, | 33 const dbus::ObjectPath& profile_path, |
36 const std::string& uuid, | 34 const std::string& uuid, |
37 const Options& options, | 35 const Options& options, |
38 const base::Closure& callback, | 36 const base::Closure& callback, |
39 const ErrorCallback& error_callback) { | 37 const ErrorCallback& error_callback) { |
40 VLOG(1) << "RegisterProfile: " << profile_path.value() << ": " << uuid; | 38 VLOG(1) << "RegisterProfile: " << profile_path.value() << ": " << uuid; |
41 | 39 |
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 | |
50 // check options for channel & psm | 40 // check options for channel & psm |
51 | 41 |
52 ServiceProviderMap::iterator iter = service_provider_map_.find(profile_path); | 42 ServiceProviderMap::iterator iter = service_provider_map_.find(profile_path); |
53 if (iter == service_provider_map_.end()) { | 43 if (iter == service_provider_map_.end()) { |
54 error_callback.Run(bluetooth_profile_manager::kErrorInvalidArguments, | 44 error_callback.Run(bluetooth_profile_manager::kErrorInvalidArguments, |
55 "No profile created"); | 45 "No profile created"); |
56 } else { | 46 } else { |
57 ProfileMap::iterator piter = profile_map_.find(uuid); | 47 ProfileMap::iterator piter = profile_map_.find(uuid); |
58 if (piter != profile_map_.end()) { | 48 if (piter != profile_map_.end()) { |
59 error_callback.Run(bluetooth_profile_manager::kErrorAlreadyExists, | 49 error_callback.Run(bluetooth_profile_manager::kErrorAlreadyExists, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 FakeBluetoothProfileServiceProvider* | 94 FakeBluetoothProfileServiceProvider* |
105 FakeBluetoothProfileManagerClient::GetProfileServiceProvider( | 95 FakeBluetoothProfileManagerClient::GetProfileServiceProvider( |
106 const std::string& uuid) { | 96 const std::string& uuid) { |
107 ProfileMap::iterator iter = profile_map_.find(uuid); | 97 ProfileMap::iterator iter = profile_map_.find(uuid); |
108 if (iter == profile_map_.end()) | 98 if (iter == profile_map_.end()) |
109 return NULL; | 99 return NULL; |
110 return service_provider_map_[iter->second]; | 100 return service_provider_map_[iter->second]; |
111 } | 101 } |
112 | 102 |
113 } // namespace chromeos | 103 } // namespace chromeos |
OLD | NEW |