Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 30 matching lines...) Expand all Loading... | |
| 41 const char kSuspendDelayDescription[] = "chrome"; | 41 const char kSuspendDelayDescription[] = "chrome"; |
| 42 | 42 |
| 43 // The PowerManagerClient implementation used in production. | 43 // The PowerManagerClient implementation used in production. |
| 44 class PowerManagerClientImpl : public PowerManagerClient { | 44 class PowerManagerClientImpl : public PowerManagerClient { |
| 45 public: | 45 public: |
| 46 PowerManagerClientImpl() | 46 PowerManagerClientImpl() |
| 47 : origin_thread_id_(base::PlatformThread::CurrentId()), | 47 : origin_thread_id_(base::PlatformThread::CurrentId()), |
| 48 power_manager_proxy_(NULL), | 48 power_manager_proxy_(NULL), |
| 49 suspend_delay_id_(-1), | 49 suspend_delay_id_(-1), |
| 50 has_suspend_delay_id_(false), | 50 has_suspend_delay_id_(false), |
| 51 dark_suspend_delay_id_(-1), | |
| 52 has_dark_suspend_delay_id_(false), | |
| 51 pending_suspend_id_(-1), | 53 pending_suspend_id_(-1), |
| 52 suspend_is_pending_(false), | 54 suspend_is_pending_(false), |
| 55 suspending_from_dark_resume_(false), | |
| 53 num_pending_suspend_readiness_callbacks_(0), | 56 num_pending_suspend_readiness_callbacks_(0), |
| 54 last_is_projecting_(false), | 57 last_is_projecting_(false), |
| 55 weak_ptr_factory_(this) {} | 58 weak_ptr_factory_(this) {} |
| 56 | 59 |
| 57 virtual ~PowerManagerClientImpl() { | 60 virtual ~PowerManagerClientImpl() { |
| 58 // Here we should unregister suspend notifications from powerd, | 61 // Here we should unregister suspend notifications from powerd, |
| 59 // however: | 62 // however: |
| 60 // - The lifetime of the PowerManagerClientImpl can extend past that of | 63 // - The lifetime of the PowerManagerClientImpl can extend past that of |
| 61 // the objectproxy, | 64 // the objectproxy, |
| 62 // - power_manager can already detect that the client is gone and | 65 // - power_manager can already detect that the client is gone and |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 278 power_manager_proxy_->ConnectToSignal( | 281 power_manager_proxy_->ConnectToSignal( |
| 279 power_manager::kPowerManagerInterface, | 282 power_manager::kPowerManagerInterface, |
| 280 power_manager::kSuspendDoneSignal, | 283 power_manager::kSuspendDoneSignal, |
| 281 base::Bind(&PowerManagerClientImpl::SuspendDoneReceived, | 284 base::Bind(&PowerManagerClientImpl::SuspendDoneReceived, |
| 282 weak_ptr_factory_.GetWeakPtr()), | 285 weak_ptr_factory_.GetWeakPtr()), |
| 283 base::Bind(&PowerManagerClientImpl::SignalConnected, | 286 base::Bind(&PowerManagerClientImpl::SignalConnected, |
| 284 weak_ptr_factory_.GetWeakPtr())); | 287 weak_ptr_factory_.GetWeakPtr())); |
| 285 | 288 |
| 286 power_manager_proxy_->ConnectToSignal( | 289 power_manager_proxy_->ConnectToSignal( |
| 287 power_manager::kPowerManagerInterface, | 290 power_manager::kPowerManagerInterface, |
| 291 power_manager::kDarkSuspendImminentSignal, | |
| 292 base::Bind( | |
| 293 &PowerManagerClientImpl::DarkSuspendImminentReceived, | |
| 294 weak_ptr_factory_.GetWeakPtr()), | |
| 295 base::Bind(&PowerManagerClientImpl::SignalConnected, | |
| 296 weak_ptr_factory_.GetWeakPtr())); | |
| 297 | |
| 298 power_manager_proxy_->ConnectToSignal( | |
| 299 power_manager::kPowerManagerInterface, | |
| 288 power_manager::kIdleActionImminentSignal, | 300 power_manager::kIdleActionImminentSignal, |
| 289 base::Bind( | 301 base::Bind( |
| 290 &PowerManagerClientImpl::IdleActionImminentReceived, | 302 &PowerManagerClientImpl::IdleActionImminentReceived, |
| 291 weak_ptr_factory_.GetWeakPtr()), | 303 weak_ptr_factory_.GetWeakPtr()), |
| 292 base::Bind(&PowerManagerClientImpl::SignalConnected, | 304 base::Bind(&PowerManagerClientImpl::SignalConnected, |
| 293 weak_ptr_factory_.GetWeakPtr())); | 305 weak_ptr_factory_.GetWeakPtr())); |
| 294 | 306 |
| 295 power_manager_proxy_->ConnectToSignal( | 307 power_manager_proxy_->ConnectToSignal( |
| 296 power_manager::kPowerManagerInterface, | 308 power_manager::kPowerManagerInterface, |
| 297 power_manager::kIdleActionDeferredSignal, | 309 power_manager::kIdleActionDeferredSignal, |
| 298 base::Bind( | 310 base::Bind( |
| 299 &PowerManagerClientImpl::IdleActionDeferredReceived, | 311 &PowerManagerClientImpl::IdleActionDeferredReceived, |
| 300 weak_ptr_factory_.GetWeakPtr()), | 312 weak_ptr_factory_.GetWeakPtr()), |
| 301 base::Bind(&PowerManagerClientImpl::SignalConnected, | 313 base::Bind(&PowerManagerClientImpl::SignalConnected, |
| 302 weak_ptr_factory_.GetWeakPtr())); | 314 weak_ptr_factory_.GetWeakPtr())); |
| 303 | 315 |
| 304 RegisterSuspendDelay(); | 316 RegisterSuspendDelays(); |
| 305 } | 317 } |
| 306 | 318 |
| 307 private: | 319 private: |
| 308 // Returns true if the current thread is the origin thread. | 320 // Returns true if the current thread is the origin thread. |
| 309 bool OnOriginThread() { | 321 bool OnOriginThread() { |
| 310 return base::PlatformThread::CurrentId() == origin_thread_id_; | 322 return base::PlatformThread::CurrentId() == origin_thread_id_; |
| 311 } | 323 } |
| 312 | 324 |
| 313 // Called when a dbus signal is initially connected. | 325 // Called when a dbus signal is initially connected. |
| 314 void SignalConnected(const std::string& interface_name, | 326 void SignalConnected(const std::string& interface_name, |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 329 } | 341 } |
| 330 | 342 |
| 331 void NameOwnerChangedReceived(const std::string& old_owner, | 343 void NameOwnerChangedReceived(const std::string& old_owner, |
| 332 const std::string& new_owner) { | 344 const std::string& new_owner) { |
| 333 VLOG(1) << "Power manager restarted (old owner was " | 345 VLOG(1) << "Power manager restarted (old owner was " |
| 334 << (old_owner.empty() ? "[none]" : old_owner.c_str()) | 346 << (old_owner.empty() ? "[none]" : old_owner.c_str()) |
| 335 << ", new owner is " | 347 << ", new owner is " |
| 336 << (new_owner.empty() ? "[none]" : new_owner.c_str()) << ")"; | 348 << (new_owner.empty() ? "[none]" : new_owner.c_str()) << ")"; |
| 337 if (!new_owner.empty()) { | 349 if (!new_owner.empty()) { |
| 338 VLOG(1) << "Sending initial state to power manager"; | 350 VLOG(1) << "Sending initial state to power manager"; |
| 339 RegisterSuspendDelay(); | 351 RegisterSuspendDelays(); |
| 340 SetIsProjecting(last_is_projecting_); | 352 SetIsProjecting(last_is_projecting_); |
| 341 FOR_EACH_OBSERVER(Observer, observers_, PowerManagerRestarted()); | 353 FOR_EACH_OBSERVER(Observer, observers_, PowerManagerRestarted()); |
| 342 } | 354 } |
| 343 } | 355 } |
| 344 | 356 |
| 345 void BrightnessChangedReceived(dbus::Signal* signal) { | 357 void BrightnessChangedReceived(dbus::Signal* signal) { |
| 346 dbus::MessageReader reader(signal); | 358 dbus::MessageReader reader(signal); |
| 347 int32 brightness_level = 0; | 359 int32 brightness_level = 0; |
| 348 bool user_initiated = 0; | 360 bool user_initiated = 0; |
| 349 if (!(reader.PopInt32(&brightness_level) && | 361 if (!(reader.PopInt32(&brightness_level) && |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 418 } | 430 } |
| 419 dbus::MessageReader reader(response); | 431 dbus::MessageReader reader(response); |
| 420 double percent = 0.0; | 432 double percent = 0.0; |
| 421 if (!reader.PopDouble(&percent)) | 433 if (!reader.PopDouble(&percent)) |
| 422 LOG(ERROR) << "Error reading response from powerd: " | 434 LOG(ERROR) << "Error reading response from powerd: " |
| 423 << response->ToString(); | 435 << response->ToString(); |
| 424 callback.Run(percent); | 436 callback.Run(percent); |
| 425 } | 437 } |
| 426 | 438 |
| 427 void OnRegisterSuspendDelayReply(dbus::Response* response) { | 439 void OnRegisterSuspendDelayReply(dbus::Response* response) { |
| 440 RegisterSuspendDelayReplyCommon(false, response); | |
|
Daniel Erat
2014/08/18 21:02:13
nit: OnRegisterSuspendDelayReply()? putting "Regis
Chirantan Ekbote
2014/08/18 21:15:43
Sorry, I uploaded this patch set on Friday before
| |
| 441 } | |
| 442 | |
| 443 void OnRegisterDarkSuspendDelayReply(dbus::Response* response) { | |
| 444 RegisterSuspendDelayReplyCommon(true, response); | |
| 445 } | |
| 446 | |
| 447 void RegisterSuspendDelayReplyCommon(bool dark_suspend, | |
| 448 dbus::Response* response) { | |
| 428 if (!response) { | 449 if (!response) { |
| 429 LOG(ERROR) << "Error calling " | 450 LOG(ERROR) << "Error calling " << response->GetMember(); |
| 430 << power_manager::kRegisterSuspendDelayMethod; | |
| 431 return; | 451 return; |
| 432 } | 452 } |
| 433 | 453 |
| 434 dbus::MessageReader reader(response); | 454 dbus::MessageReader reader(response); |
| 435 power_manager::RegisterSuspendDelayReply protobuf; | 455 power_manager::RegisterSuspendDelayReply protobuf; |
| 436 if (!reader.PopArrayOfBytesAsProto(&protobuf)) { | 456 if (!reader.PopArrayOfBytesAsProto(&protobuf)) { |
| 437 LOG(ERROR) << "Unable to parse reply from " | 457 LOG(ERROR) << "Unable to parse reply from " << response->GetMember(); |
| 438 << power_manager::kRegisterSuspendDelayMethod; | |
| 439 return; | 458 return; |
| 440 } | 459 } |
| 441 | 460 |
| 442 suspend_delay_id_ = protobuf.delay_id(); | 461 if (dark_suspend) { |
| 443 has_suspend_delay_id_ = true; | 462 dark_suspend_delay_id_ = protobuf.delay_id(); |
| 444 VLOG(1) << "Registered suspend delay " << suspend_delay_id_; | 463 has_dark_suspend_delay_id_ = true; |
| 464 VLOG(1) << "Registered dark suspend delay " << dark_suspend_delay_id_; | |
| 465 } else { | |
| 466 suspend_delay_id_ = protobuf.delay_id(); | |
| 467 has_suspend_delay_id_ = true; | |
| 468 VLOG(1) << "Registered suspend delay " << suspend_delay_id_; | |
| 469 } | |
| 445 } | 470 } |
| 446 | 471 |
| 447 void SuspendImminentReceived(dbus::Signal* signal) { | 472 void SuspendImminentReceived(dbus::Signal* signal) { |
| 448 if (!has_suspend_delay_id_) { | 473 SuspendImminentCommon(false, signal); |
| 449 LOG(ERROR) << "Received unrequested " | 474 } |
| 450 << power_manager::kSuspendImminentSignal << " signal"; | 475 |
| 476 void DarkSuspendImminentReceived(dbus::Signal* signal) { | |
| 477 SuspendImminentCommon(true, signal); | |
| 478 } | |
| 479 | |
| 480 void SuspendImminentCommon(bool in_dark_resume, | |
| 481 dbus::Signal* signal) { | |
| 482 std::string signal_name = signal->GetMember(); | |
| 483 if ((in_dark_resume && !has_dark_suspend_delay_id_) || | |
| 484 (!in_dark_resume && !has_suspend_delay_id_)) { | |
| 485 LOG(ERROR) << "Received unrequested " << signal_name << " signal"; | |
| 451 return; | 486 return; |
| 452 } | 487 } |
| 453 | 488 |
| 454 dbus::MessageReader reader(signal); | 489 dbus::MessageReader reader(signal); |
| 455 power_manager::SuspendImminent proto; | 490 power_manager::SuspendImminent proto; |
| 456 if (!reader.PopArrayOfBytesAsProto(&proto)) { | 491 if (!reader.PopArrayOfBytesAsProto(&proto)) { |
| 457 LOG(ERROR) << "Unable to decode protocol buffer from " | 492 LOG(ERROR) << "Unable to decode protocol buffer from " << signal_name |
| 458 << power_manager::kSuspendImminentSignal << " signal"; | 493 << " signal"; |
| 459 return; | 494 return; |
| 460 } | 495 } |
| 461 | 496 |
| 462 VLOG(1) << "Got " << power_manager::kSuspendImminentSignal << " signal " | 497 VLOG(1) << "Got " << signal_name << " signal announcing suspend attempt " |
| 463 << "announcing suspend attempt " << proto.suspend_id(); | 498 << proto.suspend_id(); |
| 464 if (suspend_is_pending_) { | 499 |
| 465 LOG(WARNING) << "Got " << power_manager::kSuspendImminentSignal | 500 // If a previous suspend is pending from the same state we are currently in |
| 466 << " signal about pending suspend attempt " | 501 // (fully powered on or in dark resume), then something's gone a little |
| 467 << proto.suspend_id() << " while still waiting " | 502 // wonky. |
| 468 << "on attempt " << pending_suspend_id_; | 503 if (suspend_is_pending_ && |
| 504 suspending_from_dark_resume_ == in_dark_resume) { | |
| 505 LOG(WARNING) << "Got " << signal_name << " signal about pending suspend " | |
| 506 << "attempt " << proto.suspend_id() << " while still " | |
| 507 << "waiting on attempt " << pending_suspend_id_; | |
| 469 } | 508 } |
| 470 | 509 |
| 471 pending_suspend_id_ = proto.suspend_id(); | 510 pending_suspend_id_ = proto.suspend_id(); |
| 472 suspend_is_pending_ = true; | 511 suspend_is_pending_ = true; |
| 512 suspending_from_dark_resume_ = in_dark_resume; | |
| 473 num_pending_suspend_readiness_callbacks_ = 0; | 513 num_pending_suspend_readiness_callbacks_ = 0; |
| 474 FOR_EACH_OBSERVER(Observer, observers_, SuspendImminent()); | 514 if (suspending_from_dark_resume_) { |
|
Daniel Erat
2014/08/18 21:02:13
nit: omit curly brackets
| |
| 515 FOR_EACH_OBSERVER(Observer, observers_, DarkSuspendImminent()); | |
| 516 } else { | |
| 517 FOR_EACH_OBSERVER(Observer, observers_, SuspendImminent()); | |
| 518 } | |
| 475 MaybeReportSuspendReadiness(); | 519 MaybeReportSuspendReadiness(); |
| 476 } | 520 } |
| 477 | 521 |
| 478 void SuspendDoneReceived(dbus::Signal* signal) { | 522 void SuspendDoneReceived(dbus::Signal* signal) { |
| 479 dbus::MessageReader reader(signal); | 523 dbus::MessageReader reader(signal); |
| 480 power_manager::SuspendDone proto; | 524 power_manager::SuspendDone proto; |
| 481 if (!reader.PopArrayOfBytesAsProto(&proto)) { | 525 if (!reader.PopArrayOfBytesAsProto(&proto)) { |
| 482 LOG(ERROR) << "Unable to decode protocol buffer from " | 526 LOG(ERROR) << "Unable to decode protocol buffer from " |
| 483 << power_manager::kSuspendDoneSignal << " signal"; | 527 << power_manager::kSuspendDoneSignal << " signal"; |
| 484 return; | 528 return; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 549 case power_manager::InputEvent_Type_LID_CLOSED: { | 593 case power_manager::InputEvent_Type_LID_CLOSED: { |
| 550 bool open = | 594 bool open = |
| 551 (proto.type() == power_manager::InputEvent_Type_LID_OPEN); | 595 (proto.type() == power_manager::InputEvent_Type_LID_OPEN); |
| 552 FOR_EACH_OBSERVER(PowerManagerClient::Observer, observers_, | 596 FOR_EACH_OBSERVER(PowerManagerClient::Observer, observers_, |
| 553 LidEventReceived(open, timestamp)); | 597 LidEventReceived(open, timestamp)); |
| 554 break; | 598 break; |
| 555 } | 599 } |
| 556 } | 600 } |
| 557 } | 601 } |
| 558 | 602 |
| 559 // Registers a suspend delay with the power manager. This is usually | 603 // Registers suspend delays with the power manager. This is usually only |
| 560 // only called at startup, but if the power manager restarts, we need to | 604 // called at startup, but if the power manager restarts, we need to create new |
| 561 // create a new delay. | 605 // delays. |
| 562 void RegisterSuspendDelay() { | 606 void RegisterSuspendDelays() { |
| 563 // Throw out any old delay that was registered. | 607 // Throw out any old delay that was registered. |
| 564 suspend_delay_id_ = -1; | 608 suspend_delay_id_ = -1; |
| 565 has_suspend_delay_id_ = false; | 609 has_suspend_delay_id_ = false; |
| 610 dark_suspend_delay_id_ = -1; | |
| 611 has_dark_suspend_delay_id_ = false; | |
| 566 | 612 |
| 567 dbus::MethodCall method_call( | 613 dbus::MethodCall method_call( |
| 568 power_manager::kPowerManagerInterface, | 614 power_manager::kPowerManagerInterface, |
| 569 power_manager::kRegisterSuspendDelayMethod); | 615 power_manager::kRegisterSuspendDelayMethod); |
| 570 dbus::MessageWriter writer(&method_call); | 616 dbus::MessageWriter writer(&method_call); |
| 617 dbus::MethodCall dark_method_call( | |
| 618 power_manager::kPowerManagerInterface, | |
| 619 power_manager::kRegisterDarkSuspendDelayMethod); | |
| 620 dbus::MessageWriter dark_writer(&dark_method_call); | |
| 571 | 621 |
| 572 power_manager::RegisterSuspendDelayRequest protobuf_request; | 622 power_manager::RegisterSuspendDelayRequest protobuf_request; |
| 573 base::TimeDelta timeout = | 623 base::TimeDelta timeout = |
| 574 base::TimeDelta::FromMilliseconds(kSuspendDelayTimeoutMs); | 624 base::TimeDelta::FromMilliseconds(kSuspendDelayTimeoutMs); |
| 575 protobuf_request.set_timeout(timeout.ToInternalValue()); | 625 protobuf_request.set_timeout(timeout.ToInternalValue()); |
| 576 protobuf_request.set_description(kSuspendDelayDescription); | 626 protobuf_request.set_description(kSuspendDelayDescription); |
| 577 | 627 |
| 578 if (!writer.AppendProtoAsArrayOfBytes(protobuf_request)) { | 628 if (!writer.AppendProtoAsArrayOfBytes(protobuf_request)) { |
| 579 LOG(ERROR) << "Error constructing message for " | 629 LOG(ERROR) << "Error constructing message for " |
| 580 << power_manager::kRegisterSuspendDelayMethod; | 630 << power_manager::kRegisterSuspendDelayMethod; |
| 581 return; | 631 return; |
| 582 } | 632 } |
| 633 if (!dark_writer.AppendProtoAsArrayOfBytes(protobuf_request)) { | |
| 634 LOG(ERROR) << "Error constructing message for " | |
| 635 << power_manager::kRegisterDarkSuspendDelayMethod; | |
| 636 return; | |
| 637 } | |
| 583 power_manager_proxy_->CallMethod( | 638 power_manager_proxy_->CallMethod( |
| 584 &method_call, | 639 &method_call, |
| 585 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 640 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 586 base::Bind( | 641 base::Bind( |
| 587 &PowerManagerClientImpl::OnRegisterSuspendDelayReply, | 642 &PowerManagerClientImpl::OnRegisterSuspendDelayReply, |
| 588 weak_ptr_factory_.GetWeakPtr())); | 643 weak_ptr_factory_.GetWeakPtr())); |
| 644 power_manager_proxy_->CallMethod( | |
| 645 &dark_method_call, | |
| 646 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | |
| 647 base::Bind( | |
| 648 &PowerManagerClientImpl::OnRegisterDarkSuspendDelayReply, | |
| 649 weak_ptr_factory_.GetWeakPtr())); | |
| 589 } | 650 } |
| 590 | 651 |
| 591 // Records the fact that an observer has finished doing asynchronous work | 652 // Records the fact that an observer has finished doing asynchronous work |
| 592 // that was blocking a pending suspend attempt and possibly reports | 653 // that was blocking a pending suspend attempt and possibly reports |
| 593 // suspend readiness to powerd. Called by callbacks returned via | 654 // suspend readiness to powerd. Called by callbacks returned via |
| 594 // GetSuspendReadinessCallback(). | 655 // GetSuspendReadinessCallback(). |
| 595 void HandleObserverSuspendReadiness(int32 suspend_id) { | 656 void HandleObserverSuspendReadiness(int32 suspend_id) { |
| 596 DCHECK(OnOriginThread()); | 657 DCHECK(OnOriginThread()); |
| 597 if (!suspend_is_pending_ || suspend_id != pending_suspend_id_) | 658 if (!suspend_is_pending_ || suspend_id != pending_suspend_id_) |
| 598 return; | 659 return; |
| 599 | 660 |
| 600 num_pending_suspend_readiness_callbacks_--; | 661 num_pending_suspend_readiness_callbacks_--; |
| 601 MaybeReportSuspendReadiness(); | 662 MaybeReportSuspendReadiness(); |
| 602 } | 663 } |
| 603 | 664 |
| 604 // Reports suspend readiness to powerd if no observers are still holding | 665 // Reports suspend readiness to powerd if no observers are still holding |
| 605 // suspend readiness callbacks. | 666 // suspend readiness callbacks. |
| 606 void MaybeReportSuspendReadiness() { | 667 void MaybeReportSuspendReadiness() { |
| 607 if (!suspend_is_pending_ || num_pending_suspend_readiness_callbacks_ > 0) | 668 if (!suspend_is_pending_ || num_pending_suspend_readiness_callbacks_ > 0) |
| 608 return; | 669 return; |
| 609 | 670 |
| 671 std::string method_name; | |
| 672 int32 delay_id; | |
| 673 if (suspending_from_dark_resume_) { | |
| 674 method_name = power_manager::kHandleDarkSuspendReadinessMethod; | |
| 675 delay_id = dark_suspend_delay_id_; | |
| 676 } else { | |
| 677 method_name = power_manager::kHandleSuspendReadinessMethod; | |
| 678 delay_id = suspend_delay_id_; | |
| 679 } | |
| 680 | |
| 610 dbus::MethodCall method_call( | 681 dbus::MethodCall method_call( |
| 611 power_manager::kPowerManagerInterface, | 682 power_manager::kPowerManagerInterface, method_name); |
| 612 power_manager::kHandleSuspendReadinessMethod); | |
| 613 dbus::MessageWriter writer(&method_call); | 683 dbus::MessageWriter writer(&method_call); |
| 614 | 684 |
| 615 VLOG(1) << "Announcing readiness of suspend delay " << suspend_delay_id_ | 685 VLOG(1) << "Announcing readiness of suspend delay " << delay_id |
| 616 << " for suspend attempt " << pending_suspend_id_; | 686 << " for suspend attempt " << pending_suspend_id_; |
| 617 power_manager::SuspendReadinessInfo protobuf_request; | 687 power_manager::SuspendReadinessInfo protobuf_request; |
| 618 protobuf_request.set_delay_id(suspend_delay_id_); | 688 protobuf_request.set_delay_id(delay_id); |
| 619 protobuf_request.set_suspend_id(pending_suspend_id_); | 689 protobuf_request.set_suspend_id(pending_suspend_id_); |
| 620 | 690 |
| 621 pending_suspend_id_ = -1; | 691 pending_suspend_id_ = -1; |
| 622 suspend_is_pending_ = false; | 692 suspend_is_pending_ = false; |
| 623 | 693 |
| 624 if (!writer.AppendProtoAsArrayOfBytes(protobuf_request)) { | 694 if (!writer.AppendProtoAsArrayOfBytes(protobuf_request)) { |
| 625 LOG(ERROR) << "Error constructing message for " | 695 LOG(ERROR) << "Error constructing message for " << method_name; |
| 626 << power_manager::kHandleSuspendReadinessMethod; | |
| 627 return; | 696 return; |
| 628 } | 697 } |
| 629 power_manager_proxy_->CallMethod( | 698 power_manager_proxy_->CallMethod( |
| 630 &method_call, | 699 &method_call, |
| 631 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 700 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 632 dbus::ObjectProxy::EmptyResponseCallback()); | 701 dbus::ObjectProxy::EmptyResponseCallback()); |
| 633 } | 702 } |
| 634 | 703 |
| 635 // Origin thread (i.e. the UI thread in production). | 704 // Origin thread (i.e. the UI thread in production). |
| 636 base::PlatformThreadId origin_thread_id_; | 705 base::PlatformThreadId origin_thread_id_; |
| 637 | 706 |
| 638 dbus::ObjectProxy* power_manager_proxy_; | 707 dbus::ObjectProxy* power_manager_proxy_; |
| 639 ObserverList<Observer> observers_; | 708 ObserverList<Observer> observers_; |
| 640 | 709 |
| 641 // The delay_id_ obtained from the RegisterSuspendDelay request. | 710 // The delay_id_ obtained from the RegisterSuspendDelay request. |
| 642 int32 suspend_delay_id_; | 711 int32 suspend_delay_id_; |
| 643 bool has_suspend_delay_id_; | 712 bool has_suspend_delay_id_; |
| 644 | 713 |
| 714 // The delay_id_ obtained from the RegisterDarkSuspendDelay request. | |
| 715 int32 dark_suspend_delay_id_; | |
| 716 bool has_dark_suspend_delay_id_; | |
| 717 | |
| 645 // powerd-supplied ID corresponding to an imminent suspend attempt that is | 718 // powerd-supplied ID corresponding to an imminent suspend attempt that is |
| 646 // currently being delayed. | 719 // currently being delayed. |
| 647 int32 pending_suspend_id_; | 720 int32 pending_suspend_id_; |
| 648 bool suspend_is_pending_; | 721 bool suspend_is_pending_; |
| 722 bool suspending_from_dark_resume_; | |
| 649 | 723 |
| 650 // Number of callbacks that have been returned by | 724 // Number of callbacks that have been returned by |
| 651 // GetSuspendReadinessCallback() during the currently-pending suspend | 725 // GetSuspendReadinessCallback() during the currently-pending suspend |
| 652 // attempt but have not yet been called. | 726 // attempt but have not yet been called. |
| 653 int num_pending_suspend_readiness_callbacks_; | 727 int num_pending_suspend_readiness_callbacks_; |
| 654 | 728 |
| 655 // Last state passed to SetIsProjecting(). | 729 // Last state passed to SetIsProjecting(). |
| 656 bool last_is_projecting_; | 730 bool last_is_projecting_; |
| 657 | 731 |
| 658 // Note: This should remain the last member so it'll be destroyed and | 732 // Note: This should remain the last member so it'll be destroyed and |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 889 // static | 963 // static |
| 890 PowerManagerClient* PowerManagerClient::Create( | 964 PowerManagerClient* PowerManagerClient::Create( |
| 891 DBusClientImplementationType type) { | 965 DBusClientImplementationType type) { |
| 892 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 966 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
| 893 return new PowerManagerClientImpl(); | 967 return new PowerManagerClientImpl(); |
| 894 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 968 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
| 895 return new PowerManagerClientStubImpl(); | 969 return new PowerManagerClientStubImpl(); |
| 896 } | 970 } |
| 897 | 971 |
| 898 } // namespace chromeos | 972 } // namespace chromeos |
| OLD | NEW |