Chromium Code Reviews| 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 <Foundation/Foundation.h> | 5 #import <Foundation/Foundation.h> |
| 6 | 6 |
| 7 #include "cronet_c_for_grpc.h" | 7 #include "cronet_c_for_grpc.h" |
| 8 | 8 |
| 9 // A block, that takes a request, and returns YES if the request should | |
| 10 // be handled. | |
| 11 typedef BOOL (^RequestFilterBlock)(NSURLRequest* request); | |
| 12 | |
| 9 // Interface for installing Cronet. | 13 // Interface for installing Cronet. |
| 10 CRONET_EXPORT | 14 CRONET_EXPORT |
| 11 @interface Cronet : NSObject | 15 @interface Cronet : NSObject |
| 12 | 16 |
| 13 // Sets whether HTTP/2 should be supported by CronetEngine. This method only has | 17 // Sets whether HTTP/2 should be supported by CronetEngine. This method only has |
| 14 // any effect before |start| is called. | 18 // any effect before |start| is called. |
| 15 + (void)setHttp2Enabled:(BOOL)http2Enabled; | 19 + (void)setHttp2Enabled:(BOOL)http2Enabled; |
| 16 | 20 |
| 17 // Sets whether QUIC should be supported by CronetEngine. This method only has | 21 // Sets whether QUIC should be supported by CronetEngine. This method only has |
| 18 // any effect before |start| is called. | 22 // any effect before |start| is called. |
| 19 + (void)setQuicEnabled:(BOOL)quicEnabled; | 23 + (void)setQuicEnabled:(BOOL)quicEnabled; |
| 20 | 24 |
| 21 // Adds hint that host supports QUIC on altPort. This method only has any effect | 25 // Adds hint that host supports QUIC on altPort. This method only has any effect |
| 22 // before |start| is called. | 26 // before |start| is called. |
| 23 + (void)addQuicHint:(NSString*)host port:(int)port altPort:(int)altPort; | 27 + (void)addQuicHint:(NSString*)host port:(int)port altPort:(int)altPort; |
| 24 | 28 |
| 25 // |userAgent| is expected to be of the form Product/Version. | 29 // |userAgent| is expected to be of the form Product/Version. |
| 26 // Example: Foo/3.0.0.0 | 30 // Example: Foo/3.0.0.0 |
| 27 // | 31 // |
| 28 // This method only has any effect before |start| is called. | 32 // This method only has any effect before |start| is called. |
| 29 + (void)setPartialUserAgent:(NSString*)userAgent; | 33 + (void)setPartialUserAgent:(NSString*)userAgent; |
| 30 | 34 |
| 31 // Sets SSLKEYLogFileName to export SSL key for Wireshark decryption of packet | 35 // Sets SSLKEYLogFileName to export SSL key for Wireshark decryption of packet |
| 32 // captures. This method only has any effect before |start| is called. | 36 // captures. This method only has any effect before |start| is called. |
| 33 + (void)setSslKeyLogFileName:(NSString*)sslKeyLogFileName; | 37 + (void)setSslKeyLogFileName:(NSString*)sslKeyLogFileName; |
| 34 | 38 |
| 39 // Set the block used to determine whether or not Cronet should handle the | |
| 40 // request. If this is not set, Cronet will handle all requests. | |
| 41 // This method only has any effect before |start| is called. | |
| 42 + (void)setRequestFilterBlock:(RequestFilterBlock)block; | |
|
kapishnikov
2016/08/12 17:19:31
We should mention in the doc whether the method ke
mef
2016/08/26 14:58:07
Done. Changed it to reset block after start, so it
| |
| 43 | |
| 35 // Starts CronetEngine. It is recommended to call this method on the application | 44 // Starts CronetEngine. It is recommended to call this method on the application |
| 36 // main thread. If the method is called on any thread other than the main one, | 45 // main thread. If the method is called on any thread other than the main one, |
| 37 // the method will internally try to execute synchronously using the main GCD | 46 // the method will internally try to execute synchronously using the main GCD |
| 38 // queue. Please make sure that the main thread is not blocked by a job | 47 // queue. Please make sure that the main thread is not blocked by a job |
| 39 // that calls this method; otherwise, a deadlock can occur. | 48 // that calls this method; otherwise, a deadlock can occur. |
| 40 + (void)start; | 49 + (void)start; |
| 41 | 50 |
| 51 // Registers Cronet as HttpProtocol Handler. Once registered, Cronet intercepts | |
| 52 // and handles all NSURLConnection and NSURLRequests issued by the app, | |
| 53 // including requests done through shared NSURLSession. | |
| 54 // This method must be called after |start|. | |
| 55 + (void)registerHttpProtocolHandler; | |
| 56 | |
| 57 // Unregister Cronet as HttpProtocol Handler. This means that Cronet will stop | |
| 58 // intercepting requests, however, it won't tear down the Cronet environment. | |
| 59 // This method must be called after |start|. | |
| 60 + (void)unregisterHttpProtocolHandler; | |
| 61 | |
| 62 // Installs Cronet into Cronet into NSURLSessionConfiguration so that all | |
|
kapishnikov
2016/08/12 17:19:31
Remove repeating "Cronet into"
mef
2016/08/26 14:58:07
Done.
| |
| 63 // NSURLSessions created with this configuration will use the Cronet stack. | |
| 64 // Note that this NSURLSession will share Cronet settings with the | |
|
kapishnikov
2016/08/12 17:19:31
Maybe we should mention that Cronet settings are g
mef
2016/08/26 14:58:07
Done.
| |
| 65 // sharedSession, | |
| 66 // which the |registerHttpProtocolHandler| method installs Cronet into. | |
| 67 // This method must be called after |start|. | |
| 68 + (void)installIntoSessionConfiguration:(NSURLSessionConfiguration*)config; | |
| 69 | |
| 42 // Starts net-internals logging to a file named |fileName| in the application | 70 // Starts net-internals logging to a file named |fileName| in the application |
| 43 // temporary directory. |fileName| must not be empty. Log level is determined | 71 // temporary directory. |fileName| must not be empty. Log level is determined |
| 44 // by |logBytes| - if YES then LOG_ALL otherwise LOG_ALL_BUT_BYTES. If the file | 72 // by |logBytes| - if YES then LOG_ALL otherwise LOG_ALL_BUT_BYTES. If the file |
| 45 // exists it is truncated before starting. If actively logging the call is | 73 // exists it is truncated before starting. If actively logging the call is |
| 46 // ignored. | 74 // ignored. |
| 47 + (void)startNetLogToFile:(NSString*)fileName logBytes:(BOOL)logBytes; | 75 + (void)startNetLogToFile:(NSString*)fileName logBytes:(BOOL)logBytes; |
| 48 | 76 |
| 49 // Stop net-internals logging and flush file to disk. If a logging session is | 77 // Stop net-internals logging and flush file to disk. If a logging session is |
| 50 // not in progress this call is ignored. | 78 // not in progress this call is ignored. |
| 51 + (void)stopNetLog; | 79 + (void)stopNetLog; |
| 52 | 80 |
| 53 // Returns the full user-agent that the stack uses. | 81 // Returns the full user-agent that the stack uses. |
| 54 // This is the exact string servers will see. | 82 // This is the exact string servers will see. |
| 55 + (NSString*)getUserAgent; | 83 + (NSString*)getUserAgent; |
| 56 | 84 |
| 57 // Get a pointer to global instance of cronet_engine for GRPC C API. | 85 // Get a pointer to global instance of cronet_engine for GRPC C API. |
| 58 + (cronet_engine*)getGlobalEngine; | 86 + (cronet_engine*)getGlobalEngine; |
| 59 | 87 |
| 88 // Returns differences in metrics collected by Cronet since the last call to | |
| 89 // getGlobalMetricsDeltas, serialized as a | |
| 90 // <a href=https://developers.google.com/protocol-buffers>protobuf</a>. | |
| 91 // | |
| 92 // Cronet starts collecting these metrics after the first call to | |
| 93 // getGlobalMetricsDeltras, so the first call returns no | |
| 94 // useful data as no metrics have yet been collected. | |
| 95 // differences in metrics collected by Cronet, since the last call | |
| 96 + (NSData*)getGlobalMetricsDeltas; | |
| 97 | |
| 60 @end | 98 @end |
| OLD | NEW |