Bug 1365566 - use PR_GetSystemInfo to get OS version on Firefox desktop. r=dragana. draft
authorShih-Chiang Chien <schien@mozilla.com>
Fri, 12 May 2017 12:03:14 +0800
changeset 579549 0a674ee1227d1f0c61adeac4e5f9e007991a4d7f
parent 579118 41958333867b0f537271dbd4cb4ba9e8a67a85a8
child 629034 75d2c45cff01e63ebd25039808df1d82014788ba
push id59282
push userbmo:schien@mozilla.com
push dateWed, 17 May 2017 11:54:44 +0000
reviewersdragana
bugs1365566
milestone55.0a1
Bug 1365566 - use PR_GetSystemInfo to get OS version on Firefox desktop. r=dragana. MozReview-Commit-ID: J5qlptRVzQe
netwerk/protocol/http/nsHttpHandler.cpp
--- a/netwerk/protocol/http/nsHttpHandler.cpp
+++ b/netwerk/protocol/http/nsHttpHandler.cpp
@@ -2,16 +2,18 @@
 /* vim:set ts=4 sw=4 sts=4 et cin: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // HttpLog.h should generally be included first
 #include "HttpLog.h"
 
+#include "prsystem.h"
+
 #include "nsHttp.h"
 #include "nsHttpHandler.h"
 #include "nsHttpChannel.h"
 #include "nsHttpAuthCache.h"
 #include "nsStandardURL.h"
 #include "nsIDOMWindow.h"
 #include "nsIDOMNavigator.h"
 #include "nsIMozNavigatorNetwork.h"
@@ -265,27 +267,32 @@ nsHttpHandler::nsHttpHandler()
 void
 nsHttpHandler::SetFastOpenOSSupport()
 {
     mFastOpenSupported = false;
 #if !defined(XP_WIN) && !defined(XP_LINUX) && !defined(ANDROID) && !defined(HAS_CONNECTX)
     return;
 #else
 
-    nsCOMPtr<nsIPropertyBag2> infoService =
-        do_GetService("@mozilla.org/system-info;1");
-    MOZ_ASSERT(infoService, "Could not find a system info service");
     nsAutoCString version;
     nsresult rv;
 #ifdef ANDROID
+    nsCOMPtr<nsIPropertyBag2> infoService =
+        do_GetService("@mozilla.org/system-info;1");
+    MOZ_ASSERT(infoService, "Could not find a system info service");
     rv = infoService->GetPropertyAsACString(
         NS_LITERAL_STRING("sdk_version"), version);
 #else
-    rv = infoService->GetPropertyAsACString(
-        NS_LITERAL_STRING("version"), version);
+    char buf[SYS_INFO_BUFFER_LENGTH];
+    if (PR_GetSystemInfo(PR_SI_RELEASE, buf, sizeof(buf)) == PR_SUCCESS) {
+        version = buf;
+        rv = NS_OK;
+    } else {
+        rv = NS_ERROR_FAILURE;
+    }
 #endif
 
     LOG(("nsHttpHandler::SetFastOpenOSSupport version %s", version.get()));
 
     if (NS_SUCCEEDED(rv)) {
         // set min version minus 1.
 #ifdef XP_WIN
         int min_version[] = {10, 0};