| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.net; | 5 package org.chromium.net; |
| 6 | 6 |
| 7 import android.os.ConditionVariable; | 7 import android.os.ConditionVariable; |
| 8 | 8 |
| 9 import junit.framework.Assert; | 9 import junit.framework.Assert; |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 // If true, init completes synchronously. | 30 // If true, init completes synchronously. |
| 31 private boolean mInitCompletedSynchronously = false; | 31 private boolean mInitCompletedSynchronously = false; |
| 32 private String mData = ""; | 32 private String mData = ""; |
| 33 | 33 |
| 34 public TestUploadDataStreamHandler(final long uploadDataStream) { | 34 public TestUploadDataStreamHandler(final long uploadDataStream) { |
| 35 mTestUploadDataStreamHandler = | 35 mTestUploadDataStreamHandler = |
| 36 nativeCreateTestUploadDataStreamHandler(uploadDataStream); | 36 nativeCreateTestUploadDataStreamHandler(uploadDataStream); |
| 37 } | 37 } |
| 38 | 38 |
| 39 public void destroyNativeObjects() { | 39 public void destroyNativeObjects() { |
| 40 nativeDestroy(mTestUploadDataStreamHandler); | 40 if (mTestUploadDataStreamHandler != 0) { |
| 41 mTestUploadDataStreamHandler = 0; | 41 nativeDestroy(mTestUploadDataStreamHandler); |
| 42 mTestUploadDataStreamHandler = 0; |
| 43 } |
| 42 } | 44 } |
| 43 | 45 |
| 44 /** | 46 /** |
| 45 * Init and returns whether init completes synchronously. | 47 * Init and returns whether init completes synchronously. |
| 46 */ | 48 */ |
| 47 public boolean init() { | 49 public boolean init() { |
| 48 mData = ""; | 50 mData = ""; |
| 49 nativeInit(mTestUploadDataStreamHandler); | 51 nativeInit(mTestUploadDataStreamHandler); |
| 50 mWaitInitCalled.block(); | 52 mWaitInitCalled.block(); |
| 51 mWaitInitCalled.close(); | 53 mWaitInitCalled.close(); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 @NativeClassQualifiedName("TestUploadDataStreamHandler") | 163 @NativeClassQualifiedName("TestUploadDataStreamHandler") |
| 162 private native void nativeCheckReadCallbackNotInvoked( | 164 private native void nativeCheckReadCallbackNotInvoked( |
| 163 long nativePtr); | 165 long nativePtr); |
| 164 | 166 |
| 165 @NativeClassQualifiedName("TestUploadDataStreamHandler") | 167 @NativeClassQualifiedName("TestUploadDataStreamHandler") |
| 166 private native void nativeDestroy(long nativePtr); | 168 private native void nativeDestroy(long nativePtr); |
| 167 | 169 |
| 168 private native long nativeCreateTestUploadDataStreamHandler( | 170 private native long nativeCreateTestUploadDataStreamHandler( |
| 169 long uploadDataStream); | 171 long uploadDataStream); |
| 170 } | 172 } |
| OLD | NEW |