OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 package org.chromium.chrome.browser.media.router.cast; | 5 package org.chromium.chrome.browser.media.router.cast; |
6 | 6 |
7 import android.os.Handler; | 7 import android.os.Handler; |
8 import android.support.v4.util.ArrayMap; | 8 import android.support.v4.util.ArrayMap; |
9 import android.util.SparseArray; | 9 import android.util.SparseArray; |
10 | 10 |
11 import org.chromium.base.Log; | |
12 import org.chromium.base.VisibleForTesting; | |
13 import org.json.JSONArray; | 11 import org.json.JSONArray; |
14 import org.json.JSONException; | 12 import org.json.JSONException; |
15 import org.json.JSONObject; | 13 import org.json.JSONObject; |
16 | 14 |
| 15 import org.chromium.base.Log; |
| 16 import org.chromium.base.VisibleForTesting; |
| 17 |
17 import java.util.ArrayDeque; | 18 import java.util.ArrayDeque; |
18 import java.util.Arrays; | 19 import java.util.Arrays; |
19 import java.util.HashMap; | 20 import java.util.HashMap; |
20 import java.util.List; | 21 import java.util.List; |
21 import java.util.Map; | 22 import java.util.Map; |
22 import java.util.Queue; | 23 import java.util.Queue; |
23 | 24 |
24 /** | 25 /** |
25 * The handler for cast messages. It receives events between the Cast SDK and th
e page, process and | 26 * The handler for cast messages. It receives events between the Cast SDK and th
e page, process and |
26 * dispatch the messages accordingly. The handler talks to the Cast SDK via Cast
Session, and | 27 * dispatch the messages accordingly. The handler talks to the Cast SDK via Cast
Session, and |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 // expect them to be named FOO. The reason being that FOO might exist in mul
tiple namespaces | 66 // expect them to be named FOO. The reason being that FOO might exist in mul
tiple namespaces |
66 // but the client isn't aware of namespacing. | 67 // but the client isn't aware of namespacing. |
67 private static Map<String, String> sMediaOverloadedMessageTypes; | 68 private static Map<String, String> sMediaOverloadedMessageTypes; |
68 | 69 |
69 private SparseArray<RequestRecord> mRequests; | 70 private SparseArray<RequestRecord> mRequests; |
70 private ArrayMap<String, Queue<Integer>> mStopRequests; | 71 private ArrayMap<String, Queue<Integer>> mStopRequests; |
71 private Queue<RequestRecord> mVolumeRequests; | 72 private Queue<RequestRecord> mVolumeRequests; |
72 | 73 |
73 // The reference to CastSession, only valid after calling {@link onSessionCr
eated}, and will be | 74 // The reference to CastSession, only valid after calling {@link onSessionCr
eated}, and will be |
74 // reset to null when calling {@link onApplicationStopped}. | 75 // reset to null when calling {@link onApplicationStopped}. |
75 private CastSession mSession = null; | 76 private CastSession mSession; |
76 private final CastMediaRouteProvider mRouteProvider; | 77 private final CastMediaRouteProvider mRouteProvider; |
77 private Handler mHandler; | 78 private Handler mHandler; |
78 | 79 |
79 /** | 80 /** |
80 * The record for client requests. {@link CastMessageHandler} uses this clas
s to manage the | 81 * The record for client requests. {@link CastMessageHandler} uses this clas
s to manage the |
81 * client requests and match responses to the requests. | 82 * client requests and match responses to the requests. |
82 */ | 83 */ |
83 static class RequestRecord { | 84 static class RequestRecord { |
84 public final String clientId; | 85 public final String clientId; |
85 public final int sequenceNumber; | 86 public final int sequenceNumber; |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 } | 616 } |
616 | 617 |
617 private JSONArray toJSONArray(List<String> from) throws JSONException { | 618 private JSONArray toJSONArray(List<String> from) throws JSONException { |
618 JSONArray result = new JSONArray(); | 619 JSONArray result = new JSONArray(); |
619 for (String entry : from) { | 620 for (String entry : from) { |
620 result.put(entry); | 621 result.put(entry); |
621 } | 622 } |
622 return result; | 623 return result; |
623 } | 624 } |
624 } | 625 } |
OLD | NEW |