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

Unified Diff: chrome/browser/storage_monitor/storage_monitor_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 comment name Created 7 years, 9 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
« no previous file with comments | « chrome/browser/storage_monitor/storage_monitor_mac.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/storage_monitor/storage_monitor_mac.mm
diff --git a/chrome/browser/storage_monitor/storage_monitor_mac.mm b/chrome/browser/storage_monitor/storage_monitor_mac.mm
index 2582fa333cb61087aa7a8594fb52709ff32482cc..f52ad79e809ab8755128a4821e7f896c6f8506bd 100644
--- a/chrome/browser/storage_monitor/storage_monitor_mac.mm
+++ b/chrome/browser/storage_monitor/storage_monitor_mac.mm
@@ -4,6 +4,8 @@
#include "chrome/browser/storage_monitor/storage_monitor_mac.h"
+#include "base/mac/mac_util.h"
+#include "chrome/browser/storage_monitor/image_capture_device_manager.h"
#include "chrome/browser/storage_monitor/media_storage_util.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
+// StorageMonitorMac be ref counted.
+
void GetDiskInfoAndUpdateOnFileThread(
const scoped_refptr<StorageMonitorMac>& monitor,
base::mac::ScopedCFTypeRef<CFDictionaryRef> dict,
@@ -84,10 +89,17 @@ void EjectDisk(EjectDiskOptions* options) {
} // namespace
StorageMonitorMac::StorageMonitorMac() {
- session_.reset(DASessionCreate(NULL));
+}
- DASessionScheduleWithRunLoop(
- session_, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
+StorageMonitorMac::~StorageMonitorMac() {
+ if (session_.get()) {
+ DASessionUnscheduleFromRunLoop(
+ session_, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
+ }
+}
+
+void StorageMonitorMac::Init() {
+ session_.reset(DASessionCreate(NULL));
// Register for callbacks for attached, changed, and removed devices.
// This will send notifications for existing devices too.
@@ -107,11 +119,14 @@ StorageMonitorMac::StorageMonitorMac() {
kDADiskDescriptionWatchVolumePath,
DiskDescriptionChangedCallback,
this);
-}
-StorageMonitorMac::~StorageMonitorMac() {
- DASessionUnscheduleFromRunLoop(
+ DASessionScheduleWithRunLoop(
session_, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
+
+ if (base::mac::IsOSLionOrLater()) {
+ image_capture_device_manager_.reset(new chrome::ImageCaptureDeviceManager);
+ image_capture_device_manager_->SetNotifications(receiver());
+ }
}
void StorageMonitorMac::UpdateDisk(const DiskInfoMac& info,
« no previous file with comments | « chrome/browser/storage_monitor/storage_monitor_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698