Chromium Code Reviews| Index: chrome/browser/system_monitor/chromeos/media_transfer_protocol_device_observer.h |
| diff --git a/chrome/browser/system_monitor/chromeos/media_transfer_protocol_device_observer.h b/chrome/browser/system_monitor/chromeos/media_transfer_protocol_device_observer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f31c3e23598271df99efee0a39434b1cddab65c4 |
| --- /dev/null |
| +++ b/chrome/browser/system_monitor/chromeos/media_transfer_protocol_device_observer.h |
| @@ -0,0 +1,62 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_SYSTEM_MONITOR_CHROMEOS_MEDIA_TRANSFER_PROTOCOL_DEVICE_OBSERVER_H_ |
| +#define CHROME_BROWSER_SYSTEM_MONITOR_CHROMEOS_MEDIA_TRANSFER_PROTOCOL_DEVICE_OBSERVER_H_ |
| + |
| +#include <map> |
| +#include <string> |
| + |
| +#include "base/string16.h" |
| +#include "chrome/browser/chromeos/mtp/media_transfer_protocol_manager.h" |
| + |
| +namespace chromeos { |
| +namespace mtp { |
| + |
| +// Gets the mtp device information given a |storage_name|. On success, |
| +// fills in |id|, |name| and |location|. |
| +typedef void (*GetStorageInfoFunc)(const std::string& storage_name, |
| + std::string* id, |
| + string16* name, |
| + std::string* location); |
| + |
| +// Helper class to send MTP storage attachment and detachment events to |
| +// SystemMonitor. |
| +class MediaTransferProtocolDeviceObserver |
| + : public MediaTransferProtocolManager::Observer { |
| + public: |
| + MediaTransferProtocolDeviceObserver(); |
| + |
| + // Only used in unit tests. |
|
Lei Zhang
2012/09/10 18:18:01
You can probably mark this and StorageChanged() as
kmadhusu
2012/09/11 01:50:19
Done.
|
| + explicit MediaTransferProtocolDeviceObserver( |
| + GetStorageInfoFunc get_storage_info_func); |
| + |
| + virtual ~MediaTransferProtocolDeviceObserver(); |
| + |
| + // MediaTransferProtocolManager::Observer implementation. |
| + // Exposed for unit tests. |
| + virtual void StorageChanged(bool is_attached, |
| + const std::string& storage_name) OVERRIDE; |
| + |
| + private: |
| + // Mapping of storage name and device id. |
| + typedef std::map<std::string, std::string> StorageNameAndIdMap; |
| + |
| + // Enumerate existing mtp storage devices. |
| + void EnumerateStorages(); |
| + |
| + // Map of all attached mtp devices. |
| + StorageNameAndIdMap storage_map_; |
| + |
| + // Function handler to get storage information. This is useful to set a mock |
| + // handler for unit testing. |
| + GetStorageInfoFunc get_storage_info_func_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(MediaTransferProtocolDeviceObserver); |
| +}; |
| + |
| +} // namespace mtp |
| +} // namespace chromeos |
| + |
| +#endif // CHROME_BROWSER_SYSTEM_MONITOR_CHROMEOS_MEDIA_TRANSFER_PROTOCOL_DEVICE_OBSERVER_H_ |