Bug 1205266 - log network-change events on Mac. r=mcmanus
authorDaniel Stenberg <daniel@haxx.se>
Wed, 16 Sep 2015 06:15:00 +0200
changeset 295656 3627a5fcfd4fd70bd6c35dc4d8929b9db9413afc
parent 295655 76f495de5f78dd4bdbfdb327cfa69e9ea6fe969a
child 295657 3d71fe7036fff7a0233904782cca9e000563d3d3
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus
bugs1205266
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1205266 - log network-change events on Mac. r=mcmanus
netwerk/system/mac/nsNetworkLinkService.mm
--- a/netwerk/system/mac/nsNetworkLinkService.mm
+++ b/netwerk/system/mac/nsNetworkLinkService.mm
@@ -4,25 +4,29 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsNetworkLinkService.h"
 #include "nsCOMPtr.h"
 #include "nsIObserverService.h"
 #include "nsServiceManagerUtils.h"
 #include "nsString.h"
 #include "nsCRT.h"
+#include "mozilla/Logging.h"
 #include "mozilla/Preferences.h"
 
 #import <Cocoa/Cocoa.h>
 #import <netinet/in.h>
 
 #define NETWORK_NOTIFY_CHANGED_PREF "network.notify.changed"
 
 using namespace mozilla;
 
+static PRLogModuleInfo *gNotifyAddrLog = nullptr;
+#define LOG(args) MOZ_LOG(gNotifyAddrLog, mozilla::LogLevel::Debug, args)
+
 // If non-successful, extract the error code and return it.  This
 // error code dance is inspired by
 // http://developer.apple.com/technotes/tn/tn1145.html
 static OSStatus getErrorCodeBool(Boolean success)
 {
     OSStatus err = noErr;
     if (!success) {
         int scErr = ::SCError();
@@ -116,16 +120,19 @@ nsNetworkLinkService::IPConfigChanged(SC
     service->SendEvent(true);
 }
 
 nsresult
 nsNetworkLinkService::Init(void)
 {
     nsresult rv;
 
+    if (!gNotifyAddrLog)
+        gNotifyAddrLog = PR_NewLogModule("nsNotifyAddr");
+
     nsCOMPtr<nsIObserverService> observerService =
         do_GetService("@mozilla.org/observer-service;1", &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = observerService->AddObserver(this, "xpcom-shutdown", false);
     NS_ENSURE_SUCCESS(rv, rv);
 
     Preferences::AddBoolVarCache(&mAllowChangedEvent,
@@ -304,16 +311,17 @@ nsNetworkLinkService::SendEvent(bool aNe
         }
         event = NS_NETWORK_LINK_DATA_CHANGED;
     } else if (!mStatusKnown) {
         event = NS_NETWORK_LINK_DATA_UNKNOWN;
     } else {
         event = mLinkUp ? NS_NETWORK_LINK_DATA_UP
             : NS_NETWORK_LINK_DATA_DOWN;
     }
+    LOG(("SendEvent: network is '%s'\n", event));
 
     observerService->NotifyObservers(static_cast<nsINetworkLinkService*>(this),
                                      NS_NETWORK_LINK_TOPIC,
                                      NS_ConvertASCIItoUTF16(event).get());
 }
 
 /* static */
 void