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

Side by Side Diff: chromeos/dbus/power_manager_client.cc

Issue 753313005: Revert of Re-land chromeos: Add non-extension renderers to the freezer cgroup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « chromeos/dbus/power_manager_client.h ('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/dbus/power_manager_client.h" 5 #include "chromeos/dbus/power_manager_client.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 75 }
76 76
77 virtual void RemoveObserver(Observer* observer) override { 77 virtual void RemoveObserver(Observer* observer) override {
78 observers_.RemoveObserver(observer); 78 observers_.RemoveObserver(observer);
79 } 79 }
80 80
81 virtual bool HasObserver(const Observer* observer) const override { 81 virtual bool HasObserver(const Observer* observer) const override {
82 return observers_.HasObserver(observer); 82 return observers_.HasObserver(observer);
83 } 83 }
84 84
85 virtual void SetRenderProcessManagerDelegate(
86 base::WeakPtr<RenderProcessManagerDelegate> delegate) override {
87 DCHECK(!render_process_manager_delegate_)
88 << "There can be only one! ...RenderProcessManagerDelegate";
89 render_process_manager_delegate_ = delegate;
90 }
91
92 virtual void DecreaseScreenBrightness(bool allow_off) override { 85 virtual void DecreaseScreenBrightness(bool allow_off) override {
93 dbus::MethodCall method_call( 86 dbus::MethodCall method_call(
94 power_manager::kPowerManagerInterface, 87 power_manager::kPowerManagerInterface,
95 power_manager::kDecreaseScreenBrightnessMethod); 88 power_manager::kDecreaseScreenBrightnessMethod);
96 dbus::MessageWriter writer(&method_call); 89 dbus::MessageWriter writer(&method_call);
97 writer.AppendBool(allow_off); 90 writer.AppendBool(allow_off);
98 power_manager_proxy_->CallMethod( 91 power_manager_proxy_->CallMethod(
99 &method_call, 92 &method_call,
100 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 93 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
101 dbus::ObjectProxy::EmptyResponseCallback()); 94 dbus::ObjectProxy::EmptyResponseCallback());
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 LOG(ERROR) << "Unable to decode protocol buffer from " 527 LOG(ERROR) << "Unable to decode protocol buffer from "
535 << power_manager::kSuspendDoneSignal << " signal"; 528 << power_manager::kSuspendDoneSignal << " signal";
536 return; 529 return;
537 } 530 }
538 531
539 const base::TimeDelta duration = 532 const base::TimeDelta duration =
540 base::TimeDelta::FromInternalValue(proto.suspend_duration()); 533 base::TimeDelta::FromInternalValue(proto.suspend_duration());
541 VLOG(1) << "Got " << power_manager::kSuspendDoneSignal << " signal:" 534 VLOG(1) << "Got " << power_manager::kSuspendDoneSignal << " signal:"
542 << " suspend_id=" << proto.suspend_id() 535 << " suspend_id=" << proto.suspend_id()
543 << " duration=" << duration.InSeconds() << " sec"; 536 << " duration=" << duration.InSeconds() << " sec";
544
545 if (render_process_manager_delegate_)
546 render_process_manager_delegate_->SuspendDone();
547
548 FOR_EACH_OBSERVER( 537 FOR_EACH_OBSERVER(
549 PowerManagerClient::Observer, observers_, SuspendDone(duration)); 538 PowerManagerClient::Observer, observers_, SuspendDone(duration));
550 base::PowerMonitorDeviceSource::HandleSystemResumed(); 539 base::PowerMonitorDeviceSource::HandleSystemResumed();
551 } 540 }
552 541
553 void IdleActionImminentReceived(dbus::Signal* signal) { 542 void IdleActionImminentReceived(dbus::Signal* signal) {
554 dbus::MessageReader reader(signal); 543 dbus::MessageReader reader(signal);
555 power_manager::IdleActionImminent proto; 544 power_manager::IdleActionImminent proto;
556 if (!reader.PopArrayOfBytesAsProto(&proto)) { 545 if (!reader.PopArrayOfBytesAsProto(&proto)) {
557 LOG(ERROR) << "Unable to decode protocol buffer from " 546 LOG(ERROR) << "Unable to decode protocol buffer from "
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 std::string method_name; 672 std::string method_name;
684 int32_t delay_id = -1; 673 int32_t delay_id = -1;
685 if (suspending_from_dark_resume_) { 674 if (suspending_from_dark_resume_) {
686 method_name = power_manager::kHandleDarkSuspendReadinessMethod; 675 method_name = power_manager::kHandleDarkSuspendReadinessMethod;
687 delay_id = dark_suspend_delay_id_; 676 delay_id = dark_suspend_delay_id_;
688 } else { 677 } else {
689 method_name = power_manager::kHandleSuspendReadinessMethod; 678 method_name = power_manager::kHandleSuspendReadinessMethod;
690 delay_id = suspend_delay_id_; 679 delay_id = suspend_delay_id_;
691 } 680 }
692 681
693 if (render_process_manager_delegate_ && !suspending_from_dark_resume_)
694 render_process_manager_delegate_->SuspendImminent();
695
696 dbus::MethodCall method_call( 682 dbus::MethodCall method_call(
697 power_manager::kPowerManagerInterface, method_name); 683 power_manager::kPowerManagerInterface, method_name);
698 dbus::MessageWriter writer(&method_call); 684 dbus::MessageWriter writer(&method_call);
699 685
700 VLOG(1) << "Announcing readiness of suspend delay " << delay_id 686 VLOG(1) << "Announcing readiness of suspend delay " << delay_id
701 << " for suspend attempt " << pending_suspend_id_; 687 << " for suspend attempt " << pending_suspend_id_;
702 power_manager::SuspendReadinessInfo protobuf_request; 688 power_manager::SuspendReadinessInfo protobuf_request;
703 protobuf_request.set_delay_id(delay_id); 689 protobuf_request.set_delay_id(delay_id);
704 protobuf_request.set_suspend_id(pending_suspend_id_); 690 protobuf_request.set_suspend_id(pending_suspend_id_);
705 691
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 bool suspending_from_dark_resume_; 728 bool suspending_from_dark_resume_;
743 729
744 // Number of callbacks that have been returned by 730 // Number of callbacks that have been returned by
745 // GetSuspendReadinessCallback() during the currently-pending suspend 731 // GetSuspendReadinessCallback() during the currently-pending suspend
746 // attempt but have not yet been called. 732 // attempt but have not yet been called.
747 int num_pending_suspend_readiness_callbacks_; 733 int num_pending_suspend_readiness_callbacks_;
748 734
749 // Last state passed to SetIsProjecting(). 735 // Last state passed to SetIsProjecting().
750 bool last_is_projecting_; 736 bool last_is_projecting_;
751 737
752 // The delegate used to manage the power consumption of Chrome's renderer
753 // processes.
754 base::WeakPtr<RenderProcessManagerDelegate> render_process_manager_delegate_;
755
756 // Note: This should remain the last member so it'll be destroyed and 738 // Note: This should remain the last member so it'll be destroyed and
757 // invalidate its weak pointers before any other members are destroyed. 739 // invalidate its weak pointers before any other members are destroyed.
758 base::WeakPtrFactory<PowerManagerClientImpl> weak_ptr_factory_; 740 base::WeakPtrFactory<PowerManagerClientImpl> weak_ptr_factory_;
759 741
760 DISALLOW_COPY_AND_ASSIGN(PowerManagerClientImpl); 742 DISALLOW_COPY_AND_ASSIGN(PowerManagerClientImpl);
761 }; 743 };
762 744
763 // The PowerManagerClient implementation used on Linux desktop, 745 // The PowerManagerClient implementation used on Linux desktop,
764 // which does nothing. 746 // which does nothing.
765 class PowerManagerClientStubImpl : public PowerManagerClient { 747 class PowerManagerClientStubImpl : public PowerManagerClient {
(...skipping 29 matching lines...) Expand all
795 } 777 }
796 778
797 virtual void RemoveObserver(Observer* observer) override { 779 virtual void RemoveObserver(Observer* observer) override {
798 observers_.RemoveObserver(observer); 780 observers_.RemoveObserver(observer);
799 } 781 }
800 782
801 virtual bool HasObserver(const Observer* observer) const override { 783 virtual bool HasObserver(const Observer* observer) const override {
802 return observers_.HasObserver(observer); 784 return observers_.HasObserver(observer);
803 } 785 }
804 786
805 virtual void SetRenderProcessManagerDelegate(
806 base::WeakPtr<RenderProcessManagerDelegate> delegate) override {
807 }
808
809 virtual void DecreaseScreenBrightness(bool allow_off) override { 787 virtual void DecreaseScreenBrightness(bool allow_off) override {
810 VLOG(1) << "Requested to descrease screen brightness"; 788 VLOG(1) << "Requested to descrease screen brightness";
811 SetBrightness(brightness_ - 5.0, true); 789 SetBrightness(brightness_ - 5.0, true);
812 } 790 }
813 791
814 virtual void IncreaseScreenBrightness() override { 792 virtual void IncreaseScreenBrightness() override {
815 VLOG(1) << "Requested to increase screen brightness"; 793 VLOG(1) << "Requested to increase screen brightness";
816 SetBrightness(brightness_ + 5.0, true); 794 SetBrightness(brightness_ + 5.0, true);
817 } 795 }
818 796
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 // static 970 // static
993 PowerManagerClient* PowerManagerClient::Create( 971 PowerManagerClient* PowerManagerClient::Create(
994 DBusClientImplementationType type) { 972 DBusClientImplementationType type) {
995 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) 973 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION)
996 return new PowerManagerClientImpl(); 974 return new PowerManagerClientImpl();
997 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); 975 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type);
998 return new PowerManagerClientStubImpl(); 976 return new PowerManagerClientStubImpl();
999 } 977 }
1000 978
1001 } // namespace chromeos 979 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/power_manager_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698