| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.mojo.bindings; | 5 package org.chromium.mojo.bindings; |
| 6 | 6 |
| 7 import android.annotation.SuppressLint; |
| 8 |
| 7 import org.chromium.mojo.system.AsyncWaiter; | 9 import org.chromium.mojo.system.AsyncWaiter; |
| 8 import org.chromium.mojo.system.MessagePipeHandle; | 10 import org.chromium.mojo.system.MessagePipeHandle; |
| 9 | 11 |
| 10 import java.util.HashMap; | 12 import java.util.HashMap; |
| 11 import java.util.Map; | 13 import java.util.Map; |
| 12 | 14 |
| 13 /** | 15 /** |
| 14 * Implementation of {@link Router}. | 16 * Implementation of {@link Router}. |
| 15 */ | 17 */ |
| 16 public class RouterImpl implements Router { | 18 public class RouterImpl implements Router { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 private MessageReceiverWithResponder mIncomingMessageReceiver; | 52 private MessageReceiverWithResponder mIncomingMessageReceiver; |
| 51 | 53 |
| 52 /** | 54 /** |
| 53 * The next id to use for a request id which needs a response. It is auto-in
cremented. | 55 * The next id to use for a request id which needs a response. It is auto-in
cremented. |
| 54 */ | 56 */ |
| 55 private long mNextRequestId = 1; | 57 private long mNextRequestId = 1; |
| 56 | 58 |
| 57 /** | 59 /** |
| 58 * The map from request ids to {@link MessageReceiver} of request currently
in flight. | 60 * The map from request ids to {@link MessageReceiver} of request currently
in flight. |
| 59 */ | 61 */ |
| 62 @SuppressLint("UseSparseArrays") |
| 60 private Map<Long, MessageReceiver> mResponders = new HashMap<Long, MessageRe
ceiver>(); | 63 private Map<Long, MessageReceiver> mResponders = new HashMap<Long, MessageRe
ceiver>(); |
| 61 | 64 |
| 62 /** | 65 /** |
| 63 * Constructor that will use the default {@link AsyncWaiter}. | 66 * Constructor that will use the default {@link AsyncWaiter}. |
| 64 * | 67 * |
| 65 * @param messagePipeHandle The {@link MessagePipeHandle} to route message f
or. | 68 * @param messagePipeHandle The {@link MessagePipeHandle} to route message f
or. |
| 66 */ | 69 */ |
| 67 public RouterImpl(MessagePipeHandle messagePipeHandle) { | 70 public RouterImpl(MessagePipeHandle messagePipeHandle) { |
| 68 this(messagePipeHandle, BindingsHelper.getDefaultAsyncWaiterForHandle(me
ssagePipeHandle)); | 71 this(messagePipeHandle, BindingsHelper.getDefaultAsyncWaiterForHandle(me
ssagePipeHandle)); |
| 69 } | 72 } |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 } | 189 } |
| 187 return false; | 190 return false; |
| 188 } | 191 } |
| 189 | 192 |
| 190 private void handleConnectorClose() { | 193 private void handleConnectorClose() { |
| 191 if (mIncomingMessageReceiver != null) { | 194 if (mIncomingMessageReceiver != null) { |
| 192 mIncomingMessageReceiver.close(); | 195 mIncomingMessageReceiver.close(); |
| 193 } | 196 } |
| 194 } | 197 } |
| 195 } | 198 } |
| OLD | NEW |