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

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

Issue 2836063005: [cronet] Add mechanism for restarting CronetEnvironment (Closed)
Patch Set: per #5 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..1bbe6536641c41d18852ecba1144df080550842f 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.Get()) << "Cronet is already started.";
}
+ (void)setHttp2Enabled:(BOOL)http2Enabled {
@@ -204,10 +205,11 @@ class CronetHttpProtocolHandlerDelegate
}
+ (void)startInternal {
- cronet::CronetEnvironment::Initialize();
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 +238,18 @@ class CronetHttpProtocolHandlerDelegate
dispatch_once(&onceToken, ^{
if (![NSThread isMainThread]) {
dispatch_sync(dispatch_get_main_queue(), ^(void) {
- [self startInternal];
+ cronet::CronetEnvironment::Initialize();
});
} else {
- [self startInternal];
+ cronet::CronetEnvironment::Initialize();
}
});
+
+ [self startInternal];
+}
+
++ (void)shutdown {
+ gChromeNet.Get().reset();
}
+ (void)registerHttpProtocolHandler {

Powered by Google App Engine
This is Rietveld 408576698