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

Side by Side Diff: chromeos/display/output_configurator.cc

Issue 10854121: Fixes for handling of MockDBusThreadManager::GetSystemBus(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix the build for sure Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/settings/signed_settings_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chromeos/display/output_configurator.h" 5 #include "chromeos/display/output_configurator.h"
6 6
7 #include <X11/Xlib.h> 7 #include <X11/Xlib.h>
8 #include <X11/extensions/dpms.h> 8 #include <X11/extensions/dpms.h>
9 #include <X11/extensions/Xrandr.h> 9 #include <X11/extensions/Xrandr.h>
10 10
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 secondary_output_index_(-1), 233 secondary_output_index_(-1),
234 xrandr_event_base_(0), 234 xrandr_event_base_(0),
235 output_state_(STATE_INVALID) { 235 output_state_(STATE_INVALID) {
236 if (!is_running_on_chrome_os_) 236 if (!is_running_on_chrome_os_)
237 return; 237 return;
238 // Send the signal to powerd to tell it that we will take over output 238 // Send the signal to powerd to tell it that we will take over output
239 // control. 239 // control.
240 // Note that this can be removed once the legacy powerd support is removed. 240 // Note that this can be removed once the legacy powerd support is removed.
241 chromeos::DBusThreadManager* manager = chromeos::DBusThreadManager::Get(); 241 chromeos::DBusThreadManager* manager = chromeos::DBusThreadManager::Get();
242 dbus::Bus* bus = manager->GetSystemBus(); 242 dbus::Bus* bus = manager->GetSystemBus();
243 dbus::ExportedObject* remote_object = bus->GetExportedObject( 243 if (bus) {
244 dbus::ObjectPath(power_manager::kPowerManagerServicePath)); 244 dbus::ExportedObject* remote_object = bus->GetExportedObject(
245 dbus::Signal signal(power_manager::kPowerManagerInterface, 245 dbus::ObjectPath(power_manager::kPowerManagerServicePath));
246 power_manager::kUseNewMonitorConfigSignal); 246 dbus::Signal signal(power_manager::kPowerManagerInterface,
247 CHECK(signal.raw_message() != NULL); 247 power_manager::kUseNewMonitorConfigSignal);
248 remote_object->SendSignal(&signal); 248 CHECK(signal.raw_message() != NULL);
249 remote_object->SendSignal(&signal);
250 }
249 251
250 // Cache the initial output state. 252 // Cache the initial output state.
251 Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay(); 253 Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay();
252 CHECK(display != NULL); 254 CHECK(display != NULL);
253 XGrabServer(display); 255 XGrabServer(display);
254 Window window = DefaultRootWindow(display); 256 Window window = DefaultRootWindow(display);
255 XRRScreenResources* screen = XRRGetScreenResources(display, window); 257 XRRScreenResources* screen = XRRGetScreenResources(display, window);
256 CHECK(screen != NULL); 258 CHECK(screen != NULL);
257 bool did_detect_outputs = TryRecacheOutputs(display, screen); 259 bool did_detect_outputs = TryRecacheOutputs(display, screen);
258 CHECK(did_detect_outputs); 260 CHECK(did_detect_outputs);
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 connected_output_count += 1; 838 connected_output_count += 1;
837 has_internal_output |= output_cache_[i].is_internal; 839 has_internal_output |= output_cache_[i].is_internal;
838 } 840 }
839 } 841 }
840 842
841 // "Projecting" is defined as having more than 1 output connected while at 843 // "Projecting" is defined as having more than 1 output connected while at
842 // least one of them is an internal output. 844 // least one of them is an internal output.
843 bool is_projecting = has_internal_output && (connected_output_count > 1); 845 bool is_projecting = has_internal_output && (connected_output_count > 1);
844 chromeos::DBusThreadManager* manager = chromeos::DBusThreadManager::Get(); 846 chromeos::DBusThreadManager* manager = chromeos::DBusThreadManager::Get();
845 dbus::Bus* bus = manager->GetSystemBus(); 847 dbus::Bus* bus = manager->GetSystemBus();
846 dbus::ObjectProxy* power_manager_proxy = bus->GetObjectProxy( 848 if (bus) {
847 power_manager::kPowerManagerServiceName, 849 dbus::ObjectProxy* power_manager_proxy = bus->GetObjectProxy(
848 dbus::ObjectPath(power_manager::kPowerManagerServicePath)); 850 power_manager::kPowerManagerServiceName,
849 dbus::MethodCall method_call( 851 dbus::ObjectPath(power_manager::kPowerManagerServicePath));
850 power_manager::kPowerManagerInterface, 852 dbus::MethodCall method_call(
851 power_manager::kSetIsProjectingMethod); 853 power_manager::kPowerManagerInterface,
852 dbus::MessageWriter writer(&method_call); 854 power_manager::kSetIsProjectingMethod);
853 writer.AppendBool(is_projecting); 855 dbus::MessageWriter writer(&method_call);
854 power_manager_proxy->CallMethod( 856 writer.AppendBool(is_projecting);
855 &method_call, 857 power_manager_proxy->CallMethod(
856 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 858 &method_call,
857 dbus::ObjectProxy::EmptyResponseCallback()); 859 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
860 dbus::ObjectProxy::EmptyResponseCallback());
861 }
858 } 862 }
859 863
860 void OutputConfigurator::NotifyOnDisplayChanged() { 864 void OutputConfigurator::NotifyOnDisplayChanged() {
861 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayModeChanged()); 865 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayModeChanged());
862 } 866 }
863 867
864 } // namespace chromeos 868 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/settings/signed_settings_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698