Commit 5db4a021 authored by disher@chromium.org's avatar disher@chromium.org

Remove direct DBus calls from OutputConfigurator

Remove DBus signal to power_manager::kUseNewMonitorConfigSignal since it is no
longer needed by the other side (this used to be required but it was only meant
to be temporary and the other side no longer listens for the signal).
Move DBus call to power_manager::kSetIsProjectingMethod into the DBus
PowerManagerClient class which is where the other methods in the IPC interface
live.

BUG=chromium:142039
TEST=Manually tested on Lumpy and verified that adding/removing displays results
in powerd receiving a SetIsProjecting call.


Review URL: https://chromiumcodereview.appspot.com/10831312

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151894 0039d316-1c4b-4281-b951-d872f2087c98
parent 54671488
...@@ -40,6 +40,7 @@ class MockPowerManagerClient : public PowerManagerClient { ...@@ -40,6 +40,7 @@ class MockPowerManagerClient : public PowerManagerClient {
uint32, uint32,
int, int,
const PowerStateRequestIdCallback&)); const PowerStateRequestIdCallback&));
MOCK_METHOD1(SetIsProjecting, void(bool));
MOCK_METHOD0(NotifyScreenLockCompleted, void(void)); MOCK_METHOD0(NotifyScreenLockCompleted, void(void));
MOCK_METHOD0(NotifyScreenUnlockCompleted, void(void)); MOCK_METHOD0(NotifyScreenUnlockCompleted, void(void));
}; };
......
...@@ -273,6 +273,18 @@ class PowerManagerClientImpl : public PowerManagerClient { ...@@ -273,6 +273,18 @@ class PowerManagerClientImpl : public PowerManagerClient {
weak_ptr_factory_.GetWeakPtr(), callback)); weak_ptr_factory_.GetWeakPtr(), callback));
} }
virtual void SetIsProjecting(bool is_projecting) OVERRIDE {
dbus::MethodCall method_call(
power_manager::kPowerManagerInterface,
power_manager::kSetIsProjectingMethod);
dbus::MessageWriter writer(&method_call);
writer.AppendBool(is_projecting);
power_manager_proxy_->CallMethod(
&method_call,
dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
dbus::ObjectProxy::EmptyResponseCallback());
}
virtual void NotifyScreenLockCompleted() OVERRIDE { virtual void NotifyScreenLockCompleted() OVERRIDE {
SimpleMethodCallToPowerManager(power_manager::kScreenIsLockedMethod); SimpleMethodCallToPowerManager(power_manager::kScreenIsLockedMethod);
} }
...@@ -610,6 +622,7 @@ class PowerManagerClientStubImpl : public PowerManagerClient { ...@@ -610,6 +622,7 @@ class PowerManagerClientStubImpl : public PowerManagerClient {
uint32 duration, uint32 duration,
int overrides, int overrides,
const PowerStateRequestIdCallback& callback) OVERRIDE {} const PowerStateRequestIdCallback& callback) OVERRIDE {}
virtual void SetIsProjecting(bool is_projecting) OVERRIDE {}
virtual void NotifyScreenLockCompleted() OVERRIDE {} virtual void NotifyScreenLockCompleted() OVERRIDE {}
virtual void NotifyScreenUnlockCompleted() OVERRIDE {} virtual void NotifyScreenUnlockCompleted() OVERRIDE {}
......
...@@ -181,6 +181,11 @@ class CHROMEOS_EXPORT PowerManagerClient { ...@@ -181,6 +181,11 @@ class CHROMEOS_EXPORT PowerManagerClient {
int overrides, int overrides,
const PowerStateRequestIdCallback& callback) = 0; const PowerStateRequestIdCallback& callback) = 0;
// Tells powerd whether or not we are in a projecting mode. This is used to
// adjust idleness thresholds and derived, on this side, from the number of
// video outputs attached.
virtual void SetIsProjecting(bool is_projecting) = 0;
// Creates the instance. // Creates the instance.
static PowerManagerClient* Create(DBusClientImplementationType type, static PowerManagerClient* Create(DBusClientImplementationType type,
dbus::Bus* bus); dbus::Bus* bus);
......
include_rules = [
"+dbus",
]
...@@ -23,12 +23,7 @@ ...@@ -23,12 +23,7 @@
#include "base/metrics/histogram.h" #include "base/metrics/histogram.h"
#include "base/perftimer.h" #include "base/perftimer.h"
#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/dbus_thread_manager.h"
#include "dbus/bus.h" #include "chromeos/dbus/power_manager_client.h"
#include "dbus/exported_object.h"
#include "dbus/message.h"
#include "dbus/object_path.h"
#include "dbus/object_proxy.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
namespace chromeos { namespace chromeos {
...@@ -235,19 +230,6 @@ OutputConfigurator::OutputConfigurator(bool is_extended_display_enabled) ...@@ -235,19 +230,6 @@ OutputConfigurator::OutputConfigurator(bool is_extended_display_enabled)
output_state_(STATE_INVALID) { output_state_(STATE_INVALID) {
if (!is_running_on_chrome_os_) if (!is_running_on_chrome_os_)
return; return;
// Send the signal to powerd to tell it that we will take over output
// control.
// Note that this can be removed once the legacy powerd support is removed.
chromeos::DBusThreadManager* manager = chromeos::DBusThreadManager::Get();
dbus::Bus* bus = manager->GetSystemBus();
if (bus) {
dbus::ExportedObject* remote_object = bus->GetExportedObject(
dbus::ObjectPath(power_manager::kPowerManagerServicePath));
dbus::Signal signal(power_manager::kPowerManagerInterface,
power_manager::kUseNewMonitorConfigSignal);
CHECK(signal.raw_message() != NULL);
remote_object->SendSignal(&signal);
}
// Cache the initial output state. // Cache the initial output state.
Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay(); Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay();
...@@ -851,22 +833,8 @@ void OutputConfigurator::CheckIsProjectingAndNotify() { ...@@ -851,22 +833,8 @@ void OutputConfigurator::CheckIsProjectingAndNotify() {
// "Projecting" is defined as having more than 1 output connected while at // "Projecting" is defined as having more than 1 output connected while at
// least one of them is an internal output. // least one of them is an internal output.
bool is_projecting = has_internal_output && (connected_output_count > 1); bool is_projecting = has_internal_output && (connected_output_count > 1);
chromeos::DBusThreadManager* manager = chromeos::DBusThreadManager::Get(); chromeos::DBusThreadManager::Get()->GetPowerManagerClient()
dbus::Bus* bus = manager->GetSystemBus(); ->SetIsProjecting(is_projecting);
if (bus) {
dbus::ObjectProxy* power_manager_proxy = bus->GetObjectProxy(
power_manager::kPowerManagerServiceName,
dbus::ObjectPath(power_manager::kPowerManagerServicePath));
dbus::MethodCall method_call(
power_manager::kPowerManagerInterface,
power_manager::kSetIsProjectingMethod);
dbus::MessageWriter writer(&method_call);
writer.AppendBool(is_projecting);
power_manager_proxy->CallMethod(
&method_call,
dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
dbus::ObjectProxy::EmptyResponseCallback());
}
} }
void OutputConfigurator::NotifyOnDisplayChanged() { void OutputConfigurator::NotifyOnDisplayChanged() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment