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

Side by Side Diff: chrome/browser/media/router/media_router_mojo_impl.cc

Issue 1314413005: [Presentation API] 1-UA presentation support + presenter APIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 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/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
(...skipping 14 matching lines...) Expand all
25 25
26 namespace media_router { 26 namespace media_router {
27 namespace { 27 namespace {
28 28
29 // Converts the callback result of calling Mojo CreateRoute()/JoinRoute() 29 // Converts the callback result of calling Mojo CreateRoute()/JoinRoute()
30 // into a local callback. 30 // into a local callback.
31 void RouteResponseReceived( 31 void RouteResponseReceived(
32 const std::string& presentation_id, 32 const std::string& presentation_id,
33 const std::vector<MediaRouteResponseCallback>& callbacks, 33 const std::vector<MediaRouteResponseCallback>& callbacks,
34 interfaces::MediaRoutePtr media_route, 34 interfaces::MediaRoutePtr media_route,
35 const mojo::String& error_text) { 35 const mojo::String& error_text,
36 bool is_one_ua_presentation) {
36 scoped_ptr<MediaRoute> route; 37 scoped_ptr<MediaRoute> route;
37 std::string actual_presentation_id; 38 std::string actual_presentation_id;
38 std::string error; 39 std::string error;
39 if (media_route.is_null()) { 40 if (media_route.is_null()) {
40 // An error occurred. 41 // An error occurred.
41 DCHECK(!error_text.is_null()); 42 DCHECK(!error_text.is_null());
42 error = !error_text.get().empty() ? error_text.get() : "Unknown error."; 43 error = !error_text.get().empty() ? error_text.get() : "Unknown error.";
43 } else { 44 } else {
44 route = media_route.To<scoped_ptr<MediaRoute>>(); 45 route = media_route.To<scoped_ptr<MediaRoute>>();
45 actual_presentation_id = presentation_id; 46 actual_presentation_id = presentation_id;
46 } 47 }
47 48
48 for (const MediaRouteResponseCallback& callback : callbacks) 49 for (const MediaRouteResponseCallback& callback : callbacks)
49 callback.Run(route.get(), actual_presentation_id, error); 50 callback.Run(route.get(), actual_presentation_id, error,
51 is_one_ua_presentation);
50 } 52 }
51 53
52 // TODO(imcheng): We should handle failure in this case. One way is to invoke 54 // TODO(imcheng): We should handle failure in this case. One way is to invoke
53 // all pending requests with failure. (crbug.com/490787) 55 // all pending requests with failure. (crbug.com/490787)
54 void EventPageWakeComplete(bool success) { 56 void EventPageWakeComplete(bool success) {
55 if (!success) 57 if (!success)
56 LOG(ERROR) << "An error encountered while waking the event page."; 58 LOG(ERROR) << "An error encountered while waking the event page.";
57 } 59 }
58 60
59 scoped_ptr<content::PresentationSessionMessage> 61 scoped_ptr<content::PresentationSessionMessage>
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 const MediaSource::Id& source_id, 197 const MediaSource::Id& source_id,
196 const MediaSink::Id& sink_id, 198 const MediaSink::Id& sink_id,
197 const GURL& origin, 199 const GURL& origin,
198 int tab_id, 200 int tab_id,
199 const std::vector<MediaRouteResponseCallback>& callbacks) { 201 const std::vector<MediaRouteResponseCallback>& callbacks) {
200 DCHECK(thread_checker_.CalledOnValidThread()); 202 DCHECK(thread_checker_.CalledOnValidThread());
201 203
202 if (!origin.is_valid()) { 204 if (!origin.is_valid()) {
203 DVLOG_WITH_INSTANCE(1) << "Invalid origin: " << origin; 205 DVLOG_WITH_INSTANCE(1) << "Invalid origin: " << origin;
204 for (const MediaRouteResponseCallback& callback : callbacks) 206 for (const MediaRouteResponseCallback& callback : callbacks)
205 callback.Run(nullptr, "", "Invalid origin"); 207 callback.Run(nullptr, "", "Invalid origin", false);
206 return; 208 return;
207 } 209 }
208 RunOrDefer(base::Bind( 210 RunOrDefer(base::Bind(
209 &MediaRouterMojoImpl::DoCreateRoute, base::Unretained(this), source_id, 211 &MediaRouterMojoImpl::DoCreateRoute, base::Unretained(this), source_id,
210 sink_id, origin.is_empty() ? "" : origin.spec(), tab_id, callbacks)); 212 sink_id, origin.is_empty() ? "" : origin.spec(), tab_id, callbacks));
211 } 213 }
212 214
213 void MediaRouterMojoImpl::JoinRoute( 215 void MediaRouterMojoImpl::JoinRoute(
214 const MediaSource::Id& source_id, 216 const MediaSource::Id& source_id,
215 const std::string& presentation_id, 217 const std::string& presentation_id,
216 const GURL& origin, 218 const GURL& origin,
217 int tab_id, 219 int tab_id,
218 const std::vector<MediaRouteResponseCallback>& callbacks) { 220 const std::vector<MediaRouteResponseCallback>& callbacks) {
219 DCHECK(thread_checker_.CalledOnValidThread()); 221 DCHECK(thread_checker_.CalledOnValidThread());
220 222
221 if (!origin.is_valid()) { 223 if (!origin.is_valid()) {
222 DVLOG_WITH_INSTANCE(1) << "Invalid origin: " << origin; 224 DVLOG_WITH_INSTANCE(1) << "Invalid origin: " << origin;
223 for (const MediaRouteResponseCallback& callback : callbacks) 225 for (const MediaRouteResponseCallback& callback : callbacks)
224 callback.Run(nullptr, "", "Invalid origin"); 226 callback.Run(nullptr, "", "Invalid origin", false);
225 return; 227 return;
226 } 228 }
227 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoJoinRoute, 229 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoJoinRoute,
228 base::Unretained(this), source_id, presentation_id, 230 base::Unretained(this), source_id, presentation_id,
229 origin.is_empty() ? "" : origin.spec(), tab_id, 231 origin.is_empty() ? "" : origin.spec(), tab_id,
230 callbacks)); 232 callbacks));
231 } 233 }
232 234
233 void MediaRouterMojoImpl::CloseRoute(const MediaRoute::Id& route_id) { 235 void MediaRouterMojoImpl::CloseRoute(const MediaRoute::Id& route_id) {
234 DCHECK(thread_checker_.CalledOnValidThread()); 236 DCHECK(thread_checker_.CalledOnValidThread());
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 return; 580 return;
579 } 581 }
580 582
581 for (const auto& next_request : pending_requests_) 583 for (const auto& next_request : pending_requests_)
582 next_request.Run(); 584 next_request.Run();
583 585
584 pending_requests_.clear(); 586 pending_requests_.clear();
585 } 587 }
586 588
587 } // namespace media_router 589 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698