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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <sys/socket.h> | 9 #include <sys/socket.h> |
| 10 | 10 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 return; | 76 return; |
| 77 } | 77 } |
| 78 | 78 |
| 79 local_auth_fd->PutValue(sockets[0]); | 79 local_auth_fd->PutValue(sockets[0]); |
| 80 local_auth_fd->CheckValidity(); | 80 local_auth_fd->CheckValidity(); |
| 81 | 81 |
| 82 remote_auth_fd->PutValue(sockets[1]); | 82 remote_auth_fd->PutValue(sockets[1]); |
| 83 remote_auth_fd->CheckValidity(); | 83 remote_auth_fd->CheckValidity(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void HandleDBusError(dbus::ErrorResponse* response) { | |
| 87 LOG(ERROR) << "DBus error " << response->ToString(); | |
|
achuithb
2016/08/30 08:56:28
Add a null check, but please log something if you
| |
| 88 } | |
| 89 | |
| 90 } // namespace | 86 } // namespace |
| 91 | 87 |
| 92 // The SessionManagerClient implementation used in production. | 88 // The SessionManagerClient implementation used in production. |
| 93 class SessionManagerClientImpl : public SessionManagerClient { | 89 class SessionManagerClientImpl : public SessionManagerClient { |
| 94 public: | 90 public: |
| 95 SessionManagerClientImpl() | 91 SessionManagerClientImpl() |
| 96 : session_manager_proxy_(NULL), | 92 : session_manager_proxy_(NULL), |
| 97 screen_is_locked_(false), | 93 screen_is_locked_(false), |
| 98 weak_ptr_factory_(this) {} | 94 weak_ptr_factory_(this) {} |
| 99 | 95 |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 505 VLOG(1) << "CallRestartJobWithValidFd"; | 501 VLOG(1) << "CallRestartJobWithValidFd"; |
| 506 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, | 502 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, |
| 507 login_manager::kSessionManagerRestartJob); | 503 login_manager::kSessionManagerRestartJob); |
| 508 dbus::MessageWriter writer(&method_call); | 504 dbus::MessageWriter writer(&method_call); |
| 509 writer.AppendFileDescriptor(*remote_auth_fd); | 505 writer.AppendFileDescriptor(*remote_auth_fd); |
| 510 writer.AppendArrayOfStrings(argv); | 506 writer.AppendArrayOfStrings(argv); |
| 511 | 507 |
| 512 // Ownership of local_auth_fd is passed to the callback that is to be | 508 // Ownership of local_auth_fd is passed to the callback that is to be |
| 513 // called on completion of this method call. This keeps the browser end | 509 // called on completion of this method call. This keeps the browser end |
| 514 // of the socket-pair alive for the duration of the RPC. | 510 // of the socket-pair alive for the duration of the RPC. |
| 515 session_manager_proxy_->CallMethodWithErrorCallback( | 511 session_manager_proxy_->CallMethod( |
| 516 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 512 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 517 base::Bind(&SessionManagerClientImpl::OnRestartJob, | 513 base::Bind(&SessionManagerClientImpl::OnRestartJob, |
| 518 weak_ptr_factory_.GetWeakPtr(), | 514 weak_ptr_factory_.GetWeakPtr(), |
| 519 base::Passed(&local_auth_fd)), | 515 base::Passed(&local_auth_fd))); |
| 520 base::Bind(HandleDBusError)); | |
| 521 } | 516 } |
| 522 | 517 |
| 523 // Called when kSessionManagerRestartJob method is complete. | 518 // Called when kSessionManagerRestartJob method is complete. |
| 524 // Now that the call is complete, local_auth_fd can be closed and discarded, | 519 // Now that the call is complete, local_auth_fd can be closed and discarded, |
| 525 // which will happen automatically when it goes out of scope. | 520 // which will happen automatically when it goes out of scope. |
| 526 void OnRestartJob(dbus::ScopedFileDescriptor local_auth_fd, | 521 void OnRestartJob(dbus::ScopedFileDescriptor local_auth_fd, |
| 527 dbus::Response* response) { | 522 dbus::Response* response) { |
| 528 VLOG(1) << "OnRestartJob"; | 523 VLOG(1) << "OnRestartJob"; |
| 529 LOG_IF(ERROR, !response) | 524 LOG_IF(ERROR, !response) |
| 530 << "Failed to call " | 525 << "Failed to call " |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 978 | 973 |
| 979 SessionManagerClient* SessionManagerClient::Create( | 974 SessionManagerClient* SessionManagerClient::Create( |
| 980 DBusClientImplementationType type) { | 975 DBusClientImplementationType type) { |
| 981 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 976 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
| 982 return new SessionManagerClientImpl(); | 977 return new SessionManagerClientImpl(); |
| 983 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 978 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
| 984 return new SessionManagerClientStubImpl(); | 979 return new SessionManagerClientStubImpl(); |
| 985 } | 980 } |
| 986 | 981 |
| 987 } // namespace chromeos | 982 } // namespace chromeos |
| OLD | NEW |