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

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

Issue 2876253002: [Cronet] Add ExperimentalCronetEngine.Builder.setThreadPriority() API (Closed)
Patch Set: tweaks Created 3 years, 7 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 package org.chromium.net.impl; 4 package org.chromium.net.impl;
5 5
6 import static android.os.Process.THREAD_PRIORITY_LOWEST;
7
6 import android.content.Context; 8 import android.content.Context;
7 import android.support.annotation.IntDef; 9 import android.support.annotation.IntDef;
8 import android.support.annotation.VisibleForTesting; 10 import android.support.annotation.VisibleForTesting;
9 11
10 import static org.chromium.net.CronetEngine.Builder.HTTP_CACHE_DISABLED; 12 import static org.chromium.net.CronetEngine.Builder.HTTP_CACHE_DISABLED;
11 import static org.chromium.net.CronetEngine.Builder.HTTP_CACHE_DISK; 13 import static org.chromium.net.CronetEngine.Builder.HTTP_CACHE_DISK;
12 import static org.chromium.net.CronetEngine.Builder.HTTP_CACHE_DISK_NO_HTTP; 14 import static org.chromium.net.CronetEngine.Builder.HTTP_CACHE_DISK_NO_HTTP;
13 import static org.chromium.net.CronetEngine.Builder.HTTP_CACHE_IN_MEMORY; 15 import static org.chromium.net.CronetEngine.Builder.HTTP_CACHE_IN_MEMORY;
14 16
15 import org.chromium.net.CronetEngine; 17 import org.chromium.net.CronetEngine;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 Pkp(String host, byte[][] hashes, boolean includeSubdomains, Date expira tionDate) { 66 Pkp(String host, byte[][] hashes, boolean includeSubdomains, Date expira tionDate) {
65 mHost = host; 67 mHost = host;
66 mHashes = hashes; 68 mHashes = hashes;
67 mIncludeSubdomains = includeSubdomains; 69 mIncludeSubdomains = includeSubdomains;
68 mExpirationDate = expirationDate; 70 mExpirationDate = expirationDate;
69 } 71 }
70 } 72 }
71 73
72 private static final Pattern INVALID_PKP_HOST_NAME = Pattern.compile("^[0-9\ \.]*$"); 74 private static final Pattern INVALID_PKP_HOST_NAME = Pattern.compile("^[0-9\ \.]*$");
73 75
76 private static final int INVALID_THREAD_PRIORITY = THREAD_PRIORITY_LOWEST + 1;
77
74 // Private fields are simply storage of configuration for the resulting Cron etEngine. 78 // Private fields are simply storage of configuration for the resulting Cron etEngine.
75 // See setters below for verbose descriptions. 79 // See setters below for verbose descriptions.
76 private final Context mApplicationContext; 80 private final Context mApplicationContext;
77 private final List<QuicHint> mQuicHints = new LinkedList<>(); 81 private final List<QuicHint> mQuicHints = new LinkedList<>();
78 private final List<Pkp> mPkps = new LinkedList<>(); 82 private final List<Pkp> mPkps = new LinkedList<>();
79 private boolean mPublicKeyPinningBypassForLocalTrustAnchorsEnabled; 83 private boolean mPublicKeyPinningBypassForLocalTrustAnchorsEnabled;
80 private String mUserAgent; 84 private String mUserAgent;
81 private String mStoragePath; 85 private String mStoragePath;
82 private VersionSafeCallbacks.LibraryLoader mLibraryLoader; 86 private VersionSafeCallbacks.LibraryLoader mLibraryLoader;
83 private boolean mQuicEnabled; 87 private boolean mQuicEnabled;
84 private boolean mHttp2Enabled; 88 private boolean mHttp2Enabled;
85 private boolean mSdchEnabled; 89 private boolean mSdchEnabled;
86 private boolean mBrotiEnabled; 90 private boolean mBrotiEnabled;
87 private boolean mDisableCache; 91 private boolean mDisableCache;
88 private int mHttpCacheMode; 92 private int mHttpCacheMode;
89 private long mHttpCacheMaxSize; 93 private long mHttpCacheMaxSize;
90 private String mExperimentalOptions; 94 private String mExperimentalOptions;
91 protected long mMockCertVerifier; 95 protected long mMockCertVerifier;
92 private boolean mNetworkQualityEstimatorEnabled; 96 private boolean mNetworkQualityEstimatorEnabled;
93 private String mCertVerifierData; 97 private String mCertVerifierData;
98 private int mThreadPriority = INVALID_THREAD_PRIORITY;
94 99
95 /** 100 /**
96 * Default config enables SPDY, disables QUIC, SDCH and HTTP cache. 101 * Default config enables SPDY, disables QUIC, SDCH and HTTP cache.
97 * @param context Android {@link Context} for engine to use. 102 * @param context Android {@link Context} for engine to use.
98 */ 103 */
99 public CronetEngineBuilderImpl(Context context) { 104 public CronetEngineBuilderImpl(Context context) {
100 mApplicationContext = context.getApplicationContext(); 105 mApplicationContext = context.getApplicationContext();
101 enableQuic(false); 106 enableQuic(false);
102 enableHttp2(true); 107 enableHttp2(true);
103 enableSdch(false); 108 enableSdch(false);
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 @Override 385 @Override
381 public CronetEngineBuilderImpl enableNetworkQualityEstimator(boolean value) { 386 public CronetEngineBuilderImpl enableNetworkQualityEstimator(boolean value) {
382 mNetworkQualityEstimatorEnabled = value; 387 mNetworkQualityEstimatorEnabled = value;
383 return this; 388 return this;
384 } 389 }
385 390
386 String certVerifierData() { 391 String certVerifierData() {
387 return mCertVerifierData; 392 return mCertVerifierData;
388 } 393 }
389 394
395 @Override
396 public CronetEngineBuilderImpl setThreadPriority(int priority) {
397 if (priority > THREAD_PRIORITY_LOWEST || priority < -20) {
398 throw new IllegalArgumentException("Thread priority invalid");
399 }
400 mThreadPriority = priority;
401 return this;
402 }
403
404 /**
405 * @returns thread priority provided by user, or {@code defaultThreadPriorit y} if none provided.
406 */
407 int threadPriority(int defaultThreadPriority) {
408 return mThreadPriority == INVALID_THREAD_PRIORITY ? defaultThreadPriorit y : mThreadPriority;
mef 2017/05/15 17:20:11 can we just default |mThreadPriority| to sensible
pauljensen 2017/05/15 19:03:25 I feel that could have significant impact on perfo
mef 2017/05/16 15:51:29 Sounds good, it makes sense to experiment.
409 }
410
390 /** 411 /**
391 * Returns {@link Context} for builder. 412 * Returns {@link Context} for builder.
392 * 413 *
393 * @return {@link Context} for builder. 414 * @return {@link Context} for builder.
394 */ 415 */
395 Context getContext() { 416 Context getContext() {
396 return mApplicationContext; 417 return mApplicationContext;
397 } 418 }
398 } 419 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698