Bug 1205266 - log network-change events on Mac. r=mcmanus

This commit is contained in:
Daniel Stenberg 2015-09-16 06:15:00 +02:00
Родитель abc917a355
Коммит e8f7f42088
1 изменённых файлов: 8 добавлений и 0 удалений

Просмотреть файл

@ -9,6 +9,7 @@
#include "nsServiceManagerUtils.h"
#include "nsString.h"
#include "nsCRT.h"
#include "mozilla/Logging.h"
#include "mozilla/Preferences.h"
#import <Cocoa/Cocoa.h>
@ -18,6 +19,9 @@
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
@ -121,6 +125,9 @@ 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);
@ -309,6 +316,7 @@ nsNetworkLinkService::SendEvent(bool aNetworkChanged)
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,