| 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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 [NSURLCache setSharedURLCache:gPreservedSharedURLCache]; | 223 [NSURLCache setSharedURLCache:gPreservedSharedURLCache]; |
| 224 gPreservedSharedURLCache = nil; | 224 gPreservedSharedURLCache = nil; |
| 225 } | 225 } |
| 226 [NSURLProtocol unregisterClass:[CRNPauseableHTTPProtocolHandler class]]; | 226 [NSURLProtocol unregisterClass:[CRNPauseableHTTPProtocolHandler class]]; |
| 227 } | 227 } |
| 228 | 228 |
| 229 + (void)installIntoSessionConfiguration:(NSURLSessionConfiguration*)config { | 229 + (void)installIntoSessionConfiguration:(NSURLSessionConfiguration*)config { |
| 230 config.protocolClasses = @[ [CRNPauseableHTTPProtocolHandler class] ]; | 230 config.protocolClasses = @[ [CRNPauseableHTTPProtocolHandler class] ]; |
| 231 } | 231 } |
| 232 | 232 |
| 233 + (void)startNetLogToFile:(NSString*)fileName logBytes:(BOOL)logBytes { | 233 + (NSString*)getNetLogPathForFile:(NSString*)fileName { |
| 234 if (gChromeNet.Get().get() && [fileName length]) { | 234 return [[[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory |
| 235 gChromeNet.Get()->StartNetLog([fileName UTF8String], logBytes); | 235 inDomains:NSUserDomainMask] |
| 236 lastObject] URLByAppendingPathComponent:fileName] path]; |
| 237 } |
| 238 |
| 239 + (BOOL)startNetLogToFile:(NSString*)fileName logBytes:(BOOL)logBytes { |
| 240 if (gChromeNet.Get().get() && [fileName length] && |
| 241 ![fileName isAbsolutePath]) { |
| 242 return gChromeNet.Get()->StartNetLog( |
| 243 base::SysNSStringToUTF8([self getNetLogPathForFile:fileName]), |
| 244 logBytes); |
| 236 } | 245 } |
| 246 |
| 247 return NO; |
| 237 } | 248 } |
| 238 | 249 |
| 239 + (void)stopNetLog { | 250 + (void)stopNetLog { |
| 240 if (gChromeNet.Get().get()) { | 251 if (gChromeNet.Get().get()) { |
| 241 gChromeNet.Get()->StopNetLog(); | 252 gChromeNet.Get()->StopNetLog(); |
| 242 } | 253 } |
| 243 } | 254 } |
| 244 | 255 |
| 245 + (NSString*)getUserAgent { | 256 + (NSString*)getUserAgent { |
| 246 if (!gChromeNet.Get().get()) { | 257 if (!gChromeNet.Get().get()) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 base::SysNSStringToUTF8(hostResolverRulesForTesting)); | 290 base::SysNSStringToUTF8(hostResolverRulesForTesting)); |
| 280 } | 291 } |
| 281 | 292 |
| 282 // This is a non-public dummy method that prevents the linker from stripping out | 293 // This is a non-public dummy method that prevents the linker from stripping out |
| 283 // the otherwise non-referenced methods from 'bidirectional_stream.cc'. | 294 // the otherwise non-referenced methods from 'bidirectional_stream.cc'. |
| 284 + (void)preventStrippingCronetBidirectionalStream { | 295 + (void)preventStrippingCronetBidirectionalStream { |
| 285 bidirectional_stream_create(NULL, 0, 0); | 296 bidirectional_stream_create(NULL, 0, 0); |
| 286 } | 297 } |
| 287 | 298 |
| 288 @end | 299 @end |
| OLD | NEW |