summaryrefslogtreecommitdiffstats
path: root/chrome/test/media_router
diff options
context:
space:
mode:
authorimcheng <imcheng@google.com>2015-07-17 14:44:04 -0700
committerCommit bot <commit-bot@chromium.org>2015-07-17 21:44:49 +0000
commitcb9406372121b18de2763ef791b1572641ed5c49 (patch)
tree1993cb793da3a0e7bd484d894bdb98757e0cdd99 /chrome/test/media_router
parent556701f7f0867a21474cfddfb0bc1bfc706f9f37 (diff)
downloadchromium_src-cb9406372121b18de2763ef791b1572641ed5c49.zip
chromium_src-cb9406372121b18de2763ef791b1572641ed5c49.tar.gz
chromium_src-cb9406372121b18de2763ef791b1572641ed5c49.tar.bz2
[Media Router] 2nd take on fix route response callback lifetime in UI.
This patch changes the MediaRouter CreateRoute/JoinRoute API to take multiple MediaRouteResponseCallbacks. We have a few scenarios in which we need to pass in different sets of callbacks: 1) non-presentation route request: update UI only 2) presentation route request as a result of pres API startSession: update UI + answer startSession request 3) presentation route request, browser initiated: update UI + trigger ondefaultsessionstart The callbacks are owned by the UI thread and are able to outlive the MRUI instance that made the CreateRoute call, in cases (2) and (3). Note that stale presentation API responses (i.e., made obsolete as a result of navigation) are dropped by PSImpl. Previous attempt at 1198993002. BUG=501441 Review URL: https://codereview.chromium.org/1224093004 Cr-Commit-Position: refs/heads/master@{#339337}
Diffstat (limited to 'chrome/test/media_router')
-rw-r--r--chrome/test/media_router/media_router_e2e_browsertest.cc10
-rw-r--r--chrome/test/media_router/media_router_e2e_browsertest.h2
2 files changed, 7 insertions, 5 deletions
diff --git a/chrome/test/media_router/media_router_e2e_browsertest.cc b/chrome/test/media_router/media_router_e2e_browsertest.cc
index 24f6767..38f63c0 100644
--- a/chrome/test/media_router/media_router_e2e_browsertest.cc
+++ b/chrome/test/media_router/media_router_e2e_browsertest.cc
@@ -61,9 +61,9 @@ void MediaRouterE2EBrowserTest::TearDownOnMainThread() {
}
void MediaRouterE2EBrowserTest::OnRouteResponseReceived(
- scoped_ptr<MediaRoute> route,
+ const MediaRoute* route,
const std::string& error) {
- ASSERT_TRUE(route.get());
+ ASSERT_TRUE(route);
route_id_ = route->media_route_id();
}
@@ -85,10 +85,12 @@ void MediaRouterE2EBrowserTest::CreateMediaRoute(const MediaSource& source,
const MediaSink& sink = it->second;
// The callback will set route_id_ when invoked.
- media_router_->CreateRoute(
- source.id(), sink.id(), origin, tab_id,
+ std::vector<MediaRouteResponseCallback> route_response_callbacks;
+ route_response_callbacks.push_back(
base::Bind(&MediaRouterE2EBrowserTest::OnRouteResponseReceived,
base::Unretained(this)));
+ media_router_->CreateRoute(source.id(), sink.id(), origin, tab_id,
+ route_response_callbacks);
// Wait for the route request to be fulfilled (and route to be started).
ConditionalWait(base::TimeDelta::FromSeconds(30),
diff --git a/chrome/test/media_router/media_router_e2e_browsertest.h b/chrome/test/media_router/media_router_e2e_browsertest.h
index e88f56c..385fd30 100644
--- a/chrome/test/media_router/media_router_e2e_browsertest.h
+++ b/chrome/test/media_router/media_router_e2e_browsertest.h
@@ -32,7 +32,7 @@ class MediaRouterE2EBrowserTest : public MediaRouterBaseBrowserTest {
// Callback from MediaRouter when a response to a media route request is
// received.
- void OnRouteResponseReceived(scoped_ptr<MediaRoute> route,
+ void OnRouteResponseReceived(const MediaRoute* route,
const std::string& error);
// Initializes |observer_| to listen for sinks compatible with |source|,