Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5362)

Unified Diff: chrome/browser/storage_monitor/removable_device_notifications_mac.mm

Issue 12334096: Regularize ownerships and lifecycle for storage monitor platform classes. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix mac CF Ref check Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/storage_monitor/removable_device_notifications_mac.mm
diff --git a/chrome/browser/storage_monitor/removable_device_notifications_mac.mm b/chrome/browser/storage_monitor/removable_device_notifications_mac.mm
index d1027e45c3707fbccb2ed4130508a4cd5518ff51..a1fa41c7a5d59e416e5c8ffa97e0e538482aee9e 100644
--- a/chrome/browser/storage_monitor/removable_device_notifications_mac.mm
+++ b/chrome/browser/storage_monitor/removable_device_notifications_mac.mm
@@ -4,6 +4,8 @@
#include "chrome/browser/storage_monitor/removable_device_notifications_mac.h"
+#include "base/mac/mac_util.h"
+#include "chrome/browser/storage_monitor/image_capture_device_manager.h"
#include "chrome/browser/storage_monitor/media_device_notifications_utils.h"
#include "content/public/browser/browser_thread.h"
@@ -13,6 +15,9 @@ namespace {
const char kDiskImageModelName[] = "Disk Image";
+// TODO(gbillock): Make these take weak pointers and don't have
+// RemovableDeviceNotificationsMac be ref counted.
+
void GetDiskInfoAndUpdateOnFileThread(
const scoped_refptr<RemovableDeviceNotificationsMac>& notifications,
base::mac::ScopedCFTypeRef<CFDictionaryRef> dict,
@@ -47,10 +52,17 @@ void GetDiskInfoAndUpdate(
} // namespace
RemovableDeviceNotificationsMac::RemovableDeviceNotificationsMac() {
- session_.reset(DASessionCreate(NULL));
+}
- DASessionScheduleWithRunLoop(
- session_, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
+RemovableDeviceNotificationsMac::~RemovableDeviceNotificationsMac() {
+ if (session_.get()) {
+ DASessionUnscheduleFromRunLoop(
+ session_, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
+ }
+}
+
+void RemovableDeviceNotificationsMac::Init() {
+ session_.reset(DASessionCreate(NULL));
// Register for callbacks for attached, changed, and removed devices.
// This will send notifications for existing devices too.
@@ -70,11 +82,14 @@ RemovableDeviceNotificationsMac::RemovableDeviceNotificationsMac() {
kDADiskDescriptionWatchVolumePath,
DiskDescriptionChangedCallback,
this);
-}
-RemovableDeviceNotificationsMac::~RemovableDeviceNotificationsMac() {
- DASessionUnscheduleFromRunLoop(
+ DASessionScheduleWithRunLoop(
session_, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
+
+ if (base::mac::IsOSLionOrLater()) {
+ image_capture_device_manager_.reset(new chrome::ImageCaptureDeviceManager);
+ image_capture_device_manager_->SetNotifications(receiver());
+ }
}
void RemovableDeviceNotificationsMac::UpdateDisk(

Powered by Google App Engine
This is Rietveld 408576698