summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
Diffstat (limited to 'base')
-rw-r--r--base/base.gyp2
-rw-r--r--base/mac/foundation_util.h2
-rw-r--r--base/mac/foundation_util.mm2
-rw-r--r--base/system_monitor/system_monitor.cc27
-rw-r--r--base/system_monitor/system_monitor.h27
-rw-r--r--base/system_monitor/system_monitor_unittest.cc54
-rw-r--r--base/test/mock_devices_changed_observer.cc17
-rw-r--r--base/test/mock_devices_changed_observer.h36
8 files changed, 28 insertions, 139 deletions
diff --git a/base/base.gyp b/base/base.gyp
index 1a1caee..c13a93e 100644
--- a/base/base.gyp
+++ b/base/base.gyp
@@ -409,8 +409,6 @@
'perftimer.cc',
'test/mock_chrome_application_mac.h',
'test/mock_chrome_application_mac.mm',
- 'test/mock_devices_changed_observer.cc',
- 'test/mock_devices_changed_observer.h',
'test/mock_time_provider.cc',
'test/mock_time_provider.h',
'test/multiprocess_test.cc',
diff --git a/base/mac/foundation_util.h b/base/mac/foundation_util.h
index d1e8f6a..56798c9 100644
--- a/base/mac/foundation_util.h
+++ b/base/mac/foundation_util.h
@@ -99,7 +99,6 @@ TYPE_NAME_FOR_CF_TYPE_DECL(CFNull);
TYPE_NAME_FOR_CF_TYPE_DECL(CFNumber);
TYPE_NAME_FOR_CF_TYPE_DECL(CFSet);
TYPE_NAME_FOR_CF_TYPE_DECL(CFString);
-TYPE_NAME_FOR_CF_TYPE_DECL(CFURL);
#undef TYPE_NAME_FOR_CF_TYPE_DECL
@@ -245,7 +244,6 @@ CF_CAST_DECL(CFNull);
CF_CAST_DECL(CFNumber);
CF_CAST_DECL(CFSet);
CF_CAST_DECL(CFString);
-CF_CAST_DECL(CFURL);
#undef CF_CAST_DEFN
diff --git a/base/mac/foundation_util.mm b/base/mac/foundation_util.mm
index ea61054..891ec13 100644
--- a/base/mac/foundation_util.mm
+++ b/base/mac/foundation_util.mm
@@ -183,7 +183,6 @@ TYPE_NAME_FOR_CF_TYPE_DEFN(CFNull);
TYPE_NAME_FOR_CF_TYPE_DEFN(CFNumber);
TYPE_NAME_FOR_CF_TYPE_DEFN(CFSet);
TYPE_NAME_FOR_CF_TYPE_DEFN(CFString);
-TYPE_NAME_FOR_CF_TYPE_DEFN(CFURL);
#undef TYPE_NAME_FOR_CF_TYPE_DEFN
@@ -312,7 +311,6 @@ CF_CAST_DEFN(CFNull);
CF_CAST_DEFN(CFNumber);
CF_CAST_DEFN(CFSet);
CF_CAST_DEFN(CFString);
-CF_CAST_DEFN(CFURL);
#undef CF_CAST_DEFN
diff --git a/base/system_monitor/system_monitor.cc b/base/system_monitor/system_monitor.cc
index afca3fc..28fc70b 100644
--- a/base/system_monitor/system_monitor.cc
+++ b/base/system_monitor/system_monitor.cc
@@ -1,10 +1,9 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
#include "base/system_monitor/system_monitor.h"
-#include "base/file_path.h"
#include "base/logging.h"
#include "base/message_loop.h"
#include "base/time.h"
@@ -84,16 +83,6 @@ void SystemMonitor::ProcessDevicesChanged() {
NotifyDevicesChanged();
}
-void SystemMonitor::ProcessMediaDeviceAttached(const DeviceIdType& id,
- const std::string& name,
- const FilePath& path) {
- NotifyMediaDeviceAttached(id, name, path);
-}
-
-void SystemMonitor::ProcessMediaDeviceDetached(const DeviceIdType& id) {
- NotifyMediaDeviceDetached(id);
-}
-
void SystemMonitor::AddPowerObserver(PowerObserver* obs) {
power_observer_list_->AddObserver(obs);
}
@@ -116,20 +105,6 @@ void SystemMonitor::NotifyDevicesChanged() {
&DevicesChangedObserver::OnDevicesChanged);
}
-void SystemMonitor::NotifyMediaDeviceAttached(const DeviceIdType& id,
- const std::string& name,
- const FilePath& path) {
- DVLOG(1) << "MediaDeviceAttached with name " << name << " and id " << id;
- devices_changed_observer_list_->Notify(
- &DevicesChangedObserver::OnMediaDeviceAttached, id, name, path);
-}
-
-void SystemMonitor::NotifyMediaDeviceDetached(const DeviceIdType& id) {
- DVLOG(1) << "MediaDeviceDetached for id " << id;
- devices_changed_observer_list_->Notify(
- &DevicesChangedObserver::OnMediaDeviceDetached, id);
-}
-
void SystemMonitor::NotifyPowerStateChange() {
DVLOG(1) << "PowerStateChange: " << (BatteryPower() ? "On" : "Off")
<< " battery";
diff --git a/base/system_monitor/system_monitor.h b/base/system_monitor/system_monitor.h
index 3f73b15..7684523 100644
--- a/base/system_monitor/system_monitor.h
+++ b/base/system_monitor/system_monitor.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -6,8 +6,6 @@
#define BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_
#pragma once
-#include <string>
-
#include "base/base_export.h"
#include "base/basictypes.h"
#include "build/build_config.h"
@@ -30,8 +28,6 @@
#include <IOKit/IOMessage.h>
#endif // OS_MACOSX
-class FilePath;
-
namespace base {
// Class for monitoring various system-related subsystems
@@ -46,8 +42,6 @@ class BASE_EXPORT SystemMonitor {
RESUME_EVENT // The system is being resumed.
};
- typedef unsigned int DeviceIdType;
-
// Create SystemMonitor. Only one SystemMonitor instance per application
// is allowed.
SystemMonitor();
@@ -99,19 +93,8 @@ class BASE_EXPORT SystemMonitor {
class BASE_EXPORT DevicesChangedObserver {
public:
// Notification that the devices connected to the system have changed.
- // This is only implemented on Windows currently.
virtual void OnDevicesChanged() {}
- // When a media device is attached or detached, one of these two events
- // is triggered.
- // TODO(vandebo) Pass an appropriate device identifier or way to interact
- // with the devices instead of FilePath.
- virtual void OnMediaDeviceAttached(const DeviceIdType& id,
- const std::string& name,
- const FilePath& path) {}
-
- virtual void OnMediaDeviceDetached(const DeviceIdType& id) {}
-
protected:
virtual ~DevicesChangedObserver() {}
};
@@ -140,10 +123,6 @@ class BASE_EXPORT SystemMonitor {
// Cross-platform handling of a device change event.
void ProcessDevicesChanged();
- void ProcessMediaDeviceAttached(const DeviceIdType& id,
- const std::string& name,
- const FilePath& path);
- void ProcessMediaDeviceDetached(const DeviceIdType& id);
private:
#if defined(OS_MACOSX)
@@ -162,10 +141,6 @@ class BASE_EXPORT SystemMonitor {
// Functions to trigger notifications.
void NotifyDevicesChanged();
- void NotifyMediaDeviceAttached(const DeviceIdType& id,
- const std::string& name,
- const FilePath& path);
- void NotifyMediaDeviceDetached(const DeviceIdType& id);
void NotifyPowerStateChange();
void NotifySuspend();
void NotifyResume();
diff --git a/base/system_monitor/system_monitor_unittest.cc b/base/system_monitor/system_monitor_unittest.cc
index eaed974..1d5d6af 100644
--- a/base/system_monitor/system_monitor_unittest.cc
+++ b/base/system_monitor/system_monitor_unittest.cc
@@ -1,11 +1,8 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
-#include "base/file_path.h"
-#include "base/test/mock_devices_changed_observer.h"
#include "base/system_monitor/system_monitor.h"
-#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
@@ -93,6 +90,26 @@ TEST(SystemMonitor, PowerNotifications) {
EXPECT_EQ(test[0].resumes(), 1);
}
+class DevicesChangedTest : public SystemMonitor::DevicesChangedObserver {
+ public:
+ DevicesChangedTest()
+ : changes_(0) {
+ }
+
+ // DevicesChangedObserver callbacks.
+ virtual void OnDevicesChanged() OVERRIDE {
+ changes_++;
+ }
+
+ // Test status counts.
+ int changes() const { return changes_; }
+
+ private:
+ int changes_; // Count of OnDevicesChanged notifications.
+
+ DISALLOW_COPY_AND_ASSIGN(DevicesChangedTest);
+};
+
TEST(SystemMonitor, DeviceChangeNotifications) {
const int kObservers = 5;
@@ -103,38 +120,19 @@ TEST(SystemMonitor, DeviceChangeNotifications) {
SystemMonitor::AllocateSystemIOPorts();
#endif
- testing::Sequence mock_sequencer[kObservers];
SystemMonitor system_monitor;
- MockDevicesChangedObserver observers[kObservers];
- for (int index = 0; index < kObservers; ++index) {
- system_monitor.AddDevicesChangedObserver(&observers[index]);
-
- EXPECT_CALL(observers[index], OnDevicesChanged())
- .Times(3)
- .InSequence(mock_sequencer[index]);
- EXPECT_CALL(observers[index], OnMediaDeviceAttached(1, "media device",
- testing::_))
- .InSequence(mock_sequencer[index]);
- EXPECT_CALL(observers[index], OnMediaDeviceDetached(1))
- .InSequence(mock_sequencer[index]);
- EXPECT_CALL(observers[index], OnMediaDeviceDetached(2))
- .InSequence(mock_sequencer[index]);
- }
+ DevicesChangedTest test[kObservers];
+ for (int index = 0; index < kObservers; ++index)
+ system_monitor.AddDevicesChangedObserver(&test[index]);
system_monitor.ProcessDevicesChanged();
loop.RunAllPending();
+ EXPECT_EQ(1, test[0].changes());
system_monitor.ProcessDevicesChanged();
system_monitor.ProcessDevicesChanged();
loop.RunAllPending();
-
- system_monitor.ProcessMediaDeviceAttached(
- 1, "media device", FilePath(FILE_PATH_LITERAL("path")));
- loop.RunAllPending();
-
- system_monitor.ProcessMediaDeviceDetached(1);
- system_monitor.ProcessMediaDeviceDetached(2);
- loop.RunAllPending();
+ EXPECT_EQ(3, test[0].changes());
}
} // namespace base
diff --git a/base/test/mock_devices_changed_observer.cc b/base/test/mock_devices_changed_observer.cc
deleted file mode 100644
index 25ff613..0000000
--- a/base/test/mock_devices_changed_observer.cc
+++ /dev/null
@@ -1,17 +0,0 @@
-// 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.
-
-#include "base/test/mock_devices_changed_observer.h"
-
-#include "base/file_path.h"
-
-namespace base {
-
-MockDevicesChangedObserver::MockDevicesChangedObserver() {
-}
-
-MockDevicesChangedObserver::~MockDevicesChangedObserver() {
-}
-
-} // namespace base
diff --git a/base/test/mock_devices_changed_observer.h b/base/test/mock_devices_changed_observer.h
deleted file mode 100644
index 9964f06..0000000
--- a/base/test/mock_devices_changed_observer.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// 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 BASE_TEST_MOCK_DEVICES_CHANGED_OBSERVER_H_
-#define BASE_TEST_MOCK_DEVICES_CHANGED_OBSERVER_H_
-
-#include <string>
-
-#include "base/system_monitor/system_monitor.h"
-#include "testing/gmock/include/gmock/gmock.h"
-
-class FilePath;
-
-namespace base {
-
-class MockDevicesChangedObserver
- : public base::SystemMonitor::DevicesChangedObserver {
- public:
- MockDevicesChangedObserver();
- ~MockDevicesChangedObserver();
-
- MOCK_METHOD0(OnDevicesChanged, void());
- MOCK_METHOD3(OnMediaDeviceAttached,
- void(const base::SystemMonitor::DeviceIdType& id,
- const std::string& name,
- const FilePath& path));
- MOCK_METHOD1(OnMediaDeviceDetached,
- void(const base::SystemMonitor::DeviceIdType& id));
-
- DISALLOW_COPY_AND_ASSIGN(MockDevicesChangedObserver);
-};
-
-} // namespace base
-
-#endif // BASE_TEST_MOCK_DEVICES_CHANGED_OBSERVER_H_