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

Unified Diff: chromeos/dbus/fake_bluetooth_profile_manager_client.cc

Issue 14487002: Bluetooth: Profile support for Chrome OS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add unit tests, and class comments Created 7 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 side-by-side diff with in-line comments
Download patch
Index: chromeos/dbus/fake_bluetooth_profile_manager_client.cc
diff --git a/chromeos/dbus/fake_bluetooth_profile_manager_client.cc b/chromeos/dbus/fake_bluetooth_profile_manager_client.cc
index 0547e4b1d9c9771f89db1958737ad40d0d433239..2f2fb8e0b23d49aae9fc1b8980d7d1a724496a26 100644
--- a/chromeos/dbus/fake_bluetooth_profile_manager_client.cc
+++ b/chromeos/dbus/fake_bluetooth_profile_manager_client.cc
@@ -4,8 +4,12 @@
#include "chromeos/dbus/fake_bluetooth_profile_manager_client.h"
+#include <map>
+#include <string>
+
#include "base/bind.h"
#include "base/logging.h"
+#include "chromeos/dbus/fake_bluetooth_profile_service_provider.h"
#include "dbus/bus.h"
#include "dbus/message.h"
#include "dbus/object_path.h"
@@ -14,6 +18,11 @@
namespace chromeos {
+const char FakeBluetoothProfileManagerClient::kL2capUuid[] =
+ "4d995052-33cc-4fdf-b446-75f32942a076";
+const char FakeBluetoothProfileManagerClient::kRfcommUuid[] =
+ "3f6d6dbf-a6ad-45fc-9653-47dc912ef70e";
+
FakeBluetoothProfileManagerClient::FakeBluetoothProfileManagerClient() {
}
@@ -27,7 +36,23 @@ void FakeBluetoothProfileManagerClient::RegisterProfile(
const base::Closure& callback,
const ErrorCallback& error_callback) {
VLOG(1) << "RegisterProfile: " << profile_path.value() << ": " << uuid;
- callback.Run();
+
+ // check options for channel & psm
+
+ ServiceProviderMap::iterator iter = service_provider_map_.find(profile_path);
+ if (iter == service_provider_map_.end()) {
+ error_callback.Run(bluetooth_adapter::kErrorFailed,
+ "No profile created");
+ } else {
+ ProfileMap::iterator piter = profile_map_.find(uuid);
+ if (piter != profile_map_.end()) {
+ error_callback.Run(bluetooth_adapter::kErrorAlreadyExists,
+ "Profile already registered");
+ } else {
+ profile_map_[uuid] = profile_path;
+ callback.Run();
+ }
+ }
}
void FakeBluetoothProfileManagerClient::UnregisterProfile(
@@ -35,7 +60,44 @@ void FakeBluetoothProfileManagerClient::UnregisterProfile(
const base::Closure& callback,
const ErrorCallback& error_callback) {
VLOG(1) << "UnregisterProfile: " << profile_path.value();
- callback.Run();
+
+ ServiceProviderMap::iterator iter = service_provider_map_.find(profile_path);
+ if (iter != service_provider_map_.end()) {
+ error_callback.Run(bluetooth_adapter::kErrorFailed,
+ "Profile still registered");
+ } else {
+ for (ProfileMap::iterator piter = profile_map_.begin();
+ piter != profile_map_.end(); ++piter) {
+ if (piter->second == profile_path) {
+ profile_map_.erase(piter);
+ break;
+ }
+ }
+
+ callback.Run();
+ }
+}
+
+void FakeBluetoothProfileManagerClient::RegisterProfileServiceProvider(
+ FakeBluetoothProfileServiceProvider* service_provider) {
+ service_provider_map_[service_provider->object_path_] = service_provider;
+}
+
+void FakeBluetoothProfileManagerClient::UnregisterProfileServiceProvider(
+ FakeBluetoothProfileServiceProvider* service_provider) {
+ ServiceProviderMap::iterator iter =
+ service_provider_map_.find(service_provider->object_path_);
+ if (iter != service_provider_map_.end() && iter->second == service_provider)
+ service_provider_map_.erase(iter);
+}
+
+FakeBluetoothProfileServiceProvider*
+FakeBluetoothProfileManagerClient::GetProfileServiceProvider(
+ const std::string& uuid) {
+ ProfileMap::iterator iter = profile_map_.find(uuid);
+ if (iter == profile_map_.end())
+ return NULL;
+ return service_provider_map_[iter->second];
}
} // namespace chromeos
« no previous file with comments | « chromeos/dbus/fake_bluetooth_profile_manager_client.h ('k') | chromeos/dbus/fake_bluetooth_profile_service_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698