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

Unified Diff: chrome/browser/system_monitor/media_transfer_protocol_device_observer_chromeos.h

Issue 10894045: ChromeOS: Implement MediaTransferProtocolManager observer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 3 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/system_monitor/media_transfer_protocol_device_observer_chromeos.h
diff --git a/chrome/browser/system_monitor/media_transfer_protocol_device_observer_chromeos.h b/chrome/browser/system_monitor/media_transfer_protocol_device_observer_chromeos.h
new file mode 100644
index 0000000000000000000000000000000000000000..ab252eca6f157e08ecc7dd9b0b0c5de5a03a70b9
--- /dev/null
+++ b/chrome/browser/system_monitor/media_transfer_protocol_device_observer_chromeos.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_MEDIA_TRANSFER_PROTOCOL_DEVICE_OBSERVER_CHROMEOS_H_
+#define CHROME_BROWSER_SYSTEM_MONITOR_MEDIA_TRANSFER_PROTOCOL_DEVICE_OBSERVER_CHROMEOS_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 MediaTransferProtocolDeviceObserverCros
+ : public MediaTransferProtocolManager::Observer {
+ public:
+ MediaTransferProtocolDeviceObserverCros();
+ virtual ~MediaTransferProtocolDeviceObserverCros();
+
+ protected:
+ // Only used in unit tests.
+ explicit MediaTransferProtocolDeviceObserverCros(
+ GetStorageInfoFunc get_storage_info_func);
+
+ // 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> StorageNameToIdMap;
+
+ // Enumerate existing mtp storage devices.
+ void EnumerateStorages();
+
+ // Map of all attached mtp devices.
+ StorageNameToIdMap 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(MediaTransferProtocolDeviceObserverCros);
+};
+
+} // namespace mtp
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_SYSTEM_MONITOR_MEDIA_TRANSFER_PROTOCOL_DEVICE_OBSERVER_CHROMEOS_H_

Powered by Google App Engine
This is Rietveld 408576698