| 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 "dbus/message.h" | 5 #include "dbus/message.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 return signal; | 393 return signal; |
| 394 } | 394 } |
| 395 | 395 |
| 396 // | 396 // |
| 397 // Response implementation. | 397 // Response implementation. |
| 398 // | 398 // |
| 399 | 399 |
| 400 Response::Response() : Message() { | 400 Response::Response() : Message() { |
| 401 } | 401 } |
| 402 | 402 |
| 403 Response* Response::FromRawMessage(DBusMessage* raw_message) { | 403 scoped_ptr<Response> Response::FromRawMessage(DBusMessage* raw_message) { |
| 404 DCHECK_EQ(DBUS_MESSAGE_TYPE_METHOD_RETURN, | 404 DCHECK_EQ(DBUS_MESSAGE_TYPE_METHOD_RETURN, |
| 405 dbus_message_get_type(raw_message)); | 405 dbus_message_get_type(raw_message)); |
| 406 | 406 |
| 407 Response* response = new Response; | 407 scoped_ptr<Response> response(new Response); |
| 408 response->Init(raw_message); | 408 response->Init(raw_message); |
| 409 return response; | 409 return response.Pass(); |
| 410 } | 410 } |
| 411 | 411 |
| 412 Response* Response::FromMethodCall(MethodCall* method_call) { | 412 scoped_ptr<Response> Response::FromMethodCall(MethodCall* method_call) { |
| 413 Response* response = new Response; | 413 scoped_ptr<Response> response(new Response); |
| 414 response->Init(dbus_message_new_method_return(method_call->raw_message())); | 414 response->Init(dbus_message_new_method_return(method_call->raw_message())); |
| 415 return response; | 415 return response.Pass(); |
| 416 } | 416 } |
| 417 | 417 |
| 418 Response* Response::CreateEmpty() { | 418 scoped_ptr<Response> Response::CreateEmpty() { |
| 419 Response* response = new Response; | 419 scoped_ptr<Response> response(new Response); |
| 420 response->Init(dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN)); | 420 response->Init(dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN)); |
| 421 return response; | 421 return response.Pass(); |
| 422 } | 422 } |
| 423 |
| 423 // | 424 // |
| 424 // ErrorResponse implementation. | 425 // ErrorResponse implementation. |
| 425 // | 426 // |
| 426 | 427 |
| 427 ErrorResponse::ErrorResponse() : Response() { | 428 ErrorResponse::ErrorResponse() : Response() { |
| 428 } | 429 } |
| 429 | 430 |
| 430 ErrorResponse* ErrorResponse::FromRawMessage(DBusMessage* raw_message) { | 431 scoped_ptr<ErrorResponse> ErrorResponse::FromRawMessage( |
| 432 DBusMessage* raw_message) { |
| 431 DCHECK_EQ(DBUS_MESSAGE_TYPE_ERROR, dbus_message_get_type(raw_message)); | 433 DCHECK_EQ(DBUS_MESSAGE_TYPE_ERROR, dbus_message_get_type(raw_message)); |
| 432 | 434 |
| 433 ErrorResponse* response = new ErrorResponse; | 435 scoped_ptr<ErrorResponse> response(new ErrorResponse); |
| 434 response->Init(raw_message); | 436 response->Init(raw_message); |
| 435 return response; | 437 return response.Pass(); |
| 436 } | 438 } |
| 437 | 439 |
| 438 ErrorResponse* ErrorResponse::FromMethodCall( | 440 scoped_ptr<ErrorResponse> ErrorResponse::FromMethodCall( |
| 439 MethodCall* method_call, | 441 MethodCall* method_call, |
| 440 const std::string& error_name, | 442 const std::string& error_name, |
| 441 const std::string& error_message) { | 443 const std::string& error_message) { |
| 442 ErrorResponse* response = new ErrorResponse; | 444 scoped_ptr<ErrorResponse> response(new ErrorResponse); |
| 443 response->Init(dbus_message_new_error(method_call->raw_message(), | 445 response->Init(dbus_message_new_error(method_call->raw_message(), |
| 444 error_name.c_str(), | 446 error_name.c_str(), |
| 445 error_message.c_str())); | 447 error_message.c_str())); |
| 446 return response; | 448 return response.Pass(); |
| 447 } | 449 } |
| 448 | 450 |
| 449 // | 451 // |
| 450 // MessageWriter implementation. | 452 // MessageWriter implementation. |
| 451 // | 453 // |
| 452 | 454 |
| 453 MessageWriter::MessageWriter(Message* message) : | 455 MessageWriter::MessageWriter(Message* message) : |
| 454 message_(message), | 456 message_(message), |
| 455 container_is_open_(false) { | 457 container_is_open_(false) { |
| 456 memset(&raw_message_iter_, 0, sizeof(raw_message_iter_)); | 458 memset(&raw_message_iter_, 0, sizeof(raw_message_iter_)); |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 977 const bool success = PopBasic(DBUS_TYPE_UNIX_FD, &fd); | 979 const bool success = PopBasic(DBUS_TYPE_UNIX_FD, &fd); |
| 978 if (!success) | 980 if (!success) |
| 979 return false; | 981 return false; |
| 980 | 982 |
| 981 value->PutValue(fd); | 983 value->PutValue(fd); |
| 982 // NB: the caller must check validity before using the value | 984 // NB: the caller must check validity before using the value |
| 983 return true; | 985 return true; |
| 984 } | 986 } |
| 985 | 987 |
| 986 } // namespace dbus | 988 } // namespace dbus |
| OLD | NEW |