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

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

Issue 981013002: [Cronet] Make sure to only pass the application Context to InitApplicationContext to avoid DCHECK fa (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add ChromiumUrlRequestContext test too Created 5 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
« no previous file with comments | « components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.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; 5 package org.chromium.net;
6 6
7 import android.app.Activity; 7 import android.app.Activity;
8 import android.content.Intent; 8 import android.content.Intent;
9 import android.os.Bundle; 9 import android.os.Bundle;
10 import android.os.Environment; 10 import android.os.Environment;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 @Override 68 @Override
69 protected void onCreate(final Bundle savedInstanceState) { 69 protected void onCreate(final Bundle savedInstanceState) {
70 super.onCreate(savedInstanceState); 70 super.onCreate(savedInstanceState);
71 71
72 String initString = getCommandLineArg(LIBRARY_INIT_KEY); 72 String initString = getCommandLineArg(LIBRARY_INIT_KEY);
73 if (LIBRARY_INIT_SKIP.equals(initString)) { 73 if (LIBRARY_INIT_SKIP.equals(initString)) {
74 return; 74 return;
75 } 75 }
76 76
77 mUrlRequestContext = initRequestContext(); 77 mUrlRequestContext = initRequestContext();
78 mStreamHandlerFactory = new CronetURLStreamHandlerFactory( 78 mStreamHandlerFactory = new CronetURLStreamHandlerFactory(this, getConte xtConfig());
79 getApplicationContext(), getContextConfig());
80 mHistogramManager = HistogramManager.createHistogramManager(); 79 mHistogramManager = HistogramManager.createHistogramManager();
81 80
82 if (LIBRARY_INIT_CRONET_ONLY.equals(initString)) { 81 if (LIBRARY_INIT_CRONET_ONLY.equals(initString)) {
83 return; 82 return;
84 } 83 }
85 84
86 mRequestFactory = initRequestFactory(); 85 mRequestFactory = initRequestFactory();
87 String appUrl = getUrlFromIntent(getIntent()); 86 String appUrl = getUrlFromIntent(getIntent());
88 if (appUrl != null) { 87 if (appUrl != null) {
89 startWithURL(appUrl); 88 startWithURL(appUrl);
(...skipping 20 matching lines...) Expand all
110 } 109 }
111 } 110 }
112 111
113 // Setting this here so it isn't overridden on the command line 112 // Setting this here so it isn't overridden on the command line
114 config.setLibraryName("cronet_tests"); 113 config.setLibraryName("cronet_tests");
115 return config; 114 return config;
116 } 115 }
117 116
118 // Helper function to initialize request context. Also used in testing. 117 // Helper function to initialize request context. Also used in testing.
119 public UrlRequestContext initRequestContext() { 118 public UrlRequestContext initRequestContext() {
120 return UrlRequestContext.createContext(getApplicationContext(), getConte xtConfig()); 119 return UrlRequestContext.createContext(this, getContextConfig());
121 } 120 }
122 121
123 // Helper function to initialize request factory. Also used in testing. 122 // Helper function to initialize request factory. Also used in testing.
124 public HttpUrlRequestFactory initRequestFactory() { 123 public HttpUrlRequestFactory initRequestFactory() {
125 return HttpUrlRequestFactory.createFactory(getApplicationContext(), getC ontextConfig()); 124 return HttpUrlRequestFactory.createFactory(this, getContextConfig());
126 } 125 }
127 126
128 private static String getUrlFromIntent(Intent intent) { 127 private static String getUrlFromIntent(Intent intent) {
129 return intent != null ? intent.getDataString() : null; 128 return intent != null ? intent.getDataString() : null;
130 } 129 }
131 130
132 private String getCommandLineArg(String key) { 131 private String getCommandLineArg(String key) {
133 Intent intent = getIntent(); 132 Intent intent = getIntent();
134 Bundle extras = intent.getExtras(); 133 Bundle extras = intent.getExtras();
135 Log.i(TAG, "Cronet extras: " + extras); 134 Log.i(TAG, "Cronet extras: " + extras);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 public void startNetLog() { 187 public void startNetLog() {
189 mRequestFactory.startNetLogToFile( 188 mRequestFactory.startNetLogToFile(
190 Environment.getExternalStorageDirectory().getPath() 189 Environment.getExternalStorageDirectory().getPath()
191 + "/cronet_sample_netlog.json"); 190 + "/cronet_sample_netlog.json");
192 } 191 }
193 192
194 public void stopNetLog() { 193 public void stopNetLog() {
195 mRequestFactory.stopNetLog(); 194 mRequestFactory.stopNetLog();
196 } 195 }
197 } 196 }
OLDNEW
« no previous file with comments | « components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698