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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/media/router/cast/SessionWrapper.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
Index: chrome/android/java/src/org/chromium/chrome/browser/media/router/cast/SessionWrapper.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/media/router/cast/SessionWrapper.java b/chrome/android/java/src/org/chromium/chrome/browser/media/router/cast/SessionWrapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..c1f99a9e6efc38bdfc466d024caa79814c1da66b
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/media/router/cast/SessionWrapper.java
@@ -0,0 +1,40 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.media.router.cast;
+
+import com.google.android.gms.cast.Cast;
+import com.google.android.gms.common.api.GoogleApiClient;
+
+/**
+ * A wrapper around the established Cast application session.
+ */
+public class SessionWrapper {
+ private GoogleApiClient mApiClient;
+ private String mSessionId;
+
+ /**
+ * Initializes a new {@link SessionWrapper} instance.
+ * @param apiClient Google Play Services client used to create the session.
+ * @param sessionId the session identifier to use with the Cast SDK.
+ */
+ public SessionWrapper(GoogleApiClient apiClient, String sessionId) {
+ mApiClient = apiClient;
+ mSessionId = sessionId;
+ }
+
+ /**
+ * Stops the Cast application associated with this session.
+ */
+ public void stop() {
+ assert mApiClient != null;
+
+ if (mApiClient.isConnected() || mApiClient.isConnecting()) {
+ Cast.CastApi.stopApplication(mApiClient, mSessionId);
+ }
+
+ mSessionId = null;
+ mApiClient = null;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698