| 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.net.impl; | 5 package org.chromium.net.impl; |
| 6 | 6 |
| 7 import android.os.ConditionVariable; | 7 import android.os.ConditionVariable; |
| 8 import android.os.Handler; | 8 import android.os.Handler; |
| 9 import android.os.Looper; | 9 import android.os.Looper; |
| 10 import android.os.Process; | 10 import android.os.Process; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 private String mCertVerifierData; | 141 private String mCertVerifierData; |
| 142 | 142 |
| 143 private ConditionVariable mStopNetLogCompleted; | 143 private ConditionVariable mStopNetLogCompleted; |
| 144 | 144 |
| 145 /** | 145 /** |
| 146 * True if a NetLog observer is active. | 146 * True if a NetLog observer is active. |
| 147 */ | 147 */ |
| 148 @GuardedBy("mLock") | 148 @GuardedBy("mLock") |
| 149 private boolean mIsLogging; | 149 private boolean mIsLogging; |
| 150 | 150 |
| 151 /** | |
| 152 * True if a NetLog observer that writes to disk with a bounded amount of sp
ace has been | |
| 153 * activated by calling StartNetLogToDisk(). | |
| 154 */ | |
| 155 @GuardedBy("mLock") | |
| 156 private boolean mNetLogToDisk; | |
| 157 | |
| 158 @UsedByReflection("CronetEngine.java") | 151 @UsedByReflection("CronetEngine.java") |
| 159 public CronetUrlRequestContext(final CronetEngineBuilderImpl builder) { | 152 public CronetUrlRequestContext(final CronetEngineBuilderImpl builder) { |
| 160 CronetLibraryLoader.ensureInitialized(builder.getContext(), builder); | 153 CronetLibraryLoader.ensureInitialized(builder.getContext(), builder); |
| 161 nativeSetMinLogLevel(getLoggingLevel()); | 154 nativeSetMinLogLevel(getLoggingLevel()); |
| 162 synchronized (mLock) { | 155 synchronized (mLock) { |
| 163 mUrlRequestContextAdapter = | 156 mUrlRequestContextAdapter = |
| 164 nativeCreateRequestContextAdapter(createNativeUrlRequestCont
extConfig(builder)); | 157 nativeCreateRequestContextAdapter(createNativeUrlRequestCont
extConfig(builder)); |
| 165 if (mUrlRequestContextAdapter == 0) { | 158 if (mUrlRequestContextAdapter == 0) { |
| 166 throw new NullPointerException("Context Adapter creation failed.
"); | 159 throw new NullPointerException("Context Adapter creation failed.
"); |
| 167 } | 160 } |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 mIsLogging = true; | 280 mIsLogging = true; |
| 288 } | 281 } |
| 289 } | 282 } |
| 290 | 283 |
| 291 @Override | 284 @Override |
| 292 public void startNetLogToDisk(String dirPath, boolean logAll, int maxSize) { | 285 public void startNetLogToDisk(String dirPath, boolean logAll, int maxSize) { |
| 293 synchronized (mLock) { | 286 synchronized (mLock) { |
| 294 checkHaveAdapter(); | 287 checkHaveAdapter(); |
| 295 nativeStartNetLogToDisk(mUrlRequestContextAdapter, dirPath, logAll,
maxSize); | 288 nativeStartNetLogToDisk(mUrlRequestContextAdapter, dirPath, logAll,
maxSize); |
| 296 mIsLogging = true; | 289 mIsLogging = true; |
| 297 mNetLogToDisk = true; | |
| 298 } | 290 } |
| 299 } | 291 } |
| 300 | 292 |
| 301 @Override | 293 @Override |
| 302 public void stopNetLog() { | 294 public void stopNetLog() { |
| 303 synchronized (mLock) { | 295 synchronized (mLock) { |
| 304 if (!mIsLogging) { | 296 if (!mIsLogging) { |
| 305 return; | 297 return; |
| 306 } | 298 } |
| 307 checkHaveAdapter(); | 299 checkHaveAdapter(); |
| 308 nativeStopNetLog(mUrlRequestContextAdapter); | 300 nativeStopNetLog(mUrlRequestContextAdapter); |
| 309 mIsLogging = false; | 301 mIsLogging = false; |
| 310 if (!mNetLogToDisk) { | |
| 311 return; | |
| 312 } | |
| 313 mStopNetLogCompleted = new ConditionVariable(); | 302 mStopNetLogCompleted = new ConditionVariable(); |
| 314 } | 303 } |
| 315 mStopNetLogCompleted.block(); | 304 mStopNetLogCompleted.block(); |
| 316 } | 305 } |
| 317 | 306 |
| 318 @CalledByNative | 307 @CalledByNative |
| 319 public void stopNetLogCompleted() { | 308 public void stopNetLogCompleted() { |
| 320 synchronized (mLock) { | |
| 321 mNetLogToDisk = false; | |
| 322 } | |
| 323 mStopNetLogCompleted.open(); | 309 mStopNetLogCompleted.open(); |
| 324 } | 310 } |
| 325 | 311 |
| 326 @Override | 312 @Override |
| 327 public String getCertVerifierData(long timeout) { | 313 public String getCertVerifierData(long timeout) { |
| 328 if (timeout < 0) { | 314 if (timeout < 0) { |
| 329 throw new IllegalArgumentException("timeout must be a positive value
"); | 315 throw new IllegalArgumentException("timeout must be a positive value
"); |
| 330 } else if (timeout == 0) { | 316 } else if (timeout == 0) { |
| 331 timeout = 100; | 317 timeout = 100; |
| 332 } | 318 } |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 725 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
| 740 private native void nativeProvideRTTObservations(long nativePtr, boolean sho
uld); | 726 private native void nativeProvideRTTObservations(long nativePtr, boolean sho
uld); |
| 741 | 727 |
| 742 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 728 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
| 743 private native void nativeProvideThroughputObservations(long nativePtr, bool
ean should); | 729 private native void nativeProvideThroughputObservations(long nativePtr, bool
ean should); |
| 744 | 730 |
| 745 public boolean isNetworkThread(Thread thread) { | 731 public boolean isNetworkThread(Thread thread) { |
| 746 return thread == mNetworkThread; | 732 return thread == mNetworkThread; |
| 747 } | 733 } |
| 748 } | 734 } |
| OLD | NEW |