| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_STORAGE_MONITOR_PORTABLE_DEVICE_WATCHER_WIN_H_ | 5 #ifndef CHROME_BROWSER_STORAGE_MONITOR_PORTABLE_DEVICE_WATCHER_WIN_H_ |
| 6 #define CHROME_BROWSER_STORAGE_MONITOR_PORTABLE_DEVICE_WATCHER_WIN_H_ | 6 #define CHROME_BROWSER_STORAGE_MONITOR_PORTABLE_DEVICE_WATCHER_WIN_H_ |
| 7 | 7 |
| 8 #include <portabledeviceapi.h> | 8 #include <portabledeviceapi.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
| 17 #include "chrome/browser/storage_monitor/storage_monitor.h" | 17 #include "chrome/browser/storage_monitor/storage_monitor.h" |
| 18 | 18 |
| 19 namespace base { | 19 namespace base { |
| 20 class SequencedTaskRunner; | 20 class SequencedTaskRunner; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace chrome { | |
| 24 | |
| 25 namespace test { | |
| 26 class TestPortableDeviceWatcherWin; | 23 class TestPortableDeviceWatcherWin; |
| 27 } | |
| 28 | 24 |
| 29 // This class watches the portable device mount points and sends notifications | 25 // This class watches the portable device mount points and sends notifications |
| 30 // about the attached/detached media transfer protocol (MTP) devices. | 26 // about the attached/detached media transfer protocol (MTP) devices. |
| 31 // This is a singleton class instantiated by StorageMonitorWin. This class is | 27 // This is a singleton class instantiated by StorageMonitorWin. This class is |
| 32 // created, destroyed and operates on the UI thread, except for long running | 28 // created, destroyed and operates on the UI thread, except for long running |
| 33 // tasks it spins off to a SequencedTaskRunner. | 29 // tasks it spins off to a SequencedTaskRunner. |
| 34 class PortableDeviceWatcherWin { | 30 class PortableDeviceWatcherWin { |
| 35 public: | 31 public: |
| 36 typedef std::vector<string16> StorageObjectIDs; | 32 typedef std::vector<string16> StorageObjectIDs; |
| 37 | 33 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 const std::string& storage_unique_id); | 87 const std::string& storage_unique_id); |
| 92 | 88 |
| 93 // Set the volume notifications object to be used when new | 89 // Set the volume notifications object to be used when new |
| 94 // devices are found. | 90 // devices are found. |
| 95 void SetNotifications(StorageMonitor::Receiver* notifications); | 91 void SetNotifications(StorageMonitor::Receiver* notifications); |
| 96 | 92 |
| 97 void EjectDevice(const std::string& device_id, | 93 void EjectDevice(const std::string& device_id, |
| 98 base::Callback<void(StorageMonitor::EjectStatus)> callback); | 94 base::Callback<void(StorageMonitor::EjectStatus)> callback); |
| 99 | 95 |
| 100 private: | 96 private: |
| 101 friend class test::TestPortableDeviceWatcherWin; | 97 friend class TestPortableDeviceWatcherWin; |
| 102 | 98 |
| 103 // Key: MTP device storage unique id. | 99 // Key: MTP device storage unique id. |
| 104 // Value: Metadata for the given storage. | 100 // Value: Metadata for the given storage. |
| 105 typedef std::map<std::string, StorageInfo> MTPStorageMap; | 101 typedef std::map<std::string, StorageInfo> MTPStorageMap; |
| 106 | 102 |
| 107 // Key: MTP device plug and play ID string. | 103 // Key: MTP device plug and play ID string. |
| 108 // Value: Vector of device storage objects. | 104 // Value: Vector of device storage objects. |
| 109 typedef std::map<string16, StorageObjects> MTPDeviceMap; | 105 typedef std::map<string16, StorageObjects> MTPDeviceMap; |
| 110 | 106 |
| 111 // Helpers to enumerate existing MTP storage devices. | 107 // Helpers to enumerate existing MTP storage devices. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 136 | 132 |
| 137 // Used by |media_task_runner_| to create cancelable callbacks. | 133 // Used by |media_task_runner_| to create cancelable callbacks. |
| 138 base::WeakPtrFactory<PortableDeviceWatcherWin> weak_ptr_factory_; | 134 base::WeakPtrFactory<PortableDeviceWatcherWin> weak_ptr_factory_; |
| 139 | 135 |
| 140 // The notifications object to use to signal newly attached devices. | 136 // The notifications object to use to signal newly attached devices. |
| 141 StorageMonitor::Receiver* storage_notifications_; | 137 StorageMonitor::Receiver* storage_notifications_; |
| 142 | 138 |
| 143 DISALLOW_COPY_AND_ASSIGN(PortableDeviceWatcherWin); | 139 DISALLOW_COPY_AND_ASSIGN(PortableDeviceWatcherWin); |
| 144 }; | 140 }; |
| 145 | 141 |
| 146 } // namespace chrome | |
| 147 | |
| 148 #endif // CHROME_BROWSER_STORAGE_MONITOR_PORTABLE_DEVICE_WATCHER_WIN_H_ | 142 #endif // CHROME_BROWSER_STORAGE_MONITOR_PORTABLE_DEVICE_WATCHER_WIN_H_ |
| OLD | NEW |