| 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 "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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 } | 253 } |
| 254 | 254 |
| 255 + (void)registerHttpProtocolHandler { | 255 + (void)registerHttpProtocolHandler { |
| 256 if (gPreservedSharedURLCache == nil) { | 256 if (gPreservedSharedURLCache == nil) { |
| 257 gPreservedSharedURLCache = [NSURLCache sharedURLCache]; | 257 gPreservedSharedURLCache = [NSURLCache sharedURLCache]; |
| 258 } | 258 } |
| 259 // Disable the default cache. | 259 // Disable the default cache. |
| 260 [NSURLCache setSharedURLCache:[EmptyNSURLCache emptyNSURLCache]]; | 260 [NSURLCache setSharedURLCache:[EmptyNSURLCache emptyNSURLCache]]; |
| 261 // Register the chrome http protocol handler to replace the default one. | 261 // Register the chrome http protocol handler to replace the default one. |
| 262 BOOL success = | 262 BOOL success = |
| 263 [NSURLProtocol registerClass:[CRNPauseableHTTPProtocolHandler class]]; | 263 [NSURLProtocol registerClass:[CRNHTTPProtocolHandler class]]; |
| 264 DCHECK(success); | 264 DCHECK(success); |
| 265 } | 265 } |
| 266 | 266 |
| 267 + (void)unregisterHttpProtocolHandler { | 267 + (void)unregisterHttpProtocolHandler { |
| 268 // Set up SharedURLCache preserved in registerHttpProtocolHandler. | 268 // Set up SharedURLCache preserved in registerHttpProtocolHandler. |
| 269 if (gPreservedSharedURLCache != nil) { | 269 if (gPreservedSharedURLCache != nil) { |
| 270 [NSURLCache setSharedURLCache:gPreservedSharedURLCache]; | 270 [NSURLCache setSharedURLCache:gPreservedSharedURLCache]; |
| 271 gPreservedSharedURLCache = nil; | 271 gPreservedSharedURLCache = nil; |
| 272 } | 272 } |
| 273 [NSURLProtocol unregisterClass:[CRNPauseableHTTPProtocolHandler class]]; | 273 [NSURLProtocol unregisterClass:[CRNHTTPProtocolHandler class]]; |
| 274 } | 274 } |
| 275 | 275 |
| 276 + (void)installIntoSessionConfiguration:(NSURLSessionConfiguration*)config { | 276 + (void)installIntoSessionConfiguration:(NSURLSessionConfiguration*)config { |
| 277 config.protocolClasses = @[ [CRNPauseableHTTPProtocolHandler class] ]; | 277 config.protocolClasses = @[ [CRNHTTPProtocolHandler class] ]; |
| 278 } | 278 } |
| 279 | 279 |
| 280 + (NSString*)getNetLogPathForFile:(NSString*)fileName { | 280 + (NSString*)getNetLogPathForFile:(NSString*)fileName { |
| 281 return [[[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory | 281 return [[[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory |
| 282 inDomains:NSUserDomainMask] | 282 inDomains:NSUserDomainMask] |
| 283 lastObject] URLByAppendingPathComponent:fileName] path]; | 283 lastObject] URLByAppendingPathComponent:fileName] path]; |
| 284 } | 284 } |
| 285 | 285 |
| 286 + (BOOL)startNetLogToFile:(NSString*)fileName logBytes:(BOOL)logBytes { | 286 + (BOOL)startNetLogToFile:(NSString*)fileName logBytes:(BOOL)logBytes { |
| 287 if (gChromeNet.Get().get() && [fileName length] && | 287 if (gChromeNet.Get().get() && [fileName length] && |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 base::SysNSStringToUTF8(hostResolverRulesForTesting)); | 337 base::SysNSStringToUTF8(hostResolverRulesForTesting)); |
| 338 } | 338 } |
| 339 | 339 |
| 340 // This is a non-public dummy method that prevents the linker from stripping out | 340 // This is a non-public dummy method that prevents the linker from stripping out |
| 341 // the otherwise non-referenced methods from 'bidirectional_stream.cc'. | 341 // the otherwise non-referenced methods from 'bidirectional_stream.cc'. |
| 342 + (void)preventStrippingCronetBidirectionalStream { | 342 + (void)preventStrippingCronetBidirectionalStream { |
| 343 bidirectional_stream_create(NULL, 0, 0); | 343 bidirectional_stream_create(NULL, 0, 0); |
| 344 } | 344 } |
| 345 | 345 |
| 346 @end | 346 @end |
| OLD | NEW |