| OLD | NEW |
| 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 | 4 |
| 5 #import <Cronet/Cronet.h> | 5 #import <Cronet/Cronet.h> |
| 6 #import <Foundation/Foundation.h> | 6 #import <Foundation/Foundation.h> |
| 7 | 7 |
| 8 #include "components/cronet/ios/test/start_cronet.h" | 8 #include "components/cronet/ios/test/start_cronet.h" |
| 9 | 9 |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| 11 #include "base/strings/sys_string_conversions.h" | 11 #include "base/strings/sys_string_conversions.h" |
| 12 #include "components/grpc_support/test/quic_test_server.h" | 12 #include "components/grpc_support/test/quic_test_server.h" |
| 13 | 13 |
| 14 namespace cronet { | 14 namespace cronet { |
| 15 | 15 |
| 16 void StartCronetIfNecessary(int port) { | 16 void StartCronet(int port) { |
| 17 static bool initialized = false; | 17 [Cronet setUserAgent:@"CronetTest/1.0.0.0" partial:NO]; |
| 18 if (!initialized) { | 18 [Cronet setHttp2Enabled:true]; |
| 19 initialized = true; | 19 [Cronet setQuicEnabled:true]; |
| 20 [Cronet setUserAgent:@"CronetTest/1.0.0.0" partial:NO]; | 20 [Cronet setAcceptLanguages:@"en-US,en"]; |
| 21 [Cronet setHttp2Enabled:true]; | 21 [Cronet |
| 22 [Cronet setQuicEnabled:true]; | 22 setExperimentalOptions: |
| 23 [Cronet setAcceptLanguages:@"en-US,en"]; | 23 [NSString |
| 24 [Cronet | 24 stringWithFormat:@"{\"ssl_key_log_file\":\"%@\"}", |
| 25 setExperimentalOptions: | 25 [Cronet getNetLogPathForFile:@"SSLKEYLOGFILE"]]]; |
| 26 [NSString | 26 [Cronet addQuicHint:@"test.example.com" port:443 altPort:443]; |
| 27 stringWithFormat:@"{\"ssl_key_log_file\":\"%@\"}", | 27 [Cronet enableTestCertVerifierForTesting]; |
| 28 [Cronet | 28 [Cronet setHttpCacheType:CRNHttpCacheTypeDisabled]; |
| 29 getNetLogPathForFile:@"SSLKEYLOGFILE"]]]; | 29 |
| 30 [Cronet addQuicHint:@"test.example.com" port:443 altPort:443]; | 30 [Cronet start]; |
| 31 [Cronet enableTestCertVerifierForTesting]; | 31 |
| 32 [Cronet setHttpCacheType:CRNHttpCacheTypeDisabled]; | |
| 33 [Cronet start]; | |
| 34 } | |
| 35 NSString* rules = base::SysUTF8ToNSString( | 32 NSString* rules = base::SysUTF8ToNSString( |
| 36 base::StringPrintf("MAP test.example.com 127.0.0.1:%d," | 33 base::StringPrintf("MAP test.example.com 127.0.0.1:%d," |
| 37 "MAP notfound.example.com ~NOTFOUND", | 34 "MAP notfound.example.com ~NOTFOUND", |
| 38 port)); | 35 port)); |
| 39 [Cronet setHostResolverRulesForTesting:rules]; | 36 [Cronet setHostResolverRulesForTesting:rules]; |
| 40 } | 37 } |
| 41 | 38 |
| 42 } // namespace cronet | 39 } // namespace cronet |
| OLD | NEW |