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/session_manager_client.h" | 5 #include "chromeos/dbus/session_manager_client.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 dbus::MessageWriter writer(&method_call); | 64 dbus::MessageWriter writer(&method_call); |
| 65 writer.AppendInt32(pid); | 65 writer.AppendInt32(pid); |
| 66 writer.AppendString(command_line); | 66 writer.AppendString(command_line); |
| 67 session_manager_proxy_->CallMethod( | 67 session_manager_proxy_->CallMethod( |
| 68 &method_call, | 68 &method_call, |
| 69 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 69 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 70 base::Bind(&SessionManagerClientImpl::OnRestartJob, | 70 base::Bind(&SessionManagerClientImpl::OnRestartJob, |
| 71 weak_ptr_factory_.GetWeakPtr())); | 71 weak_ptr_factory_.GetWeakPtr())); |
| 72 } | 72 } |
| 73 | 73 |
| 74 virtual void StartSession(const std::string& user_email) OVERRIDE { | 74 virtual void StartSession(const std::string& user_email, |
| 75 const StartSessionCallback& callback) OVERRIDE { | |
| 75 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, | 76 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, |
| 76 login_manager::kSessionManagerStartSession); | 77 login_manager::kSessionManagerStartSession); |
| 77 dbus::MessageWriter writer(&method_call); | 78 dbus::MessageWriter writer(&method_call); |
| 78 writer.AppendString(user_email); | 79 writer.AppendString(user_email); |
| 79 writer.AppendString(""); // Unique ID is deprecated | 80 writer.AppendString(""); // Unique ID is deprecated |
| 80 session_manager_proxy_->CallMethod( | 81 session_manager_proxy_->CallMethod( |
| 81 &method_call, | 82 &method_call, |
| 82 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 83 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 83 base::Bind(&SessionManagerClientImpl::OnStartSession, | 84 base::Bind(&SessionManagerClientImpl::OnStartSession, |
| 84 weak_ptr_factory_.GetWeakPtr())); | 85 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 85 } | 86 } |
| 86 | 87 |
| 87 virtual void StopSession() OVERRIDE { | 88 virtual void StopSession() OVERRIDE { |
| 88 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, | 89 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, |
| 89 login_manager::kSessionManagerStopSession); | 90 login_manager::kSessionManagerStopSession); |
| 90 dbus::MessageWriter writer(&method_call); | 91 dbus::MessageWriter writer(&method_call); |
| 91 writer.AppendString(""); // Unique ID is deprecated | 92 writer.AppendString(""); // Unique ID is deprecated |
| 92 session_manager_proxy_->CallMethod( | 93 session_manager_proxy_->CallMethod( |
| 93 &method_call, | 94 &method_call, |
| 94 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 95 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 325 } | 326 } |
| 326 | 327 |
| 327 // Called when kSessionManagerRestartJob method is complete. | 328 // Called when kSessionManagerRestartJob method is complete. |
| 328 void OnRestartJob(dbus::Response* response) { | 329 void OnRestartJob(dbus::Response* response) { |
| 329 LOG_IF(ERROR, !response) | 330 LOG_IF(ERROR, !response) |
| 330 << "Failed to call " | 331 << "Failed to call " |
| 331 << login_manager::kSessionManagerRestartJob; | 332 << login_manager::kSessionManagerRestartJob; |
| 332 } | 333 } |
| 333 | 334 |
| 334 // Called when kSessionManagerStartSession method is complete. | 335 // Called when kSessionManagerStartSession method is complete. |
| 335 void OnStartSession(dbus::Response* response) { | 336 void OnStartSession(const StartSessionCallback& callback, |
| 336 LOG_IF(ERROR, !response) | 337 dbus::Response* response) { |
| 337 << "Failed to call " | 338 bool success = false; |
| 338 << login_manager::kSessionManagerStartSession; | 339 if (!response) { |
| 340 LOG(ERROR) | |
|
ygorshenin1
2014/04/10 15:39:22
nit: move '<< "Failed to call "' to the previous l
Roman Sorokin (ftl)
2014/04/11 07:38:13
Done.
| |
| 341 << "Failed to call " | |
| 342 << login_manager::kSessionManagerStartSession; | |
| 343 } else { | |
| 344 dbus::MessageReader reader(response); | |
| 345 if (!reader.PopBool(&success)) | |
| 346 LOG(ERROR) << "Invalid response: " << response->ToString(); | |
| 347 } | |
| 348 callback.Run(success); | |
| 339 } | 349 } |
| 340 | 350 |
| 341 // Called when kSessionManagerStopSession method is complete. | 351 // Called when kSessionManagerStopSession method is complete. |
| 342 void OnStopSession(dbus::Response* response) { | 352 void OnStopSession(dbus::Response* response) { |
| 343 LOG_IF(ERROR, !response) | 353 LOG_IF(ERROR, !response) |
| 344 << "Failed to call " | 354 << "Failed to call " |
| 345 << login_manager::kSessionManagerStopSession; | 355 << login_manager::kSessionManagerStopSession; |
| 346 } | 356 } |
| 347 | 357 |
| 348 // Called when kSessionManagerStopSession method is complete. | 358 // Called when kSessionManagerStopSession method is complete. |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 511 observers_.AddObserver(observer); | 521 observers_.AddObserver(observer); |
| 512 } | 522 } |
| 513 virtual void RemoveObserver(Observer* observer) OVERRIDE { | 523 virtual void RemoveObserver(Observer* observer) OVERRIDE { |
| 514 observers_.RemoveObserver(observer); | 524 observers_.RemoveObserver(observer); |
| 515 } | 525 } |
| 516 virtual bool HasObserver(Observer* observer) OVERRIDE { | 526 virtual bool HasObserver(Observer* observer) OVERRIDE { |
| 517 return observers_.HasObserver(observer); | 527 return observers_.HasObserver(observer); |
| 518 } | 528 } |
| 519 virtual void EmitLoginPromptVisible() OVERRIDE {} | 529 virtual void EmitLoginPromptVisible() OVERRIDE {} |
| 520 virtual void RestartJob(int pid, const std::string& command_line) OVERRIDE {} | 530 virtual void RestartJob(int pid, const std::string& command_line) OVERRIDE {} |
| 521 virtual void StartSession(const std::string& user_email) OVERRIDE {} | 531 virtual void StartSession(const std::string& user_email, |
| 532 const StartSessionCallback& callback) OVERRIDE {} | |
| 522 virtual void StopSession() OVERRIDE {} | 533 virtual void StopSession() OVERRIDE {} |
| 523 virtual void StartDeviceWipe() OVERRIDE {} | 534 virtual void StartDeviceWipe() OVERRIDE {} |
| 524 virtual void RequestLockScreen() OVERRIDE { | 535 virtual void RequestLockScreen() OVERRIDE { |
| 525 if (delegate_) | 536 if (delegate_) |
| 526 delegate_->LockScreenForStub(); | 537 delegate_->LockScreenForStub(); |
| 527 } | 538 } |
| 528 virtual void NotifyLockScreenShown() OVERRIDE { | 539 virtual void NotifyLockScreenShown() OVERRIDE { |
| 529 FOR_EACH_OBSERVER(Observer, observers_, ScreenIsLocked()); | 540 FOR_EACH_OBSERVER(Observer, observers_, ScreenIsLocked()); |
| 530 } | 541 } |
| 531 virtual void NotifyLockScreenDismissed() OVERRIDE { | 542 virtual void NotifyLockScreenDismissed() OVERRIDE { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 627 | 638 |
| 628 SessionManagerClient* SessionManagerClient::Create( | 639 SessionManagerClient* SessionManagerClient::Create( |
| 629 DBusClientImplementationType type) { | 640 DBusClientImplementationType type) { |
| 630 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 641 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
| 631 return new SessionManagerClientImpl(); | 642 return new SessionManagerClientImpl(); |
| 632 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 643 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
| 633 return new SessionManagerClientStubImpl(); | 644 return new SessionManagerClientStubImpl(); |
| 634 } | 645 } |
| 635 | 646 |
| 636 } // namespace chromeos | 647 } // namespace chromeos |
| OLD | NEW |