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

Side by Side Diff: components/cronet/ios/Cronet.mm

Issue 2760073002: [cronet] Expose API to set experimental options (Closed)
Patch Set: add sslkeylogfile test Created 3 years, 8 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 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 "components/cronet/ios/Cronet.h" 5 #import "components/cronet/ios/Cronet.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 19 matching lines...) Expand all
30 // which is leaked at the shutdown. We should consider allowing multiple 30 // which is leaked at the shutdown. We should consider allowing multiple
31 // instances if that makes sense in the future. 31 // instances if that makes sense in the future.
32 base::LazyInstance<std::unique_ptr<cronet::CronetEnvironment>>::Leaky 32 base::LazyInstance<std::unique_ptr<cronet::CronetEnvironment>>::Leaky
33 gChromeNet = LAZY_INSTANCE_INITIALIZER; 33 gChromeNet = LAZY_INSTANCE_INITIALIZER;
34 34
35 BOOL gHttp2Enabled = YES; 35 BOOL gHttp2Enabled = YES;
36 BOOL gQuicEnabled = NO; 36 BOOL gQuicEnabled = NO;
37 cronet::URLRequestContextConfig::HttpCacheType gHttpCache = 37 cronet::URLRequestContextConfig::HttpCacheType gHttpCache =
38 cronet::URLRequestContextConfig::HttpCacheType::DISK; 38 cronet::URLRequestContextConfig::HttpCacheType::DISK;
39 ScopedVector<cronet::URLRequestContextConfig::QuicHint> gQuicHints; 39 ScopedVector<cronet::URLRequestContextConfig::QuicHint> gQuicHints;
40 NSString* gExperimentalOptions = @"{}";
40 NSString* gUserAgent = nil; 41 NSString* gUserAgent = nil;
41 BOOL gUserAgentPartial = NO; 42 BOOL gUserAgentPartial = NO;
42 NSString* gSslKeyLogFileName = nil; 43 NSString* gSslKeyLogFileName = nil;
43 RequestFilterBlock gRequestFilterBlock = nil; 44 RequestFilterBlock gRequestFilterBlock = nil;
44 std::unique_ptr<CronetHttpProtocolHandlerDelegate> gHttpProtocolHandlerDelegate; 45 std::unique_ptr<CronetHttpProtocolHandlerDelegate> gHttpProtocolHandlerDelegate;
45 NSURLCache* gPreservedSharedURLCache = nil; 46 NSURLCache* gPreservedSharedURLCache = nil;
46 BOOL gEnableTestCertVerifierForTesting = FALSE; 47 BOOL gEnableTestCertVerifierForTesting = FALSE;
47 NSString* gAcceptLanguages = nil; 48 NSString* gAcceptLanguages = nil;
48 49
49 // CertVerifier, which allows any certificates for testing. 50 // CertVerifier, which allows any certificates for testing.
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 [self checkNotStarted]; 161 [self checkNotStarted];
161 gQuicEnabled = quicEnabled; 162 gQuicEnabled = quicEnabled;
162 } 163 }
163 164
164 + (void)addQuicHint:(NSString*)host port:(int)port altPort:(int)altPort { 165 + (void)addQuicHint:(NSString*)host port:(int)port altPort:(int)altPort {
165 [self checkNotStarted]; 166 [self checkNotStarted];
166 gQuicHints.push_back(new cronet::URLRequestContextConfig::QuicHint( 167 gQuicHints.push_back(new cronet::URLRequestContextConfig::QuicHint(
167 base::SysNSStringToUTF8(host), port, altPort)); 168 base::SysNSStringToUTF8(host), port, altPort));
168 } 169 }
169 170
171 + (void)setExperimentalOptions:(NSString*)experimentalOptions {
172 [self checkNotStarted];
173 gExperimentalOptions = experimentalOptions;
174 }
175
170 + (void)setUserAgent:(NSString*)userAgent partial:(BOOL)partial { 176 + (void)setUserAgent:(NSString*)userAgent partial:(BOOL)partial {
171 [self checkNotStarted]; 177 [self checkNotStarted];
172 gUserAgent = userAgent; 178 gUserAgent = userAgent;
173 gUserAgentPartial = partial; 179 gUserAgentPartial = partial;
174 } 180 }
175 181
176 + (void)setSslKeyLogFileName:(NSString*)sslKeyLogFileName { 182 + (void)setSslKeyLogFileName:(NSString*)sslKeyLogFileName {
177 [self checkNotStarted]; 183 [self checkNotStarted];
178 gSslKeyLogFileName = sslKeyLogFileName; 184 gSslKeyLogFileName = [self getNetLogPathForFile:sslKeyLogFileName];
179 } 185 }
180 186
181 + (void)setHttpCacheType:(CRNHttpCacheType)httpCacheType { 187 + (void)setHttpCacheType:(CRNHttpCacheType)httpCacheType {
182 [self checkNotStarted]; 188 [self checkNotStarted];
183 switch (httpCacheType) { 189 switch (httpCacheType) {
184 case CRNHttpCacheTypeDisabled: 190 case CRNHttpCacheTypeDisabled:
185 gHttpCache = cronet::URLRequestContextConfig::HttpCacheType::DISABLED; 191 gHttpCache = cronet::URLRequestContextConfig::HttpCacheType::DISABLED;
186 break; 192 break;
187 case CRNHttpCacheTypeDisk: 193 case CRNHttpCacheTypeDisk:
188 gHttpCache = cronet::URLRequestContextConfig::HttpCacheType::DISK; 194 gHttpCache = cronet::URLRequestContextConfig::HttpCacheType::DISK;
(...skipping 16 matching lines...) Expand all
205 + (void)startInternal { 211 + (void)startInternal {
206 cronet::CronetEnvironment::Initialize(); 212 cronet::CronetEnvironment::Initialize();
207 std::string user_agent = base::SysNSStringToUTF8(gUserAgent); 213 std::string user_agent = base::SysNSStringToUTF8(gUserAgent);
208 gChromeNet.Get().reset( 214 gChromeNet.Get().reset(
209 new cronet::CronetEnvironment(user_agent, gUserAgentPartial)); 215 new cronet::CronetEnvironment(user_agent, gUserAgentPartial));
210 gChromeNet.Get()->set_accept_language( 216 gChromeNet.Get()->set_accept_language(
211 base::SysNSStringToUTF8(gAcceptLanguages ?: [self getAcceptLanguages])); 217 base::SysNSStringToUTF8(gAcceptLanguages ?: [self getAcceptLanguages]));
212 218
213 gChromeNet.Get()->set_http2_enabled(gHttp2Enabled); 219 gChromeNet.Get()->set_http2_enabled(gHttp2Enabled);
214 gChromeNet.Get()->set_quic_enabled(gQuicEnabled); 220 gChromeNet.Get()->set_quic_enabled(gQuicEnabled);
221 gChromeNet.Get()->set_experimental_options(
222 base::SysNSStringToUTF8(gExperimentalOptions));
215 gChromeNet.Get()->set_http_cache(gHttpCache); 223 gChromeNet.Get()->set_http_cache(gHttpCache);
216 gChromeNet.Get()->set_ssl_key_log_file_name( 224 gChromeNet.Get()->set_ssl_key_log_file_name(
217 base::SysNSStringToUTF8(gSslKeyLogFileName)); 225 base::SysNSStringToUTF8(gSslKeyLogFileName));
218 for (const auto* quicHint : gQuicHints) { 226 for (const auto* quicHint : gQuicHints) {
219 gChromeNet.Get()->AddQuicHint(quicHint->host, quicHint->port, 227 gChromeNet.Get()->AddQuicHint(quicHint->host, quicHint->port,
220 quicHint->alternate_port); 228 quicHint->alternate_port);
221 } 229 }
222 230
223 [self configureCronetEnvironmentForTesting:gChromeNet.Get().get()]; 231 [self configureCronetEnvironmentForTesting:gChromeNet.Get().get()];
224 gChromeNet.Get()->Start(); 232 gChromeNet.Get()->Start();
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 base::SysNSStringToUTF8(hostResolverRulesForTesting)); 335 base::SysNSStringToUTF8(hostResolverRulesForTesting));
328 } 336 }
329 337
330 // This is a non-public dummy method that prevents the linker from stripping out 338 // This is a non-public dummy method that prevents the linker from stripping out
331 // the otherwise non-referenced methods from 'bidirectional_stream.cc'. 339 // the otherwise non-referenced methods from 'bidirectional_stream.cc'.
332 + (void)preventStrippingCronetBidirectionalStream { 340 + (void)preventStrippingCronetBidirectionalStream {
333 bidirectional_stream_create(NULL, 0, 0); 341 bidirectional_stream_create(NULL, 0, 0);
334 } 342 }
335 343
336 @end 344 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698