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 <fcntl.h> | 5 #include <fcntl.h> |
6 #include <unistd.h> | 6 #include <unistd.h> |
7 | 7 |
8 #include "chromeos/dbus/debug_daemon_client.h" | 8 #include "chromeos/dbus/debug_daemon_client.h" |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 dbus::MessageWriter writer(&method_call); | 340 dbus::MessageWriter writer(&method_call); |
341 writer.AppendString(ip_address); | 341 writer.AppendString(ip_address); |
342 debugdaemon_proxy_->CallMethod( | 342 debugdaemon_proxy_->CallMethod( |
343 &method_call, | 343 &method_call, |
344 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 344 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
345 base::Bind(&DebugDaemonClientImpl::OnTestICMP, | 345 base::Bind(&DebugDaemonClientImpl::OnTestICMP, |
346 weak_ptr_factory_.GetWeakPtr(), | 346 weak_ptr_factory_.GetWeakPtr(), |
347 callback)); | 347 callback)); |
348 } | 348 } |
349 | 349 |
| 350 virtual void TestICMPWithOptions( |
| 351 const std::string& ip_address, |
| 352 const std::map<std::string, std::string>& options, |
| 353 const TestICMPCallback& callback) OVERRIDE { |
| 354 dbus::MethodCall method_call(debugd::kDebugdInterface, |
| 355 debugd::kTestICMPWithOptions); |
| 356 dbus::MessageWriter writer(&method_call); |
| 357 dbus::MessageWriter sub_writer(NULL); |
| 358 dbus::MessageWriter elem_writer(NULL); |
| 359 |
| 360 // Write the host. |
| 361 writer.AppendString(ip_address); |
| 362 |
| 363 // Write the options. |
| 364 writer.OpenArray("{ss}", &sub_writer); |
| 365 std::map<std::string, std::string>::const_iterator it; |
| 366 for (it = options.begin(); it != options.end(); ++it) { |
| 367 sub_writer.OpenDictEntry(&elem_writer); |
| 368 elem_writer.AppendString(it->first); |
| 369 elem_writer.AppendString(it->second); |
| 370 sub_writer.CloseContainer(&elem_writer); |
| 371 } |
| 372 writer.CloseContainer(&sub_writer); |
| 373 |
| 374 // Call the function. |
| 375 debugdaemon_proxy_->CallMethod( |
| 376 &method_call, |
| 377 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 378 base::Bind(&DebugDaemonClientImpl::OnTestICMP, |
| 379 weak_ptr_factory_.GetWeakPtr(), |
| 380 callback)); |
| 381 } |
| 382 |
350 private: | 383 private: |
351 // Called to check descriptor validity on a thread where i/o is permitted. | 384 // Called to check descriptor validity on a thread where i/o is permitted. |
352 static void CheckValidity(dbus::FileDescriptor* file_descriptor) { | 385 static void CheckValidity(dbus::FileDescriptor* file_descriptor) { |
353 file_descriptor->CheckValidity(); | 386 file_descriptor->CheckValidity(); |
354 } | 387 } |
355 | 388 |
356 // Called when a CheckValidity response is received. | 389 // Called when a CheckValidity response is received. |
357 void OnCheckValidityGetDebugLogs(dbus::FileDescriptor* file_descriptor, | 390 void OnCheckValidityGetDebugLogs(dbus::FileDescriptor* file_descriptor, |
358 const GetDebugLogsCallback& callback) { | 391 const GetDebugLogsCallback& callback) { |
359 // Issue the dbus request to get debug logs. | 392 // Issue the dbus request to get debug logs. |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 user_logs["invalid_file"] = "Invalid File"; | 641 user_logs["invalid_file"] = "Invalid File"; |
609 base::MessageLoop::current()->PostTask(FROM_HERE, | 642 base::MessageLoop::current()->PostTask(FROM_HERE, |
610 base::Bind(callback, true, user_logs)); | 643 base::Bind(callback, true, user_logs)); |
611 } | 644 } |
612 | 645 |
613 virtual void TestICMP(const std::string& ip_address, | 646 virtual void TestICMP(const std::string& ip_address, |
614 const TestICMPCallback& callback) OVERRIDE { | 647 const TestICMPCallback& callback) OVERRIDE { |
615 base::MessageLoop::current()->PostTask(FROM_HERE, | 648 base::MessageLoop::current()->PostTask(FROM_HERE, |
616 base::Bind(callback, false, "")); | 649 base::Bind(callback, false, "")); |
617 } | 650 } |
| 651 |
| 652 virtual void TestICMPWithOptions( |
| 653 const std::string& ip_address, |
| 654 const std::map<std::string, std::string>& options, |
| 655 const TestICMPCallback& callback) OVERRIDE { |
| 656 base::MessageLoop::current()->PostTask( |
| 657 FROM_HERE, base::Bind(callback, false, "")); |
| 658 } |
618 }; | 659 }; |
619 | 660 |
620 DebugDaemonClient::DebugDaemonClient() { | 661 DebugDaemonClient::DebugDaemonClient() { |
621 } | 662 } |
622 | 663 |
623 DebugDaemonClient::~DebugDaemonClient() { | 664 DebugDaemonClient::~DebugDaemonClient() { |
624 } | 665 } |
625 | 666 |
626 // static | 667 // static |
627 DebugDaemonClient::StopSystemTracingCallback | 668 DebugDaemonClient::StopSystemTracingCallback |
628 DebugDaemonClient::EmptyStopSystemTracingCallback() { | 669 DebugDaemonClient::EmptyStopSystemTracingCallback() { |
629 return base::Bind(&EmptyStopSystemTracingCallbackBody); | 670 return base::Bind(&EmptyStopSystemTracingCallbackBody); |
630 } | 671 } |
631 | 672 |
632 // static | 673 // static |
633 DebugDaemonClient* DebugDaemonClient::Create(DBusClientImplementationType type, | 674 DebugDaemonClient* DebugDaemonClient::Create(DBusClientImplementationType type, |
634 dbus::Bus* bus) { | 675 dbus::Bus* bus) { |
635 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 676 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
636 return new DebugDaemonClientImpl(bus); | 677 return new DebugDaemonClientImpl(bus); |
637 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 678 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
638 return new DebugDaemonClientStubImpl(); | 679 return new DebugDaemonClientStubImpl(); |
639 } | 680 } |
640 | 681 |
641 } // namespace chromeos | 682 } // namespace chromeos |
OLD | NEW |