| 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/debug_daemon_client.h" | 5 #include "chromeos/dbus/debug_daemon_client.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <unistd.h> | 10 #include <unistd.h> |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 sub_writer.CloseContainer(&elem_writer); | 459 sub_writer.CloseContainer(&elem_writer); |
| 460 } | 460 } |
| 461 writer.CloseContainer(&sub_writer); | 461 writer.CloseContainer(&sub_writer); |
| 462 | 462 |
| 463 debugdaemon_proxy_->CallMethod( | 463 debugdaemon_proxy_->CallMethod( |
| 464 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 464 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 465 base::Bind(&DebugDaemonClientImpl::OnSetOomScoreAdj, | 465 base::Bind(&DebugDaemonClientImpl::OnSetOomScoreAdj, |
| 466 weak_ptr_factory_.GetWeakPtr(), callback)); | 466 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 467 } | 467 } |
| 468 | 468 |
| 469 void CupsAddPrinter(const std::string& name, | 469 void CupsAddPrinter( |
| 470 const std::string& uri, | 470 const std::string& name, |
| 471 const std::string& ppd_path, | 471 const std::string& uri, |
| 472 bool ipp_everywhere, | 472 const std::string& ppd_path, |
| 473 const DebugDaemonClient::CupsAddPrinterCallback& callback, | 473 bool ipp_everywhere, |
| 474 const base::Closure& error_callback) override { | 474 const DebugDaemonClient::LegacyCupsAddPrinterCallback& callback, |
| 475 const base::Closure& error_callback) override { |
| 475 dbus::MethodCall method_call(debugd::kDebugdInterface, | 476 dbus::MethodCall method_call(debugd::kDebugdInterface, |
| 476 debugd::kCupsAddPrinter); | 477 debugd::kCupsAddPrinter); |
| 477 dbus::MessageWriter writer(&method_call); | 478 dbus::MessageWriter writer(&method_call); |
| 478 writer.AppendString(name); | 479 writer.AppendString(name); |
| 479 writer.AppendString(uri); | 480 writer.AppendString(uri); |
| 480 writer.AppendString(ppd_path); | 481 writer.AppendString(ppd_path); |
| 481 writer.AppendBool(ipp_everywhere); | 482 writer.AppendBool(ipp_everywhere); |
| 482 | 483 |
| 483 debugdaemon_proxy_->CallMethod( | 484 debugdaemon_proxy_->CallMethod( |
| 484 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 485 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 486 base::Bind(&DebugDaemonClientImpl::LegacyOnPrinterAdded, |
| 487 weak_ptr_factory_.GetWeakPtr(), callback, error_callback)); |
| 488 } |
| 489 |
| 490 void CupsAddManuallyConfiguredPrinter( |
| 491 const std::string& name, |
| 492 const std::string& uri, |
| 493 const std::string& ppd_contents, |
| 494 const DebugDaemonClient::CupsAddPrinterCallback& callback, |
| 495 const base::Closure& error_callback) override { |
| 496 dbus::MethodCall method_call(debugd::kDebugdInterface, |
| 497 debugd::kCupsAddManuallyConfiguredPrinter); |
| 498 dbus::MessageWriter writer(&method_call); |
| 499 writer.AppendString(name); |
| 500 writer.AppendString(uri); |
| 501 writer.AppendString(ppd_contents); |
| 502 |
| 503 debugdaemon_proxy_->CallMethod( |
| 504 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 485 base::Bind(&DebugDaemonClientImpl::OnPrinterAdded, | 505 base::Bind(&DebugDaemonClientImpl::OnPrinterAdded, |
| 486 weak_ptr_factory_.GetWeakPtr(), callback, error_callback)); | 506 weak_ptr_factory_.GetWeakPtr(), callback, error_callback)); |
| 487 } | 507 } |
| 508 |
| 509 void CupsAddAutoConfiguredPrinter( |
| 510 const std::string& name, |
| 511 const std::string& uri, |
| 512 const DebugDaemonClient::CupsAddPrinterCallback& callback, |
| 513 const base::Closure& error_callback) override { |
| 514 dbus::MethodCall method_call(debugd::kDebugdInterface, |
| 515 debugd::kCupsAddAutoConfiguredPrinter); |
| 516 dbus::MessageWriter writer(&method_call); |
| 517 writer.AppendString(name); |
| 518 writer.AppendString(uri); |
| 519 |
| 520 debugdaemon_proxy_->CallMethod( |
| 521 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 522 base::Bind(&DebugDaemonClientImpl::OnPrinterAdded, |
| 523 weak_ptr_factory_.GetWeakPtr(), callback, error_callback)); |
| 524 } |
| 488 | 525 |
| 489 void CupsRemovePrinter( | 526 void CupsRemovePrinter( |
| 490 const std::string& name, | 527 const std::string& name, |
| 491 const DebugDaemonClient::CupsRemovePrinterCallback& callback, | 528 const DebugDaemonClient::CupsRemovePrinterCallback& callback, |
| 492 const base::Closure& error_callback) override { | 529 const base::Closure& error_callback) override { |
| 493 dbus::MethodCall method_call(debugd::kDebugdInterface, | 530 dbus::MethodCall method_call(debugd::kDebugdInterface, |
| 494 debugd::kCupsRemovePrinter); | 531 debugd::kCupsRemovePrinter); |
| 495 dbus::MessageWriter writer(&method_call); | 532 dbus::MessageWriter writer(&method_call); |
| 496 writer.AppendString(name); | 533 writer.AppendString(name); |
| 497 | 534 |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 | 743 |
| 707 void OnSetOomScoreAdj(const SetOomScoreAdjCallback& callback, | 744 void OnSetOomScoreAdj(const SetOomScoreAdjCallback& callback, |
| 708 dbus::Response* response) { | 745 dbus::Response* response) { |
| 709 std::string output; | 746 std::string output; |
| 710 if (response && dbus::MessageReader(response).PopString(&output)) | 747 if (response && dbus::MessageReader(response).PopString(&output)) |
| 711 callback.Run(true, output); | 748 callback.Run(true, output); |
| 712 else | 749 else |
| 713 callback.Run(false, ""); | 750 callback.Run(false, ""); |
| 714 } | 751 } |
| 715 | 752 |
| 716 void OnPrinterAdded(const CupsAddPrinterCallback& callback, | 753 void LegacyOnPrinterAdded(const LegacyCupsAddPrinterCallback& callback, |
| 717 const base::Closure& error_callback, | 754 const base::Closure& error_callback, |
| 718 dbus::Response* response) { | 755 dbus::Response* response) { |
| 719 bool result = false; | 756 bool result = false; |
| 720 dbus::MessageReader reader(response); | 757 dbus::MessageReader reader(response); |
| 721 if (response && reader.PopBool(&result)) { | 758 if (response && reader.PopBool(&result)) { |
| 722 callback.Run(result); | 759 callback.Run(result); |
| 723 } else { | 760 } else { |
| 724 error_callback.Run(); | 761 error_callback.Run(); |
| 762 } |
| 763 } |
| 764 |
| 765 void OnPrinterAdded(const CupsAddPrinterCallback& callback, |
| 766 const base::Closure& error_callback, |
| 767 dbus::Response* response) { |
| 768 int32_t result; |
| 769 dbus::MessageReader reader(response); |
| 770 if (response && reader.PopInt32(&result)) { |
| 771 callback.Run(result); |
| 772 } else { |
| 773 error_callback.Run(); |
| 725 } | 774 } |
| 726 } | 775 } |
| 727 | 776 |
| 728 void OnPrinterRemoved(const CupsRemovePrinterCallback& callback, | 777 void OnPrinterRemoved(const CupsRemovePrinterCallback& callback, |
| 729 const base::Closure& error_callback, | 778 const base::Closure& error_callback, |
| 730 dbus::Response* response) { | 779 dbus::Response* response) { |
| 731 bool result = false; | 780 bool result = false; |
| 732 dbus::MessageReader reader(response); | 781 dbus::MessageReader reader(response); |
| 733 if (response && reader.PopBool(&result)) { | 782 if (response && reader.PopBool(&result)) { |
| 734 callback.Run(result); | 783 callback.Run(result); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 757 DebugDaemonClient::EmptyStopAgentTracingCallback() { | 806 DebugDaemonClient::EmptyStopAgentTracingCallback() { |
| 758 return base::Bind(&EmptyStopAgentTracingCallbackBody); | 807 return base::Bind(&EmptyStopAgentTracingCallbackBody); |
| 759 } | 808 } |
| 760 | 809 |
| 761 // static | 810 // static |
| 762 DebugDaemonClient* DebugDaemonClient::Create() { | 811 DebugDaemonClient* DebugDaemonClient::Create() { |
| 763 return new DebugDaemonClientImpl(); | 812 return new DebugDaemonClientImpl(); |
| 764 } | 813 } |
| 765 | 814 |
| 766 } // namespace chromeos | 815 } // namespace chromeos |
| OLD | NEW |