summaryrefslogtreecommitdiffstats
path: root/base/system_monitor
diff options
context:
space:
mode:
authorvandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-21 02:53:50 +0000
committervandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-21 02:53:50 +0000
commitaab7847ca789eb9ebb0f34bf61a6e4dd4c8769ea (patch)
treeb2c76bc6112a956f59a01cf74a7b89b3d5943a73 /base/system_monitor
parent7d2f9a3e37b0d59b790bd48e7e8bb2c3bae8613b (diff)
downloadchromium_src-aab7847ca789eb9ebb0f34bf61a6e4dd4c8769ea.zip
chromium_src-aab7847ca789eb9ebb0f34bf61a6e4dd4c8769ea.tar.gz
chromium_src-aab7847ca789eb9ebb0f34bf61a6e4dd4c8769ea.tar.bz2
SystemMonitor: Pull device type into the device id
Add a utility class to create an split device ids as well as to get some information about devices. BUG=NONE Review URL: https://chromiumcodereview.appspot.com/10829384 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152496 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/system_monitor')
-rw-r--r--base/system_monitor/system_monitor.cc10
-rw-r--r--base/system_monitor/system_monitor.h13
-rw-r--r--base/system_monitor/system_monitor_unittest.cc8
3 files changed, 3 insertions, 28 deletions
diff --git a/base/system_monitor/system_monitor.cc b/base/system_monitor/system_monitor.cc
index 5df0557..8cff63b 100644
--- a/base/system_monitor/system_monitor.cc
+++ b/base/system_monitor/system_monitor.cc
@@ -25,11 +25,9 @@ static int kDelayedBatteryCheckMs = 10 * 1000;
SystemMonitor::MediaDeviceInfo::MediaDeviceInfo(
const std::string& id,
const string16& device_name,
- MediaDeviceType device_type,
const FilePath::StringType& device_location)
: unique_id(id),
name(device_name),
- type(device_type),
location(device_location) {
}
@@ -101,16 +99,15 @@ void SystemMonitor::ProcessDevicesChanged(DeviceType device_type) {
void SystemMonitor::ProcessMediaDeviceAttached(
const std::string& id,
const string16& name,
- MediaDeviceType type,
const FilePath::StringType& location) {
- MediaDeviceInfo info(id, name, type, location);
+ MediaDeviceInfo info(id, name, location);
if (ContainsKey(media_device_map_, id)) {
// This can happen if our unique id scheme fails. Ignore the incoming
// non-unique attachment.
return;
}
media_device_map_.insert(std::make_pair(id, info));
- NotifyMediaDeviceAttached(id, name, type, location);
+ NotifyMediaDeviceAttached(id, name, location);
}
void SystemMonitor::ProcessMediaDeviceDetached(const std::string& id) {
@@ -157,12 +154,11 @@ void SystemMonitor::NotifyDevicesChanged(DeviceType device_type) {
void SystemMonitor::NotifyMediaDeviceAttached(
const std::string& id,
const string16& name,
- MediaDeviceType type,
const FilePath::StringType& location) {
DVLOG(1) << "MediaDeviceAttached with name " << UTF16ToUTF8(name)
<< " and id " << id;
devices_changed_observer_list_->Notify(
- &DevicesChangedObserver::OnMediaDeviceAttached, id, name, type, location);
+ &DevicesChangedObserver::OnMediaDeviceAttached, id, name, location);
}
void SystemMonitor::NotifyMediaDeviceDetached(const std::string& id) {
diff --git a/base/system_monitor/system_monitor.h b/base/system_monitor/system_monitor.h
index 5f4d42d..7461b7a 100644
--- a/base/system_monitor/system_monitor.h
+++ b/base/system_monitor/system_monitor.h
@@ -58,16 +58,9 @@ class BASE_EXPORT SystemMonitor {
DEVTYPE_UNKNOWN, // Other devices.
};
- // Type of location data to identify a currently attached media device.
- enum MediaDeviceType {
- TYPE_PATH, // FilePath::StringType, e.g. a mount point.
- TYPE_MTP, // (W)string to locate a MTP device, e.g. its usb bus/port.
- };
-
struct BASE_EXPORT MediaDeviceInfo {
MediaDeviceInfo(const std::string& id,
const string16& device_name,
- MediaDeviceType device_type,
const FilePath::StringType& device_location);
// Unique media device id - persists between device attachments.
@@ -76,9 +69,6 @@ class BASE_EXPORT SystemMonitor {
// Human readable media device name.
string16 name;
- // Media device type.
- MediaDeviceType type;
-
// Current attached media device location.
FilePath::StringType location;
};
@@ -148,7 +138,6 @@ class BASE_EXPORT SystemMonitor {
// is triggered.
virtual void OnMediaDeviceAttached(const std::string& id,
const string16& name,
- MediaDeviceType type,
const FilePath::StringType& location) {}
virtual void OnMediaDeviceDetached(const std::string& id) {}
@@ -183,7 +172,6 @@ class BASE_EXPORT SystemMonitor {
void ProcessDevicesChanged(DeviceType device_type);
void ProcessMediaDeviceAttached(const std::string& id,
const string16& name,
- MediaDeviceType type,
const FilePath::StringType& location);
void ProcessMediaDeviceDetached(const std::string& id);
@@ -209,7 +197,6 @@ class BASE_EXPORT SystemMonitor {
void NotifyDevicesChanged(DeviceType device_type);
void NotifyMediaDeviceAttached(const std::string& id,
const string16& name,
- MediaDeviceType type,
const FilePath::StringType& data);
void NotifyMediaDeviceDetached(const std::string& id);
void NotifyPowerStateChange();
diff --git a/base/system_monitor/system_monitor_unittest.cc b/base/system_monitor/system_monitor_unittest.cc
index 2f6ddb5f..ee21cc8 100644
--- a/base/system_monitor/system_monitor_unittest.cc
+++ b/base/system_monitor/system_monitor_unittest.cc
@@ -122,7 +122,6 @@ TEST_F(SystemMonitorTest, DeviceChangeNotifications) {
EXPECT_CALL(observers[index],
OnMediaDeviceAttached(kDeviceId1,
kDeviceName,
- base::SystemMonitor::TYPE_PATH,
testing::_))
.InSequence(mock_sequencer[index]);
EXPECT_CALL(observers[index], OnMediaDeviceDetached(kDeviceId1))
@@ -141,7 +140,6 @@ TEST_F(SystemMonitorTest, DeviceChangeNotifications) {
system_monitor_->ProcessMediaDeviceAttached(
kDeviceId1,
kDeviceName,
- base::SystemMonitor::TYPE_PATH,
FILE_PATH_LITERAL("path"));
message_loop_.RunAllPending();
@@ -162,7 +160,6 @@ TEST_F(SystemMonitorTest, GetAttachedMediaDevicesAttachDetach) {
const FilePath kDevicePath1(FILE_PATH_LITERAL("/testfoo"));
system_monitor_->ProcessMediaDeviceAttached(kDeviceId1,
kDeviceName1,
- base::SystemMonitor::TYPE_PATH,
kDevicePath1.value());
message_loop_.RunAllPending();
std::vector<SystemMonitor::MediaDeviceInfo> devices =
@@ -170,7 +167,6 @@ TEST_F(SystemMonitorTest, GetAttachedMediaDevicesAttachDetach) {
ASSERT_EQ(1U, devices.size());
EXPECT_EQ(kDeviceId1, devices[0].unique_id);
EXPECT_EQ(kDeviceName1, devices[0].name);
- EXPECT_EQ(base::SystemMonitor::TYPE_PATH, devices[0].type);
EXPECT_EQ(kDevicePath1.value(), devices[0].location);
const std::string kDeviceId2 = "44";
@@ -178,18 +174,15 @@ TEST_F(SystemMonitorTest, GetAttachedMediaDevicesAttachDetach) {
const FilePath kDevicePath2(FILE_PATH_LITERAL("/testbar"));
system_monitor_->ProcessMediaDeviceAttached(kDeviceId2,
kDeviceName2,
- base::SystemMonitor::TYPE_PATH,
kDevicePath2.value());
message_loop_.RunAllPending();
devices = system_monitor_->GetAttachedMediaDevices();
ASSERT_EQ(2U, devices.size());
EXPECT_EQ(kDeviceId1, devices[0].unique_id);
EXPECT_EQ(kDeviceName1, devices[0].name);
- EXPECT_EQ(base::SystemMonitor::TYPE_PATH, devices[0].type);
EXPECT_EQ(kDevicePath1.value(), devices[0].location);
EXPECT_EQ(kDeviceId2, devices[1].unique_id);
EXPECT_EQ(kDeviceName2, devices[1].name);
- EXPECT_EQ(base::SystemMonitor::TYPE_PATH, devices[1].type);
EXPECT_EQ(kDevicePath2.value(), devices[1].location);
system_monitor_->ProcessMediaDeviceDetached(kDeviceId1);
@@ -198,7 +191,6 @@ TEST_F(SystemMonitorTest, GetAttachedMediaDevicesAttachDetach) {
ASSERT_EQ(1U, devices.size());
EXPECT_EQ(kDeviceId2, devices[0].unique_id);
EXPECT_EQ(kDeviceName2, devices[0].name);
- EXPECT_EQ(base::SystemMonitor::TYPE_PATH, devices[0].type);
EXPECT_EQ(kDevicePath2.value(), devices[0].location);
system_monitor_->ProcessMediaDeviceDetached(kDeviceId2);