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

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

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

Powered by Google App Engine
This is Rietveld 408576698