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

Unified Diff: components/cronet/ios/Cronet.mm

Issue 2836063005: [cronet] Add mechanism for restarting CronetEnvironment (Closed)
Patch Set: Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: components/cronet/ios/Cronet.mm
diff --git a/components/cronet/ios/Cronet.mm b/components/cronet/ios/Cronet.mm
index b883049b52d3fefab00ba5ac7b4ec128cc676e90..fb313b6314f06a97b50ab4d3e918c77cc87dc950 100644
--- a/components/cronet/ios/Cronet.mm
+++ b/components/cronet/ios/Cronet.mm
@@ -148,8 +148,9 @@ class CronetHttpProtocolHandlerDelegate
gAcceptLanguages = acceptLanguages;
}
+// TODO(lilyhoughton) this should either be removed, or made more sophisticated
+ (void)checkNotStarted {
- CHECK(gChromeNet == NULL) << "Cronet is already started.";
+ // CHECK(gChromeNet == NULL) << "Cronet is already started.";
}
+ (void)setHttp2Enabled:(BOOL)http2Enabled {
@@ -203,11 +204,16 @@ class CronetHttpProtocolHandlerDelegate
gRequestFilterBlock = block;
}
-+ (void)startInternal {
++ (void)initializeCronet {
cronet::CronetEnvironment::Initialize();
+}
+
++ (void)startInternal {
std::string user_agent = base::SysNSStringToUTF8(gUserAgent);
+
gChromeNet.Get().reset(
new cronet::CronetEnvironment(user_agent, gUserAgentPartial));
+
gChromeNet.Get()->set_accept_language(
base::SysNSStringToUTF8(gAcceptLanguages ?: [self getAcceptLanguages]));
@@ -236,12 +242,14 @@ class CronetHttpProtocolHandlerDelegate
dispatch_once(&onceToken, ^{
if (![NSThread isMainThread]) {
dispatch_sync(dispatch_get_main_queue(), ^(void) {
- [self startInternal];
+ [self initializeCronet];
mef 2017/04/25 17:55:10 maybe call cronet::CronetEnvironment::Initialize()
lilyhoughton 2017/04/26 18:31:53 Good call. Done.
});
} else {
- [self startInternal];
+ [self initializeCronet];
}
});
+
+ [self startInternal];
mef 2017/04/25 17:55:10 This now will happen current thread instead of mai
lilyhoughton 2017/04/26 18:31:53 Acknowledged.
}
+ (void)registerHttpProtocolHandler {

Powered by Google App Engine
This is Rietveld 408576698