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

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

Issue 939753004: device/bluetooth: Implement Unregister() of BlueotoothAudioSinkChromeOS and disconnection-related c… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_media_client.h" 5 #include "chromeos/dbus/fake_bluetooth_media_client.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "chromeos/dbus/dbus_thread_manager.h" 9 #include "chromeos/dbus/dbus_thread_manager.h"
10 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" 10 #include "chromeos/dbus/fake_bluetooth_adapter_client.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 callback.Run(); 74 callback.Run();
75 } 75 }
76 76
77 void FakeBluetoothMediaClient::UnregisterEndpoint( 77 void FakeBluetoothMediaClient::UnregisterEndpoint(
78 const ObjectPath& object_path, 78 const ObjectPath& object_path,
79 const ObjectPath& endpoint_path, 79 const ObjectPath& endpoint_path,
80 const base::Closure& callback, 80 const base::Closure& callback,
81 const ErrorCallback& error_callback) { 81 const ErrorCallback& error_callback) {
82 // TODO(mcchou): Come up with some corresponding actions. 82 // TODO(mcchou): Come up with some corresponding actions.
83 error_callback.Run(kFailedError, ""); 83 VLOG(1) << "UnregisterEndpoint: " << endpoint_path.value();
84
85 if (endpoints_.find(endpoint_path) == endpoints_.end()) {
Ben Chan 2015/02/19 00:21:45 see ContainsKey in src/base/stl_util.h
Miao 2015/02/23 21:04:24 Done.
86 error_callback.Run(kFailedError, "Unknown media endpoint");
87 return;
88 }
89
90 SetEndpointRegistered(endpoint_path, false);
91 callback.Run();
84 } 92 }
85 93
86 void FakeBluetoothMediaClient::SetVisible(bool visible) { 94 void FakeBluetoothMediaClient::SetVisible(bool visible) {
87 visible_ = visible; 95 visible_ = visible;
88 96
89 if (visible_) 97 if (visible_)
90 return; 98 return;
91 99
92 // If the media object becomes invisible, an update chain will 100 // If the media object becomes invisible, an update chain will
93 // unregister all endpoints and set the associated transport 101 // unregister all endpoints and set the associated transport
94 // objects to be invalid. 102 // objects to be invalid.
95 for (std::map<ObjectPath, bool>::iterator it = endpoints_.begin(); 103 for (std::map<ObjectPath, bool>::iterator it = endpoints_.begin();
96 it != endpoints_.end(); ++it) { 104 it != endpoints_.end(); ++it) {
97 SetEndpointRegistered(it->first, false); 105 SetEndpointRegistered(it->first, false);
98 } 106 }
107
99 endpoints_.clear(); 108 endpoints_.clear();
100 109
101 // Notifies observers about the change on |visible_|. 110 // Notifies observers about the change on |visible_|.
102 FOR_EACH_OBSERVER(BluetoothMediaClient::Observer, observers_, 111 FOR_EACH_OBSERVER(BluetoothMediaClient::Observer, observers_,
103 MediaRemoved(object_path_)); 112 MediaRemoved(object_path_));
104 } 113 }
105 114
106 void FakeBluetoothMediaClient::SetEndpointRegistered( 115 void FakeBluetoothMediaClient::SetEndpointRegistered(
107 const ObjectPath& endpoint_path, 116 const ObjectPath& endpoint_path,
108 bool registered) { 117 bool registered) {
109 if (registered) { 118 if (registered) {
110 endpoints_[endpoint_path] = registered; 119 endpoints_[endpoint_path] = registered;
armansito 2015/02/19 00:37:46 Do an early return here.
Miao 2015/02/23 21:04:24 Done.
111 } else { 120 } else {
112 // Once a media endpoint object becomes invalid, the associated transport 121 // Once a media endpoint object becomes invalid, the associated transport
113 // becomes invalid. 122 // becomes invalid.
114 FakeBluetoothMediaTransportClient* transport = 123 FakeBluetoothMediaTransportClient* transport =
115 static_cast<FakeBluetoothMediaTransportClient*>( 124 static_cast<FakeBluetoothMediaTransportClient*>(
116 DBusThreadManager::Get()->GetBluetoothMediaTransportClient()); 125 DBusThreadManager::Get()->GetBluetoothMediaTransportClient());
117 transport->SetValid(endpoint_path, true); 126 transport->SetValid(endpoint_path, false);
118 } 127 }
119 } 128 }
120 129
121 } // namespace chromeos 130 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698