Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / storage_monitor / storage_monitor_mac.h
blob76a0b2105dd575e465382ab1da7e64895f00f826
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_MAC_H_
6 #define CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_MAC_H_
8 #include <DiskArbitration/DiskArbitration.h>
9 #include <map>
11 #include "base/mac/scoped_cftyperef.h"
12 #include "base/memory/weak_ptr.h"
13 #include "chrome/browser/storage_monitor/storage_monitor.h"
15 class ImageCaptureDeviceManager;
17 // This class posts notifications to listeners when a new disk
18 // is attached, removed, or changed.
19 class StorageMonitorMac : public StorageMonitor,
20 public base::SupportsWeakPtr<StorageMonitorMac> {
21 public:
22 enum UpdateType {
23 UPDATE_DEVICE_ADDED,
24 UPDATE_DEVICE_CHANGED,
25 UPDATE_DEVICE_REMOVED,
28 // Should only be called by browser start up code. Use GetInstance() instead.
29 StorageMonitorMac();
31 virtual ~StorageMonitorMac();
33 virtual void Init() OVERRIDE;
35 void UpdateDisk(const std::string& bsd_name,
36 const StorageInfo& info,
37 UpdateType update_type);
39 virtual bool GetStorageInfoForPath(
40 const base::FilePath& path,
41 StorageInfo* device_info) const OVERRIDE;
43 virtual void EjectDevice(
44 const std::string& device_id,
45 base::Callback<void(EjectStatus)> callback) OVERRIDE;
47 private:
48 static void DiskAppearedCallback(DADiskRef disk, void* context);
49 static void DiskDisappearedCallback(DADiskRef disk, void* context);
50 static void DiskDescriptionChangedCallback(DADiskRef disk,
51 CFArrayRef keys,
52 void *context);
53 void GetDiskInfoAndUpdate(DADiskRef disk, UpdateType update_type);
55 bool ShouldPostNotificationForDisk(const StorageInfo& info) const;
56 bool FindDiskWithMountPoint(const base::FilePath& mount_point,
57 StorageInfo* info) const;
59 base::ScopedCFTypeRef<DASessionRef> session_;
60 // Maps disk bsd names to disk info objects. This map tracks all mountable
61 // devices on the system, though only notifications for removable devices are
62 // posted.
63 std::map<std::string, StorageInfo> disk_info_map_;
65 int pending_disk_updates_;
67 scoped_ptr<ImageCaptureDeviceManager> image_capture_device_manager_;
69 DISALLOW_COPY_AND_ASSIGN(StorageMonitorMac);
72 #endif // CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_MAC_H_