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

Side by Side Diff: components/cronet/android/java/src/org/chromium/net/impl/CronetUrlRequestContext.java

Issue 2751113004: Revert of [Cronet] Write effective experimental options to NetLog (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
OLDNEW
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
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
151 @UsedByReflection("CronetEngine.java") 158 @UsedByReflection("CronetEngine.java")
152 public CronetUrlRequestContext(final CronetEngineBuilderImpl builder) { 159 public CronetUrlRequestContext(final CronetEngineBuilderImpl builder) {
153 CronetLibraryLoader.ensureInitialized(builder.getContext(), builder); 160 CronetLibraryLoader.ensureInitialized(builder.getContext(), builder);
154 nativeSetMinLogLevel(getLoggingLevel()); 161 nativeSetMinLogLevel(getLoggingLevel());
155 synchronized (mLock) { 162 synchronized (mLock) {
156 mUrlRequestContextAdapter = 163 mUrlRequestContextAdapter =
157 nativeCreateRequestContextAdapter(createNativeUrlRequestCont extConfig(builder)); 164 nativeCreateRequestContextAdapter(createNativeUrlRequestCont extConfig(builder));
158 if (mUrlRequestContextAdapter == 0) { 165 if (mUrlRequestContextAdapter == 0) {
159 throw new NullPointerException("Context Adapter creation failed. "); 166 throw new NullPointerException("Context Adapter creation failed. ");
160 } 167 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 mIsLogging = true; 287 mIsLogging = true;
281 } 288 }
282 } 289 }
283 290
284 @Override 291 @Override
285 public void startNetLogToDisk(String dirPath, boolean logAll, int maxSize) { 292 public void startNetLogToDisk(String dirPath, boolean logAll, int maxSize) {
286 synchronized (mLock) { 293 synchronized (mLock) {
287 checkHaveAdapter(); 294 checkHaveAdapter();
288 nativeStartNetLogToDisk(mUrlRequestContextAdapter, dirPath, logAll, maxSize); 295 nativeStartNetLogToDisk(mUrlRequestContextAdapter, dirPath, logAll, maxSize);
289 mIsLogging = true; 296 mIsLogging = true;
297 mNetLogToDisk = true;
290 } 298 }
291 } 299 }
292 300
293 @Override 301 @Override
294 public void stopNetLog() { 302 public void stopNetLog() {
295 synchronized (mLock) { 303 synchronized (mLock) {
296 if (!mIsLogging) { 304 if (!mIsLogging) {
297 return; 305 return;
298 } 306 }
299 checkHaveAdapter(); 307 checkHaveAdapter();
300 nativeStopNetLog(mUrlRequestContextAdapter); 308 nativeStopNetLog(mUrlRequestContextAdapter);
301 mIsLogging = false; 309 mIsLogging = false;
310 if (!mNetLogToDisk) {
311 return;
312 }
302 mStopNetLogCompleted = new ConditionVariable(); 313 mStopNetLogCompleted = new ConditionVariable();
303 } 314 }
304 mStopNetLogCompleted.block(); 315 mStopNetLogCompleted.block();
305 } 316 }
306 317
307 @CalledByNative 318 @CalledByNative
308 public void stopNetLogCompleted() { 319 public void stopNetLogCompleted() {
320 synchronized (mLock) {
321 mNetLogToDisk = false;
322 }
309 mStopNetLogCompleted.open(); 323 mStopNetLogCompleted.open();
310 } 324 }
311 325
312 @Override 326 @Override
313 public String getCertVerifierData(long timeout) { 327 public String getCertVerifierData(long timeout) {
314 if (timeout < 0) { 328 if (timeout < 0) {
315 throw new IllegalArgumentException("timeout must be a positive value "); 329 throw new IllegalArgumentException("timeout must be a positive value ");
316 } else if (timeout == 0) { 330 } else if (timeout == 0) {
317 timeout = 100; 331 timeout = 100;
318 } 332 }
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 @NativeClassQualifiedName("CronetURLRequestContextAdapter") 739 @NativeClassQualifiedName("CronetURLRequestContextAdapter")
726 private native void nativeProvideRTTObservations(long nativePtr, boolean sho uld); 740 private native void nativeProvideRTTObservations(long nativePtr, boolean sho uld);
727 741
728 @NativeClassQualifiedName("CronetURLRequestContextAdapter") 742 @NativeClassQualifiedName("CronetURLRequestContextAdapter")
729 private native void nativeProvideThroughputObservations(long nativePtr, bool ean should); 743 private native void nativeProvideThroughputObservations(long nativePtr, bool ean should);
730 744
731 public boolean isNetworkThread(Thread thread) { 745 public boolean isNetworkThread(Thread thread) {
732 return thread == mNetworkThread; 746 return thread == mNetworkThread;
733 } 747 }
734 } 748 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698