Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(362)

Side by Side Diff: chromeos/dbus/debug_daemon_client.cc

Issue 10831059: debugd: Add GetNetworkInterfaces functionality. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add pointer to the documentation of the GetNetworkInterface json format. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chromeos/dbus/debug_daemon_client.h ('k') | chromeos/dbus/mock_debug_daemon_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 dbus::MethodCall method_call(debugd::kDebugdInterface, 224 dbus::MethodCall method_call(debugd::kDebugdInterface,
225 debugd::kGetModemStatus); 225 debugd::kGetModemStatus);
226 debugdaemon_proxy_->CallMethod( 226 debugdaemon_proxy_->CallMethod(
227 &method_call, 227 &method_call,
228 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 228 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
229 base::Bind(&DebugDaemonClientImpl::OnGetModemStatus, 229 base::Bind(&DebugDaemonClientImpl::OnGetModemStatus,
230 weak_ptr_factory_.GetWeakPtr(), 230 weak_ptr_factory_.GetWeakPtr(),
231 callback)); 231 callback));
232 } 232 }
233 233
234 virtual void GetNetworkInterfaces(
235 const GetNetworkInterfacesCallback& callback) OVERRIDE {
236 dbus::MethodCall method_call(debugd::kDebugdInterface,
237 debugd::kGetInterfaces);
238 debugdaemon_proxy_->CallMethod(
239 &method_call,
240 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
241 base::Bind(&DebugDaemonClientImpl::OnGetNetworkInterfaces,
242 weak_ptr_factory_.GetWeakPtr(),
243 callback));
244 }
245
234 virtual void GetAllLogs(const GetAllLogsCallback& callback) 246 virtual void GetAllLogs(const GetAllLogsCallback& callback)
235 OVERRIDE { 247 OVERRIDE {
236 dbus::MethodCall method_call(debugd::kDebugdInterface, 248 dbus::MethodCall method_call(debugd::kDebugdInterface,
237 "GetAllLogs"); 249 "GetAllLogs");
238 debugdaemon_proxy_->CallMethod( 250 debugdaemon_proxy_->CallMethod(
239 &method_call, 251 &method_call,
240 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 252 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
241 base::Bind(&DebugDaemonClientImpl::OnGetAllLogs, 253 base::Bind(&DebugDaemonClientImpl::OnGetAllLogs,
242 weak_ptr_factory_.GetWeakPtr(), 254 weak_ptr_factory_.GetWeakPtr(),
243 callback)); 255 callback));
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 379
368 void OnGetModemStatus(const GetModemStatusCallback& callback, 380 void OnGetModemStatus(const GetModemStatusCallback& callback,
369 dbus::Response* response) { 381 dbus::Response* response) {
370 std::string status; 382 std::string status;
371 if (response && dbus::MessageReader(response).PopString(&status)) 383 if (response && dbus::MessageReader(response).PopString(&status))
372 callback.Run(true, status); 384 callback.Run(true, status);
373 else 385 else
374 callback.Run(false, ""); 386 callback.Run(false, "");
375 } 387 }
376 388
389 void OnGetNetworkInterfaces(const GetNetworkInterfacesCallback& callback,
390 dbus::Response* response) {
391 std::string status;
392 if (response && dbus::MessageReader(response).PopString(&status))
393 callback.Run(true, status);
394 else
395 callback.Run(false, "");
396 }
397
377 void OnGetAllLogs(const GetAllLogsCallback& callback, 398 void OnGetAllLogs(const GetAllLogsCallback& callback,
378 dbus::Response* response) { 399 dbus::Response* response) {
379 std::map<std::string, std::string> logs; 400 std::map<std::string, std::string> logs;
380 bool broken = false; // did we see a broken (k,v) pair? 401 bool broken = false; // did we see a broken (k,v) pair?
381 dbus::MessageReader sub_reader(NULL); 402 dbus::MessageReader sub_reader(NULL);
382 if (!response || !dbus::MessageReader(response).PopArray(&sub_reader)) { 403 if (!response || !dbus::MessageReader(response).PopArray(&sub_reader)) {
383 callback.Run(false, logs); 404 callback.Run(false, logs);
384 return; 405 return;
385 } 406 }
386 while (sub_reader.HasMoreData()) { 407 while (sub_reader.HasMoreData()) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 } 493 }
473 virtual void GetRoutes(bool numeric, bool ipv6, 494 virtual void GetRoutes(bool numeric, bool ipv6,
474 const GetRoutesCallback& callback) OVERRIDE { 495 const GetRoutesCallback& callback) OVERRIDE {
475 std::vector<std::string> empty; 496 std::vector<std::string> empty;
476 callback.Run(false, empty); 497 callback.Run(false, empty);
477 } 498 }
478 virtual void GetNetworkStatus(const GetNetworkStatusCallback& callback) 499 virtual void GetNetworkStatus(const GetNetworkStatusCallback& callback)
479 OVERRIDE { 500 OVERRIDE {
480 callback.Run(false, ""); 501 callback.Run(false, "");
481 } 502 }
482 virtual void GetModemStatus(const GetNetworkStatusCallback& callback) 503 virtual void GetModemStatus(const GetModemStatusCallback& callback)
483 OVERRIDE { 504 OVERRIDE {
484 callback.Run(false, ""); 505 callback.Run(false, "");
485 } 506 }
507 virtual void GetNetworkInterfaces(
508 const GetNetworkInterfacesCallback& callback) OVERRIDE {
509 callback.Run(false, "");
510 }
486 virtual void GetAllLogs(const GetAllLogsCallback& callback) OVERRIDE { 511 virtual void GetAllLogs(const GetAllLogsCallback& callback) OVERRIDE {
487 std::map<std::string, std::string> empty; 512 std::map<std::string, std::string> empty;
488 callback.Run(false, empty); 513 callback.Run(false, empty);
489 } 514 }
490 }; 515 };
491 516
492 DebugDaemonClient::DebugDaemonClient() { 517 DebugDaemonClient::DebugDaemonClient() {
493 } 518 }
494 519
495 DebugDaemonClient::~DebugDaemonClient() { 520 DebugDaemonClient::~DebugDaemonClient() {
496 } 521 }
497 522
498 // static 523 // static
499 DebugDaemonClient::StopSystemTracingCallback 524 DebugDaemonClient::StopSystemTracingCallback
500 DebugDaemonClient::EmptyStopSystemTracingCallback() { 525 DebugDaemonClient::EmptyStopSystemTracingCallback() {
501 return base::Bind(&EmptyStopSystemTracingCallbackBody); 526 return base::Bind(&EmptyStopSystemTracingCallbackBody);
502 } 527 }
503 528
504 // static 529 // static
505 DebugDaemonClient* DebugDaemonClient::Create(DBusClientImplementationType type, 530 DebugDaemonClient* DebugDaemonClient::Create(DBusClientImplementationType type,
506 dbus::Bus* bus) { 531 dbus::Bus* bus) {
507 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) 532 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION)
508 return new DebugDaemonClientImpl(bus); 533 return new DebugDaemonClientImpl(bus);
509 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); 534 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type);
510 return new DebugDaemonClientStubImpl(); 535 return new DebugDaemonClientStubImpl();
511 } 536 }
512 537
513 } // namespace chromeos 538 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/debug_daemon_client.h ('k') | chromeos/dbus/mock_debug_daemon_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698