| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ios/crnet/CrNet.h" | 5 #import "ios/crnet/CrNet.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
| 9 #import "ios/net/crn_http_protocol_handler.h" | 9 #import "ios/net/crn_http_protocol_handler.h" |
| 10 #import "ios/crnet/crnet_environment.h" | 10 #import "ios/crnet/crnet_environment.h" |
| 11 | 11 |
| 12 static CrNetEnvironment* g_chrome_net = NULL; | 12 static CrNetEnvironment* g_chrome_net = NULL; |
| 13 | 13 |
| 14 static BOOL g_http2_enabled = YES; | 14 static BOOL g_http2_enabled = YES; |
| 15 static BOOL g_quic_enabled = NO; | 15 static BOOL g_quic_enabled = NO; |
| 16 static BOOL g_sdch_enabled = NO; | 16 static BOOL g_sdch_enabled = NO; |
| 17 static BOOL g_user_agent_partial = NO; |
| 17 static NSString* g_user_agent = nil; | 18 static NSString* g_user_agent = nil; |
| 18 static NSString* g_sdch_pref_store_filename = nil; | 19 static NSString* g_sdch_pref_store_filename = nil; |
| 19 static RequestFilterBlock g_request_filter_block = nil; | 20 static RequestFilterBlock g_request_filter_block = nil; |
| 20 | 21 |
| 21 @implementation CrNet | 22 @implementation CrNet |
| 22 | 23 |
| 23 + (void)setHttp2Enabled:(BOOL)http2Enabled { | 24 + (void)setHttp2Enabled:(BOOL)http2Enabled { |
| 24 g_http2_enabled = http2Enabled; | 25 g_http2_enabled = http2Enabled; |
| 25 } | 26 } |
| 26 | 27 |
| 27 + (void)setQuicEnabled:(BOOL)quicEnabled { | 28 + (void)setQuicEnabled:(BOOL)quicEnabled { |
| 28 g_quic_enabled = quicEnabled; | 29 g_quic_enabled = quicEnabled; |
| 29 } | 30 } |
| 30 | 31 |
| 31 + (void)setSDCHEnabled:(BOOL)sdchEnabled | 32 + (void)setSDCHEnabled:(BOOL)sdchEnabled |
| 32 withPrefStore:(NSString*)filename { | 33 withPrefStore:(NSString*)filename { |
| 33 g_sdch_enabled = sdchEnabled; | 34 g_sdch_enabled = sdchEnabled; |
| 34 g_sdch_pref_store_filename = filename; | 35 g_sdch_pref_store_filename = filename; |
| 35 } | 36 } |
| 36 | 37 |
| 37 + (void)setPartialUserAgent:(NSString *)userAgent { | 38 + (void)setPartialUserAgent:(NSString *)userAgent { |
| 39 [self setUserAgent:userAgent partial:YES]; |
| 40 } |
| 41 |
| 42 + (void)setUserAgent:(NSString*)userAgent partial:(bool)partial { |
| 38 g_user_agent = userAgent; | 43 g_user_agent = userAgent; |
| 44 g_user_agent_partial = partial; |
| 39 } | 45 } |
| 40 | 46 |
| 41 + (void)installInternal { | 47 + (void)installInternal { |
| 42 CrNetEnvironment::Initialize(); | 48 CrNetEnvironment::Initialize(); |
| 43 std::string partial_user_agent = base::SysNSStringToUTF8(g_user_agent); | 49 std::string user_agent = base::SysNSStringToUTF8(g_user_agent); |
| 44 g_chrome_net = new CrNetEnvironment(partial_user_agent); | 50 g_chrome_net = new CrNetEnvironment(user_agent, g_user_agent_partial == YES); |
| 45 | 51 |
| 46 g_chrome_net->set_spdy_enabled(g_http2_enabled); | 52 g_chrome_net->set_spdy_enabled(g_http2_enabled); |
| 47 g_chrome_net->set_quic_enabled(g_quic_enabled); | 53 g_chrome_net->set_quic_enabled(g_quic_enabled); |
| 48 g_chrome_net->set_sdch_enabled(g_sdch_enabled); | 54 g_chrome_net->set_sdch_enabled(g_sdch_enabled); |
| 49 if (g_sdch_pref_store_filename) { | 55 if (g_sdch_pref_store_filename) { |
| 50 std::string filename = base::SysNSStringToUTF8(g_sdch_pref_store_filename); | 56 std::string filename = base::SysNSStringToUTF8(g_sdch_pref_store_filename); |
| 51 g_chrome_net->set_sdch_pref_store_filename(filename); | 57 g_chrome_net->set_sdch_pref_store_filename(filename); |
| 52 } | 58 } |
| 53 | 59 |
| 54 g_chrome_net->Install(); | 60 g_chrome_net->Install(); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 } | 141 } |
| 136 } | 142 } |
| 137 | 143 |
| 138 + (void)clearCacheWithCompletionCallback:(ClearCacheCallback)clearCacheCallback
{ | 144 + (void)clearCacheWithCompletionCallback:(ClearCacheCallback)clearCacheCallback
{ |
| 139 if (g_chrome_net) { | 145 if (g_chrome_net) { |
| 140 g_chrome_net->ClearCache(clearCacheCallback); | 146 g_chrome_net->ClearCache(clearCacheCallback); |
| 141 } | 147 } |
| 142 } | 148 } |
| 143 | 149 |
| 144 @end | 150 @end |
| OLD | NEW |