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

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

Issue 1133883002: [Cronet] Enable persistence mode for Sdch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@quic_server_remove_loop
Patch Set: Created 5 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 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 18 matching lines...) Expand all
29 * Activity for managing the Cronet Test. 29 * Activity for managing the Cronet Test.
30 */ 30 */
31 @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 31 @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
32 public class CronetTestActivity extends Activity { 32 public class CronetTestActivity extends Activity {
33 private static final String TAG = "CronetTestActivity"; 33 private static final String TAG = "CronetTestActivity";
34 34
35 public static final String COMMAND_LINE_ARGS_KEY = "commandLineArgs"; 35 public static final String COMMAND_LINE_ARGS_KEY = "commandLineArgs";
36 public static final String POST_DATA_KEY = "postData"; 36 public static final String POST_DATA_KEY = "postData";
37 public static final String CONFIG_KEY = "config"; 37 public static final String CONFIG_KEY = "config";
38 public static final String CACHE_KEY = "cache"; 38 public static final String CACHE_KEY = "cache";
39 public static final String SDCH_KEY = "sdch";
40
39 public static final String LIBRARY_INIT_KEY = "libraryInit"; 41 public static final String LIBRARY_INIT_KEY = "libraryInit";
40 /** 42 /**
41 * Skips library initialization. 43 * Skips library initialization.
42 */ 44 */
43 public static final String LIBRARY_INIT_SKIP = "skip"; 45 public static final String LIBRARY_INIT_SKIP = "skip";
44 46
45 // Uses disk cache. 47 // Uses disk cache.
46 public static final String CACHE_DISK = "disk"; 48 public static final String CACHE_DISK = "disk";
47 49
48 // Uses disk cache but does not store http data. 50 // Uses disk cache but does not store http data.
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 * Prepares the path for the test storage (http cache, QUIC server info). 145 * Prepares the path for the test storage (http cache, QUIC server info).
144 */ 146 */
145 private void prepareTestStorage() { 147 private void prepareTestStorage() {
146 File storage = new File(getTestStorage()); 148 File storage = new File(getTestStorage());
147 if (storage.exists()) { 149 if (storage.exists()) {
148 assertTrue(recursiveDelete(storage)); 150 assertTrue(recursiveDelete(storage));
149 } 151 }
150 assertTrue(storage.mkdir()); 152 assertTrue(storage.mkdir());
151 } 153 }
152 154
153 private String getTestStorage() { 155 String getTestStorage() {
154 return PathUtils.getDataDirectory(getApplicationContext()) + "/test_stor age"; 156 return PathUtils.getDataDirectory(getApplicationContext()) + "/test_stor age";
155 } 157 }
156 158
157 private boolean recursiveDelete(File path) { 159 private boolean recursiveDelete(File path) {
158 if (path.isDirectory()) { 160 if (path.isDirectory()) {
159 for (File c : path.listFiles()) { 161 for (File c : path.listFiles()) {
160 if (!recursiveDelete(c)) { 162 if (!recursiveDelete(c)) {
161 return false; 163 return false;
162 } 164 }
163 } 165 }
(...skipping 25 matching lines...) Expand all
189 if (CACHE_DISK.equals(cacheString)) { 191 if (CACHE_DISK.equals(cacheString)) {
190 config.setStoragePath(getTestStorage()); 192 config.setStoragePath(getTestStorage());
191 config.enableHttpCache(UrlRequestContextConfig.HttpCache.DISK, 1000 * 1024); 193 config.enableHttpCache(UrlRequestContextConfig.HttpCache.DISK, 1000 * 1024);
192 } else if (CACHE_DISK_NO_HTTP.equals(cacheString)) { 194 } else if (CACHE_DISK_NO_HTTP.equals(cacheString)) {
193 config.setStoragePath(getTestStorage()); 195 config.setStoragePath(getTestStorage());
194 config.enableHttpCache(UrlRequestContextConfig.HttpCache.DISK_NO_HTT P, 1000 * 1024); 196 config.enableHttpCache(UrlRequestContextConfig.HttpCache.DISK_NO_HTT P, 1000 * 1024);
195 } else if (CACHE_IN_MEMORY.equals(cacheString)) { 197 } else if (CACHE_IN_MEMORY.equals(cacheString)) {
196 config.enableHttpCache(UrlRequestContextConfig.HttpCache.IN_MEMORY, 100 * 1024); 198 config.enableHttpCache(UrlRequestContextConfig.HttpCache.IN_MEMORY, 100 * 1024);
197 } 199 }
198 200
201 String sdchString = getCommandLineArg(SDCH_KEY);
202 if (sdchString != null) {
203 config.enableSDCH(true);
204 }
205
199 // Setting this here so it isn't overridden on the command line 206 // Setting this here so it isn't overridden on the command line
200 config.setLibraryName("cronet_tests"); 207 config.setLibraryName("cronet_tests");
201 return config; 208 return config;
202 } 209 }
203 210
204 // Helper function to initialize request context. Also used in testing. 211 // Helper function to initialize request context. Also used in testing.
205 public UrlRequestContext initRequestContext() { 212 public UrlRequestContext initRequestContext() {
206 return UrlRequestContext.createContext(this, mConfig); 213 return UrlRequestContext.createContext(this, mConfig);
207 } 214 }
208 215
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 290
284 public void stopNetLog() { 291 public void stopNetLog() {
285 if (mRequestFactory != null) { 292 if (mRequestFactory != null) {
286 mRequestFactory.stopNetLog(); 293 mRequestFactory.stopNetLog();
287 } 294 }
288 if (mUrlRequestContext != null) { 295 if (mUrlRequestContext != null) {
289 mUrlRequestContext.stopNetLog(); 296 mUrlRequestContext.stopNetLog();
290 } 297 }
291 } 298 }
292 } 299 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698