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

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

Issue 228703004: Start session fail causes restart chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed more browser tests Created 6 years, 8 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
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/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
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(),
86 callback));
85 } 87 }
86 88
87 virtual void StopSession() OVERRIDE { 89 virtual void StopSession() OVERRIDE {
88 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, 90 dbus::MethodCall method_call(login_manager::kSessionManagerInterface,
89 login_manager::kSessionManagerStopSession); 91 login_manager::kSessionManagerStopSession);
90 dbus::MessageWriter writer(&method_call); 92 dbus::MessageWriter writer(&method_call);
91 writer.AppendString(""); // Unique ID is deprecated 93 writer.AppendString(""); // Unique ID is deprecated
92 session_manager_proxy_->CallMethod( 94 session_manager_proxy_->CallMethod(
93 &method_call, 95 &method_call,
94 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 96 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 } 327 }
326 328
327 // Called when kSessionManagerRestartJob method is complete. 329 // Called when kSessionManagerRestartJob method is complete.
328 void OnRestartJob(dbus::Response* response) { 330 void OnRestartJob(dbus::Response* response) {
329 LOG_IF(ERROR, !response) 331 LOG_IF(ERROR, !response)
330 << "Failed to call " 332 << "Failed to call "
331 << login_manager::kSessionManagerRestartJob; 333 << login_manager::kSessionManagerRestartJob;
332 } 334 }
333 335
334 // Called when kSessionManagerStartSession method is complete. 336 // Called when kSessionManagerStartSession method is complete.
335 void OnStartSession(dbus::Response* response) { 337 void OnStartSession(const StartSessionCallback& callback,
336 LOG_IF(ERROR, !response) 338 dbus::Response* response) {
337 << "Failed to call " 339 bool success = false;
338 << login_manager::kSessionManagerStartSession; 340 if (!response) {
341 LOG(ERROR) << "Failed to call "
342 << login_manager::kSessionManagerStartSession;
343 } else {
344 dbus::MessageReader reader(response);
345 if (!reader.PopBool(&success))
Nikita (slow) 2014/04/18 05:22:59 I think response also has error string, please put
Roman Sorokin (ftl) 2014/04/22 08:28:47 Error string from dbus was logged in object_proxy
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
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 {
533 callback.Run(true);
534 }
522 virtual void StopSession() OVERRIDE {} 535 virtual void StopSession() OVERRIDE {}
523 virtual void StartDeviceWipe() OVERRIDE {} 536 virtual void StartDeviceWipe() OVERRIDE {}
524 virtual void RequestLockScreen() OVERRIDE { 537 virtual void RequestLockScreen() OVERRIDE {
525 if (delegate_) 538 if (delegate_)
526 delegate_->LockScreenForStub(); 539 delegate_->LockScreenForStub();
527 } 540 }
528 virtual void NotifyLockScreenShown() OVERRIDE { 541 virtual void NotifyLockScreenShown() OVERRIDE {
529 FOR_EACH_OBSERVER(Observer, observers_, ScreenIsLocked()); 542 FOR_EACH_OBSERVER(Observer, observers_, ScreenIsLocked());
530 } 543 }
531 virtual void NotifyLockScreenDismissed() OVERRIDE { 544 virtual void NotifyLockScreenDismissed() OVERRIDE {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 640
628 SessionManagerClient* SessionManagerClient::Create( 641 SessionManagerClient* SessionManagerClient::Create(
629 DBusClientImplementationType type) { 642 DBusClientImplementationType type) {
630 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) 643 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION)
631 return new SessionManagerClientImpl(); 644 return new SessionManagerClientImpl();
632 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); 645 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type);
633 return new SessionManagerClientStubImpl(); 646 return new SessionManagerClientStubImpl();
634 } 647 }
635 648
636 } // namespace chromeos 649 } // namespace chromeos
OLDNEW
« chromeos/dbus/fake_session_manager_client.cc ('K') | « chromeos/dbus/session_manager_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698