Bug 1056857 - Code cleanup related to debugging flags. r=kanru

- change #define to const char* for consistency
- change int to bool for bool flags
- make debug log messages more concise, multi-line messages (that could be one-line) make watching the debug log difficult
This commit is contained in:
Garvan Keeley 2014-09-02 21:09:00 -04:00
Родитель 9a1557adb3
Коммит 29a3acd410
1 изменённых файлов: 21 добавлений и 26 удалений

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

@ -41,10 +41,6 @@
#include "nsIRadioInterfaceLayer.h"
#endif
// Both of these settings can be toggled in the Gaia Developer settings screen
#define SETTING_DEBUG_ENABLED "geolocation.debugging.enabled"
#define SETTING_DEBUG_GPS_IGNORED "geolocation.debugging.gps-locations-ignored"
#ifdef AGPS_TYPE_INVALID
#define AGPS_HAVE_DUAL_APN
#endif
@ -54,11 +50,13 @@
using namespace mozilla;
static const int kDefaultPeriod = 1000; // ms
static int gGPSDebugging = false;
static bool gDebug_isLoggingEnabled = false;
static bool gDebug_isGPSLocationIgnored = false;
static const char* kNetworkConnStateChangedTopic = "network-connection-state-changed";
static const char* kMozSettingsChangedTopic = "mozsettings-changed";
// Both of these settings can be toggled in the Gaia Developer settings screen.
static const char* kSettingDebugEnabled = "geolocation.debugging.enabled";
static const char* kSettingDebugGpsIgnored = "geolocation.debugging.gps-locations-ignored";
// While most methods of GonkGPSGeolocationProvider should only be
// called from main thread, we deliberately put the Init and ShutdownGPS
@ -135,10 +133,9 @@ GonkGPSGeolocationProvider::SvStatusCallback(GpsSvStatus* sv_info)
void
GonkGPSGeolocationProvider::NmeaCallback(GpsUtcTime timestamp, const char* nmea, int length)
{
if (gGPSDebugging) {
nsContentUtils::LogMessageToConsole("NMEA: timestamp:\t%lld", timestamp);
nsContentUtils::LogMessageToConsole("NMEA: nmea: \t%s", nmea);
nsContentUtils::LogMessageToConsole("NMEA length: \%d", length);
if (gDebug_isLoggingEnabled) {
nsContentUtils::LogMessageToConsole("geo: NMEA: timestamp:\t%lld, length: %d, %s",
timestamp, length, nmea);
}
}
@ -563,13 +560,11 @@ GonkGPSGeolocationProvider::InjectLocation(double latitude,
double longitude,
float accuracy)
{
if (gGPSDebugging) {
nsContentUtils::LogMessageToConsole("*** injecting location");
nsContentUtils::LogMessageToConsole("*** lat: %f", latitude);
nsContentUtils::LogMessageToConsole("*** lon: %f", longitude);
nsContentUtils::LogMessageToConsole("*** accuracy: %f", accuracy);
if (gDebug_isLoggingEnabled) {
nsContentUtils::LogMessageToConsole("geo: injecting location (%f, %f) accuracy: %f",
latitude, longitude, accuracy);
}
MOZ_ASSERT(NS_IsMainThread());
if (!mGpsInterface) {
return;
@ -776,13 +771,13 @@ GonkGPSGeolocationProvider::NetworkLocationUpdate::Update(nsIDOMGeoPosition *pos
if (isGPSFullyInactive ||
(isGPSTempInactive && delta > kMinMLSCoordChangeInMeters))
{
if (gGPSDebugging) {
if (gDebug_isLoggingEnabled) {
nsContentUtils::LogMessageToConsole("geo: Using MLS, GPS age:%fs, MLS Delta:%fm\n",
diff_ms / 1000.0, delta);
}
provider->mLocationCallback->Update(position);
} else if (provider->mLastGPSPosition) {
if (gGPSDebugging) {
if (gDebug_isLoggingEnabled) {
nsContentUtils::LogMessageToConsole("geo: Using old GPS age:%fs\n",
diff_ms / 1000.0);
}
@ -815,8 +810,8 @@ GonkGPSGeolocationProvider::Startup()
{
MOZ_ASSERT(NS_IsMainThread());
RequestSettingValue(SETTING_DEBUG_ENABLED);
RequestSettingValue(SETTING_DEBUG_GPS_IGNORED);
RequestSettingValue(kSettingDebugEnabled);
RequestSettingValue(kSettingDebugGpsIgnored);
// Setup an observer to watch changes to the setting.
nsCOMPtr<nsIObserverService> observerService = services::GetObserverService();
@ -980,8 +975,8 @@ GonkGPSGeolocationProvider::Observe(nsISupports* aSubject,
#endif
if (!strcmp(aTopic, kMozSettingsChangedTopic)) {
RequestSettingValue(SETTING_DEBUG_ENABLED);
RequestSettingValue(SETTING_DEBUG_GPS_IGNORED);
RequestSettingValue(kSettingDebugEnabled);
RequestSettingValue(kSettingDebugGpsIgnored);
}
return NS_OK;
@ -1011,14 +1006,14 @@ GonkGPSGeolocationProvider::Handle(const nsAString& aName,
}
} else
#endif // MOZ_B2G_RIL
if (aName.EqualsLiteral(SETTING_DEBUG_GPS_IGNORED)) {
if (aName.EqualsASCII(kSettingDebugGpsIgnored)) {
gDebug_isGPSLocationIgnored = aResult.isBoolean() ? aResult.toBoolean() : false;
if (gGPSDebugging) {
if (gDebug_isLoggingEnabled) {
nsContentUtils::LogMessageToConsole("geo: Debug: GPS ignored %d\n", gDebug_isGPSLocationIgnored);
}
return NS_OK;
} else if (aName.EqualsLiteral(SETTING_DEBUG_ENABLED)) {
gGPSDebugging = aResult.isBoolean() ? aResult.toBoolean() : false;
} else if (aName.EqualsASCII(kSettingDebugEnabled)) {
gDebug_isLoggingEnabled = aResult.isBoolean() ? aResult.toBoolean() : false;
return NS_OK;
}
return NS_OK;