OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/media/router/media_router_mojo_impl.h" | 5 #include "chrome/browser/media/router/media_router_mojo_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/guid.h" | 8 #include "base/guid.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 base::Unretained(this), source_id, sink_id, callback)); | 167 base::Unretained(this), source_id, sink_id, callback)); |
168 } | 168 } |
169 | 169 |
170 void MediaRouterMojoImpl::CloseRoute(const MediaRoute::Id& route_id) { | 170 void MediaRouterMojoImpl::CloseRoute(const MediaRoute::Id& route_id) { |
171 DCHECK(thread_checker_.CalledOnValidThread()); | 171 DCHECK(thread_checker_.CalledOnValidThread()); |
172 | 172 |
173 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoCloseRoute, | 173 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoCloseRoute, |
174 base::Unretained(this), route_id)); | 174 base::Unretained(this), route_id)); |
175 } | 175 } |
176 | 176 |
177 void MediaRouterMojoImpl::PostMessage(const MediaRoute::Id& route_id, | 177 void MediaRouterMojoImpl::SendMessage(const MediaRoute::Id& route_id, |
178 const std::string& message) { | 178 const std::string& message, |
| 179 const SendMessageCallback& callback) { |
179 DCHECK(thread_checker_.CalledOnValidThread()); | 180 DCHECK(thread_checker_.CalledOnValidThread()); |
180 | 181 |
181 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoPostMessage, | 182 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoPostMessage, |
182 base::Unretained(this), route_id, message)); | 183 base::Unretained(this), route_id, message, callback)); |
183 } | 184 } |
184 | 185 |
185 void MediaRouterMojoImpl::ClearIssue(const Issue::Id& issue_id) { | 186 void MediaRouterMojoImpl::ClearIssue(const Issue::Id& issue_id) { |
186 DCHECK(thread_checker_.CalledOnValidThread()); | 187 DCHECK(thread_checker_.CalledOnValidThread()); |
187 | 188 |
188 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoClearIssue, | 189 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoClearIssue, |
189 base::Unretained(this), issue_id)); | 190 base::Unretained(this), issue_id)); |
190 } | 191 } |
191 | 192 |
192 void MediaRouterMojoImpl::RegisterMediaSinksObserver( | 193 void MediaRouterMojoImpl::RegisterMediaSinksObserver( |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 mojo_media_router_->CreateRoute( | 276 mojo_media_router_->CreateRoute( |
276 source_id, sink_id, base::Bind(&CreateRouteFinished, sink_id, callback)); | 277 source_id, sink_id, base::Bind(&CreateRouteFinished, sink_id, callback)); |
277 } | 278 } |
278 | 279 |
279 void MediaRouterMojoImpl::DoCloseRoute(const MediaRoute::Id& route_id) { | 280 void MediaRouterMojoImpl::DoCloseRoute(const MediaRoute::Id& route_id) { |
280 DVLOG_WITH_INSTANCE(1) << "CloseRoute " << route_id; | 281 DVLOG_WITH_INSTANCE(1) << "CloseRoute " << route_id; |
281 mojo_media_router_->CloseRoute(route_id); | 282 mojo_media_router_->CloseRoute(route_id); |
282 } | 283 } |
283 | 284 |
284 void MediaRouterMojoImpl::DoPostMessage(const MediaRoute::Id& route_id, | 285 void MediaRouterMojoImpl::DoPostMessage(const MediaRoute::Id& route_id, |
285 const std::string& message) { | 286 const std::string& message, |
286 DVLOG_WITH_INSTANCE(1) << "PostMessage " << route_id; | 287 const SendMessageCallback& callback) { |
287 mojo_media_router_->PostMessage(route_id, message); | 288 DVLOG_WITH_INSTANCE(1) << "SendMessage " << route_id; |
| 289 mojo_media_router_->SendMessage(route_id, message, callback); |
288 } | 290 } |
289 | 291 |
290 void MediaRouterMojoImpl::DoClearIssue(const Issue::Id& issue_id) { | 292 void MediaRouterMojoImpl::DoClearIssue(const Issue::Id& issue_id) { |
291 DVLOG_WITH_INSTANCE(1) << "ClearIssue " << issue_id; | 293 DVLOG_WITH_INSTANCE(1) << "ClearIssue " << issue_id; |
292 mojo_media_router_->ClearIssue(issue_id); | 294 mojo_media_router_->ClearIssue(issue_id); |
293 } | 295 } |
294 | 296 |
295 void MediaRouterMojoImpl::DoStartObservingMediaSinks( | 297 void MediaRouterMojoImpl::DoStartObservingMediaSinks( |
296 const std::string& source_id) { | 298 const std::string& source_id) { |
297 DVLOG_WITH_INSTANCE(1) << "StartObservingMediaSinks: " << source_id; | 299 DVLOG_WITH_INSTANCE(1) << "StartObservingMediaSinks: " << source_id; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 return; | 360 return; |
359 } | 361 } |
360 | 362 |
361 for (const auto& next_request : pending_requests_) | 363 for (const auto& next_request : pending_requests_) |
362 next_request.Run(); | 364 next_request.Run(); |
363 | 365 |
364 pending_requests_.clear(); | 366 pending_requests_.clear(); |
365 } | 367 } |
366 | 368 |
367 } // namespace media_router | 369 } // namespace media_router |
OLD | NEW |