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

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

Issue 268293002: Revert of Start session fail causes restart chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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
« no previous file with comments | « chromeos/dbus/session_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/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, 74 virtual void StartSession(const std::string& user_email) OVERRIDE {
75 const StartSessionCallback& callback) OVERRIDE {
76 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, 75 dbus::MethodCall method_call(login_manager::kSessionManagerInterface,
77 login_manager::kSessionManagerStartSession); 76 login_manager::kSessionManagerStartSession);
78 dbus::MessageWriter writer(&method_call); 77 dbus::MessageWriter writer(&method_call);
79 writer.AppendString(user_email); 78 writer.AppendString(user_email);
80 writer.AppendString(""); // Unique ID is deprecated 79 writer.AppendString(""); // Unique ID is deprecated
81 session_manager_proxy_->CallMethod( 80 session_manager_proxy_->CallMethod(
82 &method_call, 81 &method_call,
83 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 82 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
84 base::Bind(&SessionManagerClientImpl::OnStartSession, 83 base::Bind(&SessionManagerClientImpl::OnStartSession,
85 weak_ptr_factory_.GetWeakPtr(), 84 weak_ptr_factory_.GetWeakPtr()));
86 callback));
87 } 85 }
88 86
89 virtual void StopSession() OVERRIDE { 87 virtual void StopSession() OVERRIDE {
90 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, 88 dbus::MethodCall method_call(login_manager::kSessionManagerInterface,
91 login_manager::kSessionManagerStopSession); 89 login_manager::kSessionManagerStopSession);
92 dbus::MessageWriter writer(&method_call); 90 dbus::MessageWriter writer(&method_call);
93 writer.AppendString(""); // Unique ID is deprecated 91 writer.AppendString(""); // Unique ID is deprecated
94 session_manager_proxy_->CallMethod( 92 session_manager_proxy_->CallMethod(
95 &method_call, 93 &method_call,
96 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 94 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 } 325 }
328 326
329 // Called when kSessionManagerRestartJob method is complete. 327 // Called when kSessionManagerRestartJob method is complete.
330 void OnRestartJob(dbus::Response* response) { 328 void OnRestartJob(dbus::Response* response) {
331 LOG_IF(ERROR, !response) 329 LOG_IF(ERROR, !response)
332 << "Failed to call " 330 << "Failed to call "
333 << login_manager::kSessionManagerRestartJob; 331 << login_manager::kSessionManagerRestartJob;
334 } 332 }
335 333
336 // Called when kSessionManagerStartSession method is complete. 334 // Called when kSessionManagerStartSession method is complete.
337 void OnStartSession(const StartSessionCallback& callback, 335 void OnStartSession(dbus::Response* response) {
338 dbus::Response* response) { 336 LOG_IF(ERROR, !response)
339 bool success = false; 337 << "Failed to call "
340 if (!response) { 338 << login_manager::kSessionManagerStartSession;
341 LOG(ERROR) << "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);
349 } 339 }
350 340
351 // Called when kSessionManagerStopSession method is complete. 341 // Called when kSessionManagerStopSession method is complete.
352 void OnStopSession(dbus::Response* response) { 342 void OnStopSession(dbus::Response* response) {
353 LOG_IF(ERROR, !response) 343 LOG_IF(ERROR, !response)
354 << "Failed to call " 344 << "Failed to call "
355 << login_manager::kSessionManagerStopSession; 345 << login_manager::kSessionManagerStopSession;
356 } 346 }
357 347
358 // Called when kSessionManagerStopSession method is complete. 348 // Called when kSessionManagerStopSession method is complete.
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 observers_.AddObserver(observer); 511 observers_.AddObserver(observer);
522 } 512 }
523 virtual void RemoveObserver(Observer* observer) OVERRIDE { 513 virtual void RemoveObserver(Observer* observer) OVERRIDE {
524 observers_.RemoveObserver(observer); 514 observers_.RemoveObserver(observer);
525 } 515 }
526 virtual bool HasObserver(Observer* observer) OVERRIDE { 516 virtual bool HasObserver(Observer* observer) OVERRIDE {
527 return observers_.HasObserver(observer); 517 return observers_.HasObserver(observer);
528 } 518 }
529 virtual void EmitLoginPromptVisible() OVERRIDE {} 519 virtual void EmitLoginPromptVisible() OVERRIDE {}
530 virtual void RestartJob(int pid, const std::string& command_line) OVERRIDE {} 520 virtual void RestartJob(int pid, const std::string& command_line) OVERRIDE {}
531 virtual void StartSession(const std::string& user_email, 521 virtual void StartSession(const std::string& user_email) OVERRIDE {}
532 const StartSessionCallback& callback) OVERRIDE {
533 callback.Run(true);
534 }
535 virtual void StopSession() OVERRIDE {} 522 virtual void StopSession() OVERRIDE {}
536 virtual void StartDeviceWipe() OVERRIDE {} 523 virtual void StartDeviceWipe() OVERRIDE {}
537 virtual void RequestLockScreen() OVERRIDE { 524 virtual void RequestLockScreen() OVERRIDE {
538 if (delegate_) 525 if (delegate_)
539 delegate_->LockScreenForStub(); 526 delegate_->LockScreenForStub();
540 } 527 }
541 virtual void NotifyLockScreenShown() OVERRIDE { 528 virtual void NotifyLockScreenShown() OVERRIDE {
542 FOR_EACH_OBSERVER(Observer, observers_, ScreenIsLocked()); 529 FOR_EACH_OBSERVER(Observer, observers_, ScreenIsLocked());
543 } 530 }
544 virtual void NotifyLockScreenDismissed() OVERRIDE { 531 virtual void NotifyLockScreenDismissed() OVERRIDE {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 627
641 SessionManagerClient* SessionManagerClient::Create( 628 SessionManagerClient* SessionManagerClient::Create(
642 DBusClientImplementationType type) { 629 DBusClientImplementationType type) {
643 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) 630 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION)
644 return new SessionManagerClientImpl(); 631 return new SessionManagerClientImpl();
645 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); 632 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type);
646 return new SessionManagerClientStubImpl(); 633 return new SessionManagerClientStubImpl();
647 } 634 }
648 635
649 } // namespace chromeos 636 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/session_manager_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698