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

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

Issue 2805743003: Allow posting the CronetEngine UI Thread initialization on a custom Ui executor instead of the defa… (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « components/cronet/android/java/src/org/chromium/net/impl/CronetLibraryLoader.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 // initialization on main and network threads completes and 171 // initialization on main and network threads completes and
172 // initNetworkThread is called back on network thread. 172 // initNetworkThread is called back on network thread.
173 nativeInitRequestContextOnMainThread(mUrlRequestContextAdapt er); 173 nativeInitRequestContextOnMainThread(mUrlRequestContextAdapt er);
174 } 174 }
175 } 175 }
176 }; 176 };
177 // Run task immediately or post it to the UI thread. 177 // Run task immediately or post it to the UI thread.
178 if (Looper.getMainLooper() == Looper.myLooper()) { 178 if (Looper.getMainLooper() == Looper.myLooper()) {
179 task.run(); 179 task.run();
180 } else { 180 } else {
181 new Handler(Looper.getMainLooper()).post(task); 181 if (builder.uiExecutor() != null) {
182 builder.uiExecutor().execute(task);
183 } else {
184 new Handler(Looper.getMainLooper()).post(task);
185 }
182 } 186 }
183 } 187 }
184 188
185 @VisibleForTesting 189 @VisibleForTesting
186 public static long createNativeUrlRequestContextConfig(CronetEngineBuilderIm pl builder) { 190 public static long createNativeUrlRequestContextConfig(CronetEngineBuilderIm pl builder) {
187 final long urlRequestContextConfig = nativeCreateRequestContextConfig( 191 final long urlRequestContextConfig = nativeCreateRequestContextConfig(
188 builder.getUserAgent(), builder.storagePath(), builder.quicEnabl ed(), 192 builder.getUserAgent(), builder.storagePath(), builder.quicEnabl ed(),
189 builder.getDefaultQuicUserAgentId(), builder.http2Enabled(), bui lder.sdchEnabled(), 193 builder.getDefaultQuicUserAgentId(), builder.http2Enabled(), bui lder.sdchEnabled(),
190 builder.dataReductionProxyKey(), builder.dataReductionProxyPrima ryProxy(), 194 builder.dataReductionProxyKey(), builder.dataReductionProxyPrima ryProxy(),
191 builder.dataReductionProxyFallbackProxy(), 195 builder.dataReductionProxyFallbackProxy(),
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 @NativeClassQualifiedName("CronetURLRequestContextAdapter") 729 @NativeClassQualifiedName("CronetURLRequestContextAdapter")
726 private native void nativeProvideRTTObservations(long nativePtr, boolean sho uld); 730 private native void nativeProvideRTTObservations(long nativePtr, boolean sho uld);
727 731
728 @NativeClassQualifiedName("CronetURLRequestContextAdapter") 732 @NativeClassQualifiedName("CronetURLRequestContextAdapter")
729 private native void nativeProvideThroughputObservations(long nativePtr, bool ean should); 733 private native void nativeProvideThroughputObservations(long nativePtr, bool ean should);
730 734
731 public boolean isNetworkThread(Thread thread) { 735 public boolean isNetworkThread(Thread thread) {
732 return thread == mNetworkThread; 736 return thread == mNetworkThread;
733 } 737 }
734 } 738 }
OLDNEW
« no previous file with comments | « components/cronet/android/java/src/org/chromium/net/impl/CronetLibraryLoader.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698