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

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

Issue 2465303002: [cronet] make startNetLogToFile write to correct file (Closed)
Patch Set: Sync Created 4 years 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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
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*)netLogPath:(NSString*)fileName {
mef 2016/12/09 18:30:40 So, fileName can never be an absolute path, right?
lilyhoughton 2016/12/09 19:42:50 Yeah
234 return [[[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory
235 inDomains:NSUserDomainMask]
236 lastObject] URLByAppendingPathComponent:fileName] path];
237 }
238
239 + (BOOL)startNetLogToFile:(NSString*)fileName logBytes:(BOOL)logBytes {
234 if (gChromeNet.Get().get() && [fileName length]) { 240 if (gChromeNet.Get().get() && [fileName length]) {
235 gChromeNet.Get()->StartNetLog([fileName UTF8String], logBytes); 241 return gChromeNet.Get()->StartNetLog(
242 base::SysNSStringToUTF8([self netLogPath:fileName]), logBytes);
236 } 243 }
244
245 return NO;
237 } 246 }
238 247
239 + (void)stopNetLog { 248 + (void)stopNetLog {
240 if (gChromeNet.Get().get()) { 249 if (gChromeNet.Get().get()) {
241 gChromeNet.Get()->StopNetLog(); 250 gChromeNet.Get()->StopNetLog();
242 } 251 }
243 } 252 }
244 253
245 + (NSString*)getUserAgent { 254 + (NSString*)getUserAgent {
246 if (!gChromeNet.Get().get()) { 255 if (!gChromeNet.Get().get()) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 base::SysNSStringToUTF8(hostResolverRulesForTesting)); 288 base::SysNSStringToUTF8(hostResolverRulesForTesting));
280 } 289 }
281 290
282 // This is a non-public dummy method that prevents the linker from stripping out 291 // This is a non-public dummy method that prevents the linker from stripping out
283 // the otherwise non-referenced methods from 'bidirectional_stream.cc'. 292 // the otherwise non-referenced methods from 'bidirectional_stream.cc'.
284 + (void)preventStrippingCronetBidirectionalStream { 293 + (void)preventStrippingCronetBidirectionalStream {
285 bidirectional_stream_create(NULL, 0, 0); 294 bidirectional_stream_create(NULL, 0, 0);
286 } 295 }
287 296
288 @end 297 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698