diff options
author | peconn <peconn@chromium.org> | 2016-03-15 02:25:06 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-15 09:26:25 +0000 |
commit | e9c288b43d7473906bfe1c0d8dc4bb19b0723709 (patch) | |
tree | 21494c662caf0e2aad6cf199707ca9705bc3fa64 /ios/crnet | |
parent | 99cbc477a9c32e129642ad3836207b040d52e5b9 (diff) | |
download | chromium_src-e9c288b43d7473906bfe1c0d8dc4bb19b0723709.zip chromium_src-e9c288b43d7473906bfe1c0d8dc4bb19b0723709.tar.gz chromium_src-e9c288b43d7473906bfe1c0d8dc4bb19b0723709.tar.bz2 |
Revert of Remove support for Alt-Svc/Alternate Protocol Probability (patchset #8 id:140001 of https://codereview.chromium.org/1699653002/ )
Reason for revert:
https://bugs.chromium.org/p/chromium/issues/detail?id=594921
Basically parts of http_stream_factory_impl_unittest.cc are only compiled if ENABLE_BIDIRECTIONAL_STREAM is a build flag and you haven't updated these parts of the file.
Original issue's description:
> Remove support forAlt-Svc/Alternate Protocol Probability
>
> Committed: https://crrev.com/dced4c771d25317d26a0f6e258c7b7f64d4e8eea
> Cr-Commit-Position: refs/heads/master@{#379652}
>
> Committed: https://crrev.com/740688bec5c66af00debe117b6d375ecd212e570
> Cr-Commit-Position: refs/heads/master@{#381134}
TBR=bnc@chromium.org,eroman@chromium.org,mef@chromium.org,rch@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Review URL: https://codereview.chromium.org/1802893002
Cr-Commit-Position: refs/heads/master@{#381197}
Diffstat (limited to 'ios/crnet')
-rw-r--r-- | ios/crnet/CrNet.h | 23 | ||||
-rw-r--r-- | ios/crnet/CrNet.mm | 7 | ||||
-rw-r--r-- | ios/crnet/crnet_consumer/crnet_consumer_app_delegate.mm | 2 | ||||
-rw-r--r-- | ios/crnet/crnet_environment.h | 7 | ||||
-rw-r--r-- | ios/crnet/crnet_environment.mm | 2 |
5 files changed, 41 insertions, 0 deletions
diff --git a/ios/crnet/CrNet.h b/ios/crnet/CrNet.h index 043ee6e..2fbb48f2 100644 --- a/ios/crnet/CrNet.h +++ b/ios/crnet/CrNet.h @@ -35,6 +35,29 @@ typedef void(^ClearCacheCallback)(int errorCode); + (void)setSDCHEnabled:(BOOL)sdchEnabled withPrefStore:(NSString*)filename; +// Set the alternate protocol threshold. Servers announce alternate protocols +// with a probability value; any alternate protocol whose probability value is +// greater than this value will be used, so |alternateProtocolThreshold| == 0 +// implies any announced alternate protocol will be used, and +// |alternateProtocolThreshold| == 1 implies no alternate protocol will ever be +// used. Note that individual alternate protocols must also be individually +// enabled to be considered; currently the only alternate protocol is QUIC (SPDY +// is not controlled by this mechanism). +// +// For example, imagine your service has two frontends a.service.com and +// b.service.com, and you would like to divide your users into three classes: +// Users who use QUIC for both a and b +// Users who use QUIC for a but not b +// Users who use QUIC for neither a nor b +// You can achieve that effect with: +// a.service.com advertises QUIC with p=0.67 +// b.service.com advertises QUIC with p=0.33 +// alternateProtocolThreshold set to a uniform random number in [0,1] +// Now equal proportions of users will fall into the three experimental groups. +// +// The default for this value is 1.0, i.e. all alternate protocols disabled. ++ (void)setAlternateProtocolThreshold:(double)alternateProtocolThreshold; + // |userAgent| is expected to be of the form Product/Version. // Example: Foo/3.0.0.0 // diff --git a/ios/crnet/CrNet.mm b/ios/crnet/CrNet.mm index 0347344..2c91094 100644 --- a/ios/crnet/CrNet.mm +++ b/ios/crnet/CrNet.mm @@ -16,6 +16,7 @@ static BOOL g_quic_enabled = NO; static BOOL g_sdch_enabled = NO; static NSString* g_user_agent = nil; static NSString* g_sdch_pref_store_filename = nil; +static double g_alternate_protocol_threshold = 1.0; static RequestFilterBlock g_request_filter_block = nil; @implementation CrNet @@ -38,6 +39,10 @@ static RequestFilterBlock g_request_filter_block = nil; g_user_agent = userAgent; } ++ (void)setAlternateProtocolThreshold:(double)alternateProtocolThreshold { + g_alternate_protocol_threshold = alternateProtocolThreshold; +} + + (void)installInternal { CrNetEnvironment::Initialize(); std::string partial_user_agent = base::SysNSStringToUTF8(g_user_agent); @@ -50,6 +55,8 @@ static RequestFilterBlock g_request_filter_block = nil; std::string filename = base::SysNSStringToUTF8(g_sdch_pref_store_filename); g_chrome_net->set_sdch_pref_store_filename(filename); } + g_chrome_net->set_alternate_protocol_threshold( + g_alternate_protocol_threshold); g_chrome_net->Install(); g_chrome_net->SetHTTPProtocolHandlerRegistered(true); diff --git a/ios/crnet/crnet_consumer/crnet_consumer_app_delegate.mm b/ios/crnet/crnet_consumer/crnet_consumer_app_delegate.mm index b224eda..ca44848 100644 --- a/ios/crnet/crnet_consumer/crnet_consumer_app_delegate.mm +++ b/ios/crnet/crnet_consumer/crnet_consumer_app_delegate.mm @@ -45,6 +45,8 @@ didFinishLaunchingWithOptions:(NSDictionary*)launchOptions { [CrNet setPartialUserAgent:@"Dummy/1.0"]; [CrNet setQuicEnabled:YES]; + // Always use QUIC if able. + [CrNet setAlternateProtocolThreshold:0.0]; [CrNet setSDCHEnabled:YES withPrefStore:[self SDCHPrefStoreFileName]]; [CrNet install]; [CrNet startNetLogToFile:[self currentNetLogFileName] logBytes:NO]; diff --git a/ios/crnet/crnet_environment.h b/ios/crnet/crnet_environment.h index 5a698897..a0b49c1 100644 --- a/ios/crnet/crnet_environment.h +++ b/ios/crnet/crnet_environment.h @@ -93,10 +93,16 @@ class CrNetEnvironment { void set_sdch_pref_store_filename(const std::string& pref_store) { sdch_pref_store_filename_ = pref_store; } + void set_alternate_protocol_threshold(double threshold) { + alternate_protocol_threshold_ = threshold; + } bool spdy_enabled() const { return spdy_enabled_; } bool quic_enabled() const { return quic_enabled_; } bool sdch_enabled() const { return sdch_enabled_; } + double alternate_protocol_threshold() const { + return alternate_protocol_threshold_; + } // Clears the network stack's disk cache. void ClearCache(ClearCacheCallback callback); @@ -136,6 +142,7 @@ class CrNetEnvironment { bool quic_enabled_; bool sdch_enabled_; std::string sdch_pref_store_filename_; + double alternate_protocol_threshold_; static CrNetEnvironment* chrome_net_; scoped_ptr<base::Thread> network_io_thread_; diff --git a/ios/crnet/crnet_environment.mm b/ios/crnet/crnet_environment.mm index 4b75a5a..128d76b 100644 --- a/ios/crnet/crnet_environment.mm +++ b/ios/crnet/crnet_environment.mm @@ -445,6 +445,8 @@ void CrNetEnvironment::InitializeOnNetworkThread() { params.enable_http2 = spdy_enabled(); params.parse_alternative_services = false; params.enable_quic = quic_enabled(); + params.alternative_service_probability_threshold = + alternate_protocol_threshold_; if (!params.channel_id_service) { // The main context may not have a ChannelIDService, since it is lazily |