Index: chrome/browser/system_monitor/removable_device_notifications_mac.mm |
diff --git a/chrome/browser/system_monitor/removable_device_notifications_mac.mm b/chrome/browser/system_monitor/removable_device_notifications_mac.mm |
index 85455e6a9ee9605c431db01c8093148700b868b0..185ae18ef727170cd51982aa4fd093ed6baea745 100644 |
--- a/chrome/browser/system_monitor/removable_device_notifications_mac.mm |
+++ b/chrome/browser/system_monitor/removable_device_notifications_mac.mm |
@@ -10,6 +10,9 @@ namespace chrome { |
namespace { |
+static RemovableDeviceNotificationsMac* |
+ g_removable_device_notifications_mac = NULL; |
+ |
void GetDiskInfoAndUpdateOnFileThread( |
const base::WeakPtr<RemovableDeviceNotificationsMac>& notifications, |
base::mac::ScopedCFTypeRef<CFDictionaryRef> dict, |
@@ -45,6 +48,9 @@ void GetDiskInfoAndUpdate( |
RemovableDeviceNotificationsMac::RemovableDeviceNotificationsMac() { |
session_.reset(DASessionCreate(NULL)); |
+ DCHECK(!g_removable_device_notifications_mac); |
+ g_removable_device_notifications_mac = this; |
+ |
DASessionScheduleWithRunLoop( |
session_, CFRunLoopGetCurrent(), kCFRunLoopCommonModes); |
@@ -69,10 +75,20 @@ RemovableDeviceNotificationsMac::RemovableDeviceNotificationsMac() { |
} |
RemovableDeviceNotificationsMac::~RemovableDeviceNotificationsMac() { |
+ DCHECK_EQ(this, g_removable_device_notifications_mac); |
+ g_removable_device_notifications_mac = NULL; |
+ |
DASessionUnscheduleFromRunLoop( |
session_, CFRunLoopGetCurrent(), kCFRunLoopCommonModes); |
} |
+// static |
+RemovableDeviceNotificationsMac* |
+RemovableDeviceNotificationsMac::GetInstance() { |
+ DCHECK(g_removable_device_notifications_mac != NULL); |
+ return g_removable_device_notifications_mac; |
+} |
+ |
void RemovableDeviceNotificationsMac::UpdateDisk( |
const DiskInfoMac& info, |
UpdateType update_type) { |