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

Side by Side Diff: ios/crnet/CrNet.mm

Issue 2206283003: [Cronet] Add CrNet.setUserAgent method on iOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@crnetgn
Patch Set: Sync Created 4 years, 3 months 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 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 {
38 g_user_agent = userAgent; 39 g_user_agent = userAgent;
40 g_user_agent_partial = YES;
41 }
42
43 + (void)setUserAgent:(NSString*)userAgent {
44 g_user_agent = userAgent;
45 g_user_agent_partial = NO;
39 } 46 }
40 47
41 + (void)installInternal { 48 + (void)installInternal {
42 CrNetEnvironment::Initialize(); 49 CrNetEnvironment::Initialize();
43 std::string partial_user_agent = base::SysNSStringToUTF8(g_user_agent); 50 std::string user_agent = base::SysNSStringToUTF8(g_user_agent);
44 g_chrome_net = new CrNetEnvironment(partial_user_agent); 51 g_chrome_net = new CrNetEnvironment(user_agent, g_user_agent_partial == YES);
45 52
46 g_chrome_net->set_spdy_enabled(g_http2_enabled); 53 g_chrome_net->set_spdy_enabled(g_http2_enabled);
47 g_chrome_net->set_quic_enabled(g_quic_enabled); 54 g_chrome_net->set_quic_enabled(g_quic_enabled);
48 g_chrome_net->set_sdch_enabled(g_sdch_enabled); 55 g_chrome_net->set_sdch_enabled(g_sdch_enabled);
49 if (g_sdch_pref_store_filename) { 56 if (g_sdch_pref_store_filename) {
50 std::string filename = base::SysNSStringToUTF8(g_sdch_pref_store_filename); 57 std::string filename = base::SysNSStringToUTF8(g_sdch_pref_store_filename);
51 g_chrome_net->set_sdch_pref_store_filename(filename); 58 g_chrome_net->set_sdch_pref_store_filename(filename);
52 } 59 }
53 60
54 g_chrome_net->Install(); 61 g_chrome_net->Install();
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 142 }
136 } 143 }
137 144
138 + (void)clearCacheWithCompletionCallback:(ClearCacheCallback)clearCacheCallback { 145 + (void)clearCacheWithCompletionCallback:(ClearCacheCallback)clearCacheCallback {
139 if (g_chrome_net) { 146 if (g_chrome_net) {
140 g_chrome_net->ClearCache(clearCacheCallback); 147 g_chrome_net->ClearCache(clearCacheCallback);
141 } 148 }
142 } 149 }
143 150
144 @end 151 @end
OLDNEW
« ios/crnet/CrNet.h ('K') | « ios/crnet/CrNet.h ('k') | ios/crnet/crnet_environment.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698