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

Unified Diff: components/cast_channel/cast_socket_service.cc

Issue 2942993003: [cast_channel] Make CastMessageHandler a CastSocket::Observer instead of CastTransport::Delegate (Closed)
Patch Set: resolve code review comments from Derek and Mark Created 3 years, 6 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: components/cast_channel/cast_socket_service.cc
diff --git a/components/cast_channel/cast_socket_service.cc b/components/cast_channel/cast_socket_service.cc
index f58c9858e9212121ed2ad48758d411773747d708..fc43c5daaa40e00bc12ef91bebcd258017edc18c 100644
--- a/components/cast_channel/cast_socket_service.cc
+++ b/components/cast_channel/cast_socket_service.cc
@@ -52,6 +52,22 @@ CastSocket* CastSocketService::GetSocket(int channel_id) const {
return socket_it == sockets_.end() ? nullptr : socket_it->second.get();
}
+CastSocket::Observer* CastSocketService::GetObserver(const std::string& id) {
+ auto it = std::find_if(
+ socket_observer_map_.begin(), socket_observer_map_.end(),
+ [id](const std::pair<const std::string,
mark a. foltz 2017/06/20 01:16:43 Can the parameter passed to the lambda be const au
zhaobin 2017/06/20 17:50:05 Seems not.. Got ''auto' not allowed in lambda para
+ std::unique_ptr<CastSocket::Observer>>& entry) {
+ return entry.first == id;
+ });
+ return it == socket_observer_map_.end() ? nullptr : it->second.get();
+}
+
+void CastSocketService::AddObserver(
+ const std::string& id,
+ std::unique_ptr<CastSocket::Observer> observer) {
+ socket_observer_map_.insert(std::make_pair(id, std::move(observer)));
+}
+
void CastSocketService::ShutdownOnUIThread() {}
} // namespace cast_channel

Powered by Google App Engine
This is Rietveld 408576698