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

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: Address Misha's comments Created 5 years, 6 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.
49 public static final String CACHE_DISK_NO_HTTP = "diskNoHttp"; 51 public static final String CACHE_DISK_NO_HTTP = "diskNoHttp";
50 52
51 // Uses in-memory cache. 53 // Uses in-memory cache.
52 public static final String CACHE_IN_MEMORY = "memory"; 54 public static final String CACHE_IN_MEMORY = "memory";
53 55
56 // Enables Sdch.
57 public static final String SDCH_ENABLE = "enable";
58
54 /** 59 /**
55 * Initializes Cronet Async API only. 60 * Initializes Cronet Async API only.
56 */ 61 */
57 public static final String LIBRARY_INIT_CRONET_ONLY = "cronetOnly"; 62 public static final String LIBRARY_INIT_CRONET_ONLY = "cronetOnly";
58 63
59 /** 64 /**
60 * Initializes Cronet HttpURLConnection Wrapper API. 65 * Initializes Cronet HttpURLConnection Wrapper API.
61 */ 66 */
62 public static final String LIBRARY_INIT_WRAPPER = "wrapperOnly"; 67 public static final String LIBRARY_INIT_WRAPPER = "wrapperOnly";
63 68
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 * Prepares the path for the test storage (http cache, QUIC server info). 148 * Prepares the path for the test storage (http cache, QUIC server info).
144 */ 149 */
145 private void prepareTestStorage() { 150 private void prepareTestStorage() {
146 File storage = new File(getTestStorage()); 151 File storage = new File(getTestStorage());
147 if (storage.exists()) { 152 if (storage.exists()) {
148 assertTrue(recursiveDelete(storage)); 153 assertTrue(recursiveDelete(storage));
149 } 154 }
150 assertTrue(storage.mkdir()); 155 assertTrue(storage.mkdir());
151 } 156 }
152 157
153 private String getTestStorage() { 158 String getTestStorage() {
154 return PathUtils.getDataDirectory(getApplicationContext()) + "/test_stor age"; 159 return PathUtils.getDataDirectory(getApplicationContext()) + "/test_stor age";
155 } 160 }
156 161
157 private boolean recursiveDelete(File path) { 162 private boolean recursiveDelete(File path) {
158 if (path.isDirectory()) { 163 if (path.isDirectory()) {
159 for (File c : path.listFiles()) { 164 for (File c : path.listFiles()) {
160 if (!recursiveDelete(c)) { 165 if (!recursiveDelete(c)) {
161 return false; 166 return false;
162 } 167 }
163 } 168 }
(...skipping 25 matching lines...) Expand all
189 if (CACHE_DISK.equals(cacheString)) { 194 if (CACHE_DISK.equals(cacheString)) {
190 config.setStoragePath(getTestStorage()); 195 config.setStoragePath(getTestStorage());
191 config.enableHttpCache(UrlRequestContextConfig.HttpCache.DISK, 1000 * 1024); 196 config.enableHttpCache(UrlRequestContextConfig.HttpCache.DISK, 1000 * 1024);
192 } else if (CACHE_DISK_NO_HTTP.equals(cacheString)) { 197 } else if (CACHE_DISK_NO_HTTP.equals(cacheString)) {
193 config.setStoragePath(getTestStorage()); 198 config.setStoragePath(getTestStorage());
194 config.enableHttpCache(UrlRequestContextConfig.HttpCache.DISK_NO_HTT P, 1000 * 1024); 199 config.enableHttpCache(UrlRequestContextConfig.HttpCache.DISK_NO_HTT P, 1000 * 1024);
195 } else if (CACHE_IN_MEMORY.equals(cacheString)) { 200 } else if (CACHE_IN_MEMORY.equals(cacheString)) {
196 config.enableHttpCache(UrlRequestContextConfig.HttpCache.IN_MEMORY, 100 * 1024); 201 config.enableHttpCache(UrlRequestContextConfig.HttpCache.IN_MEMORY, 100 * 1024);
197 } 202 }
198 203
204 String sdchString = getCommandLineArg(SDCH_KEY);
205 if (SDCH_ENABLE.equals(sdchString)) {
206 config.enableSDCH(true);
207 }
208
199 // Setting this here so it isn't overridden on the command line 209 // Setting this here so it isn't overridden on the command line
200 config.setLibraryName("cronet_tests"); 210 config.setLibraryName("cronet_tests");
201 return config; 211 return config;
202 } 212 }
203 213
204 // Helper function to initialize request context. Also used in testing. 214 // Helper function to initialize request context. Also used in testing.
205 public UrlRequestContext initRequestContext() { 215 public UrlRequestContext initRequestContext() {
206 return UrlRequestContext.createContext(this, mConfig); 216 return UrlRequestContext.createContext(this, mConfig);
207 } 217 }
208 218
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 293
284 public void stopNetLog() { 294 public void stopNetLog() {
285 if (mRequestFactory != null) { 295 if (mRequestFactory != null) {
286 mRequestFactory.stopNetLog(); 296 mRequestFactory.stopNetLog();
287 } 297 }
288 if (mUrlRequestContext != null) { 298 if (mUrlRequestContext != null) {
289 mUrlRequestContext.stopNetLog(); 299 mUrlRequestContext.stopNetLog();
290 } 300 }
291 } 301 }
292 } 302 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698