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/ios/Cronet.mm

Issue 2484263005: Revert of Revert "Revert of Moving gRPC support interfaces out of cronet and into a new component. (Closed)
Patch Set: Created 4 years, 1 month 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/ios/Cronet.h ('k') | components/cronet/ios/cronet_bidirectional_stream.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 23 matching lines...) Expand all
34 BOOL gHttp2Enabled = YES; 34 BOOL gHttp2Enabled = YES;
35 BOOL gQuicEnabled = NO; 35 BOOL gQuicEnabled = NO;
36 ScopedVector<cronet::URLRequestContextConfig::QuicHint> gQuicHints; 36 ScopedVector<cronet::URLRequestContextConfig::QuicHint> gQuicHints;
37 NSString* gUserAgent = nil; 37 NSString* gUserAgent = nil;
38 BOOL gUserAgentPartial = NO; 38 BOOL gUserAgentPartial = NO;
39 NSString* gSslKeyLogFileName = nil; 39 NSString* gSslKeyLogFileName = nil;
40 RequestFilterBlock gRequestFilterBlock = nil; 40 RequestFilterBlock gRequestFilterBlock = nil;
41 std::unique_ptr<CronetHttpProtocolHandlerDelegate> gHttpProtocolHandlerDelegate; 41 std::unique_ptr<CronetHttpProtocolHandlerDelegate> gHttpProtocolHandlerDelegate;
42 NSURLCache* gPreservedSharedURLCache = nil; 42 NSURLCache* gPreservedSharedURLCache = nil;
43 BOOL gEnableTestCertVerifierForTesting = FALSE; 43 BOOL gEnableTestCertVerifierForTesting = FALSE;
44 NSString* gHostResolverRulesForTesting = @"";
44 45
45 // CertVerifier, which allows any certificates for testing. 46 // CertVerifier, which allows any certificates for testing.
46 class TestCertVerifier : public net::CertVerifier { 47 class TestCertVerifier : public net::CertVerifier {
47 int Verify(const RequestParams& params, 48 int Verify(const RequestParams& params,
48 net::CRLSet* crl_set, 49 net::CRLSet* crl_set,
49 net::CertVerifyResult* verify_result, 50 net::CertVerifyResult* verify_result,
50 const net::CompletionCallback& callback, 51 const net::CompletionCallback& callback,
51 std::unique_ptr<Request>* out_req, 52 std::unique_ptr<Request>* out_req,
52 const net::NetLogWithSource& net_log) override { 53 const net::NetLogWithSource& net_log) override {
53 net::Error result = net::OK; 54 net::Error result = net::OK;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 base::mac::ScopedBlock<RequestFilterBlock> filter_; 99 base::mac::ScopedBlock<RequestFilterBlock> filter_;
99 base::Lock lock_; 100 base::Lock lock_;
100 }; 101 };
101 102
102 } // namespace 103 } // namespace
103 104
104 @implementation Cronet 105 @implementation Cronet
105 106
106 + (void)configureCronetEnvironmentForTesting: 107 + (void)configureCronetEnvironmentForTesting:
107 (cronet::CronetEnvironment*)cronetEnvironment { 108 (cronet::CronetEnvironment*)cronetEnvironment {
109 cronetEnvironment->set_host_resolver_rules(
110 [gHostResolverRulesForTesting UTF8String]);
108 if (gEnableTestCertVerifierForTesting) { 111 if (gEnableTestCertVerifierForTesting) {
109 std::unique_ptr<TestCertVerifier> test_cert_verifier = 112 std::unique_ptr<TestCertVerifier> test_cert_verifier =
110 base::MakeUnique<TestCertVerifier>(); 113 base::MakeUnique<TestCertVerifier>();
111 cronetEnvironment->set_cert_verifier(std::move(test_cert_verifier)); 114 cronetEnvironment->set_cert_verifier(std::move(test_cert_verifier));
112 } 115 }
113 } 116 }
114 117
115 + (NSString*)getAcceptLanguages { 118 + (NSString*)getAcceptLanguages {
116 // Use the framework bundle to search for resources. 119 // Use the framework bundle to search for resources.
117 NSBundle* frameworkBundle = [NSBundle bundleForClass:self]; 120 NSBundle* frameworkBundle = [NSBundle bundleForClass:self];
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 247
245 + (NSString*)getUserAgent { 248 + (NSString*)getUserAgent {
246 if (!gChromeNet.Get().get()) { 249 if (!gChromeNet.Get().get()) {
247 return nil; 250 return nil;
248 } 251 }
249 252
250 return [NSString stringWithCString:gChromeNet.Get()->user_agent().c_str() 253 return [NSString stringWithCString:gChromeNet.Get()->user_agent().c_str()
251 encoding:[NSString defaultCStringEncoding]]; 254 encoding:[NSString defaultCStringEncoding]];
252 } 255 }
253 256
254 + (stream_engine*)getGlobalEngine { 257 + (cronet_engine*)getGlobalEngine {
255 DCHECK(gChromeNet.Get().get()); 258 DCHECK(gChromeNet.Get().get());
256 if (gChromeNet.Get().get()) { 259 if (gChromeNet.Get().get()) {
257 static stream_engine engine; 260 static cronet_engine engine;
258 engine.obj = gChromeNet.Get()->GetURLRequestContextGetter(); 261 engine.obj = gChromeNet.Get().get();
259 return &engine; 262 return &engine;
260 } 263 }
261 return nil; 264 return nil;
262 } 265 }
263 266
264 + (NSData*)getGlobalMetricsDeltas { 267 + (NSData*)getGlobalMetricsDeltas {
265 if (!gChromeNet.Get().get()) { 268 if (!gChromeNet.Get().get()) {
266 return nil; 269 return nil;
267 } 270 }
268 std::vector<uint8_t> deltas(gChromeNet.Get()->GetHistogramDeltas()); 271 std::vector<uint8_t> deltas(gChromeNet.Get()->GetHistogramDeltas());
269 return [NSData dataWithBytes:deltas.data() length:deltas.size()]; 272 return [NSData dataWithBytes:deltas.data() length:deltas.size()];
270 } 273 }
271 274
272 + (void)enableTestCertVerifierForTesting { 275 + (void)enableTestCertVerifierForTesting {
273 gEnableTestCertVerifierForTesting = YES; 276 gEnableTestCertVerifierForTesting = YES;
274 } 277 }
275 278
276 + (void)setHostResolverRulesForTesting:(NSString*)hostResolverRulesForTesting { 279 + (void)setHostResolverRulesForTesting:(NSString*)hostResolverRulesForTesting {
277 DCHECK(gChromeNet.Get().get()); 280 gHostResolverRulesForTesting = hostResolverRulesForTesting;
278 gChromeNet.Get()->SetHostResolverRules(
279 base::SysNSStringToUTF8(hostResolverRulesForTesting));
280 } 281 }
281 282
282 // This is a non-public dummy method that prevents the linker from stripping out 283 // This is a non-public dummy method that prevents the linker from stripping out
283 // the otherwise non-referenced methods from 'bidirectional_stream.cc'. 284 // the otherwise non-referenced methods from 'cronet_bidirectional_stream.cc'.
284 + (void)preventStrippingCronetBidirectionalStream { 285 + (void)preventStrippingCronetBidirectionalStream {
285 bidirectional_stream_create(NULL, 0, 0); 286 cronet_bidirectional_stream_create(NULL, 0, 0);
286 } 287 }
287 288
288 @end 289 @end
OLDNEW
« no previous file with comments | « components/cronet/ios/Cronet.h ('k') | components/cronet/ios/cronet_bidirectional_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698