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