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

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

Issue 617393005: Make URLRequestContextAdapter initialization asynchronous (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 6 years, 2 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 | « no previous file | components/cronet/android/url_request_adapter.cc » ('j') | 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; 5 package org.chromium.net;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.os.ConditionVariable; 8 import android.os.ConditionVariable;
9 import android.os.Process; 9 import android.os.Process;
10 import android.util.Log; 10 import android.util.Log;
(...skipping 19 matching lines...) Expand all
30 private final ConditionVariable mStarted = new ConditionVariable(); 30 private final ConditionVariable mStarted = new ConditionVariable();
31 31
32 /** 32 /**
33 * Constructor. 33 * Constructor.
34 * 34 *
35 */ 35 */
36 protected ChromiumUrlRequestContext(Context context, String userAgent, 36 protected ChromiumUrlRequestContext(Context context, String userAgent,
37 String config) { 37 String config) {
38 mChromiumUrlRequestContextAdapter = nativeCreateRequestContextAdapter( 38 mChromiumUrlRequestContextAdapter = nativeCreateRequestContextAdapter(
39 context, userAgent, getLoggingLevel(), config); 39 context, userAgent, getLoggingLevel(), config);
40 if (mChromiumUrlRequestContextAdapter == 0) 40 if (mChromiumUrlRequestContextAdapter == 0) {
41 throw new NullPointerException("Context Adapter creation failed"); 41 throw new NullPointerException("Context Adapter creation failed");
42 42 }
43 // TODO(mef): Revisit the need of block here.
44 mStarted.block(2000);
45 } 43 }
46 44
47 /** 45 /**
48 * Returns the version of this network stack formatted as N.N.N.N/X where 46 * Returns the version of this network stack formatted as N.N.N.N/X where
49 * N.N.N.N is the version of Chromium and X is the revision number. 47 * N.N.N.N is the version of Chromium and X is the revision number.
50 */ 48 */
51 public static String getVersion() { 49 public static String getVersion() {
52 return Version.getVersion(); 50 return Version.getVersion();
53 } 51 }
54 52
(...skipping 28 matching lines...) Expand all
83 * not in progress this call is ignored. 81 * not in progress this call is ignored.
84 */ 82 */
85 public void stopNetLog() { 83 public void stopNetLog() {
86 nativeStopNetLog(mChromiumUrlRequestContextAdapter); 84 nativeStopNetLog(mChromiumUrlRequestContextAdapter);
87 } 85 }
88 86
89 @CalledByNative 87 @CalledByNative
90 private void initNetworkThread() { 88 private void initNetworkThread() {
91 Thread.currentThread().setName("ChromiumNet"); 89 Thread.currentThread().setName("ChromiumNet");
92 Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); 90 Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
93 mStarted.open(); 91 mStarted.open();
xunjieli 2014/10/02 21:52:28 I should probably get rid of mStarted completely,
94 } 92 }
95 93
96 @Override 94 @Override
97 protected void finalize() throws Throwable { 95 protected void finalize() throws Throwable {
98 nativeReleaseRequestContextAdapter(mChromiumUrlRequestContextAdapter); 96 nativeReleaseRequestContextAdapter(mChromiumUrlRequestContextAdapter);
99 super.finalize(); 97 super.finalize();
100 } 98 }
101 99
102 protected long getChromiumUrlRequestContextAdapter() { 100 protected long getChromiumUrlRequestContextAdapter() {
103 return mChromiumUrlRequestContextAdapter; 101 return mChromiumUrlRequestContextAdapter;
(...skipping 25 matching lines...) Expand all
129 127
130 private native void nativeInitializeStatistics(); 128 private native void nativeInitializeStatistics();
131 129
132 private native String nativeGetStatisticsJSON(String filter); 130 private native String nativeGetStatisticsJSON(String filter);
133 131
134 private native void nativeStartNetLogToFile( 132 private native void nativeStartNetLogToFile(
135 long chromiumUrlRequestContextAdapter, String fileName); 133 long chromiumUrlRequestContextAdapter, String fileName);
136 134
137 private native void nativeStopNetLog(long chromiumUrlRequestContextAdapter); 135 private native void nativeStopNetLog(long chromiumUrlRequestContextAdapter);
138 } 136 }
OLDNEW
« no previous file with comments | « no previous file | components/cronet/android/url_request_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698