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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/media/router/ChromeMediaRouter.java

Issue 1292853003: [Presentation API, Android] Implement closing the route (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@create-route
Patch Set: merge Created 5 years, 4 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
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/media/router/cast/CreateRouteRequest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/media/router/ChromeMediaRouter.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/media/router/ChromeMediaRouter.java b/chrome/android/java/src/org/chromium/chrome/browser/media/router/ChromeMediaRouter.java
index 0c4cbd8fa79ad79fd259eb99d46c9dfecd327da6..b0acddaec714581b633d4257d0ec30b48efe1afe 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/media/router/ChromeMediaRouter.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/media/router/ChromeMediaRouter.java
@@ -16,6 +16,7 @@ import org.chromium.chrome.browser.media.router.cast.CreateRouteRequest;
import org.chromium.chrome.browser.media.router.cast.DiscoveryCallback;
import org.chromium.chrome.browser.media.router.cast.MediaSink;
import org.chromium.chrome.browser.media.router.cast.MediaSource;
+import org.chromium.chrome.browser.media.router.cast.SessionWrapper;
import java.util.HashMap;
import java.util.List;
@@ -36,8 +37,8 @@ public class ChromeMediaRouter {
private final Map<String, List<MediaSink>> mSinks = new HashMap<String, List<MediaSink>>();
private final Map<String, DiscoveryCallback> mDiscoveryCallbacks =
new HashMap<String, DiscoveryCallback>();
- private final Map<String, String> mSessionIds =
- new HashMap<String, String>();
+ private final Map<String, SessionWrapper> mSessions =
+ new HashMap<String, SessionWrapper>();
/**
* Called when the sinks found by the media route provider for
@@ -56,8 +57,8 @@ public class ChromeMediaRouter {
* @param requestId the id of the route creation request.
*/
public void onRouteCreated(
- String mediaRouteId, int requestId, String sessionId, boolean wasLaunched) {
- mSessionIds.put(mediaRouteId, sessionId);
+ String mediaRouteId, int requestId, SessionWrapper session, boolean wasLaunched) {
+ mSessions.put(mediaRouteId, session);
nativeOnRouteCreated(mNativeMediaRouterAndroid, mediaRouteId, requestId, wasLaunched);
}
@@ -183,6 +184,19 @@ public class ChromeMediaRouter {
new Cast.Listener() {});
}
+ /**
+ * Closes the route specified by the id.
+ * @param routeId the id of the route to close.
+ */
+ @CalledByNative
+ public void closeRoute(String routeId) {
+ SessionWrapper session = mSessions.remove(routeId);
+ if (session != null) session.stop();
+ if (mAndroidMediaRouter != null) {
+ mAndroidMediaRouter.selectRoute(mAndroidMediaRouter.getDefaultRoute());
+ }
+ }
+
@VisibleForTesting
ChromeMediaRouter(long nativeMediaRouter, Context applicationContext) {
assert applicationContext != null;
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/media/router/cast/CreateRouteRequest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698