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

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

Issue 1218583002: metrics: Add dbus interface for GetRandomPerfOutput (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Create a scoped_ptr<TestIncognitoObserver> and return as scoped_ptr<WindowedIncognitoObserver> Created 5 years, 5 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
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 "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 <unistd.h> 8 #include <unistd.h>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 writer.AppendUint32(duration); 154 writer.AppendUint32(duration);
155 155
156 debugdaemon_proxy_->CallMethod( 156 debugdaemon_proxy_->CallMethod(
157 &method_call, 157 &method_call,
158 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 158 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
159 base::Bind(&DebugDaemonClientImpl::OnGetPerfData, 159 base::Bind(&DebugDaemonClientImpl::OnGetPerfData,
160 weak_ptr_factory_.GetWeakPtr(), 160 weak_ptr_factory_.GetWeakPtr(),
161 callback)); 161 callback));
162 } 162 }
163 163
164 void GetPerfOutput(uint32_t duration,
165 const GetPerfOutputCallback& callback) override {
166 dbus::MethodCall method_call(debugd::kDebugdInterface,
167 debugd::kGetRandomPerfOutput);
168 dbus::MessageWriter writer(&method_call);
169 writer.AppendUint32(duration);
170
171 debugdaemon_proxy_->CallMethod(
172 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
173 base::Bind(&DebugDaemonClientImpl::OnGetPerfOutput,
174 weak_ptr_factory_.GetWeakPtr(), callback));
175 }
176
164 void GetScrubbedLogs(const GetLogsCallback& callback) override { 177 void GetScrubbedLogs(const GetLogsCallback& callback) override {
165 dbus::MethodCall method_call(debugd::kDebugdInterface, 178 dbus::MethodCall method_call(debugd::kDebugdInterface,
166 debugd::kGetFeedbackLogs); 179 debugd::kGetFeedbackLogs);
167 debugdaemon_proxy_->CallMethod( 180 debugdaemon_proxy_->CallMethod(
168 &method_call, 181 &method_call,
169 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 182 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
170 base::Bind(&DebugDaemonClientImpl::OnGetAllLogs, 183 base::Bind(&DebugDaemonClientImpl::OnGetAllLogs,
171 weak_ptr_factory_.GetWeakPtr(), 184 weak_ptr_factory_.GetWeakPtr(),
172 callback)); 185 callback));
173 } 186 }
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 size_t buf_size = 0; 467 size_t buf_size = 0;
455 if (!reader.PopArrayOfBytes(&buffer, &buf_size)) 468 if (!reader.PopArrayOfBytes(&buffer, &buf_size))
456 return; 469 return;
457 470
458 // TODO(asharif): Figure out a way to avoid this copy. 471 // TODO(asharif): Figure out a way to avoid this copy.
459 data.insert(data.end(), buffer, buffer + buf_size); 472 data.insert(data.end(), buffer, buffer + buf_size);
460 473
461 callback.Run(data); 474 callback.Run(data);
462 } 475 }
463 476
477 void OnGetPerfOutput(const GetPerfOutputCallback& callback,
478 dbus::Response* response) {
479 if (!response) {
480 return;
481 }
stevenjb 2015/07/07 02:03:51 nit: no {}
Simon Que 2015/07/07 04:39:46 Done.
482
483 dbus::MessageReader reader(response);
484
485 int status = 0;
486 if (!reader.PopInt32(&status))
487 return;
488
489 const uint8* buffer = NULL;
stevenjb 2015/07/07 02:03:51 nullptr
Simon Que 2015/07/07 04:39:46 Done.
490 size_t buf_size = 0;
491
492 if (!reader.PopArrayOfBytes(&buffer, &buf_size))
493 return;
494 std::vector<uint8> perf_data;
495 if (buf_size > 0)
496 perf_data.insert(perf_data.end(), buffer, buffer + buf_size);
497
498 if (!reader.PopArrayOfBytes(&buffer, &buf_size))
499 return;
500 std::vector<uint8> perf_stat;
501 if (buf_size > 0)
502 perf_stat.insert(perf_stat.end(), buffer, buffer + buf_size);
503
504 callback.Run(status, perf_data, perf_stat);
505 }
506
464 void OnGetAllLogs(const GetLogsCallback& callback, 507 void OnGetAllLogs(const GetLogsCallback& callback,
465 dbus::Response* response) { 508 dbus::Response* response) {
466 std::map<std::string, std::string> logs; 509 std::map<std::string, std::string> logs;
467 bool broken = false; // did we see a broken (k,v) pair? 510 bool broken = false; // did we see a broken (k,v) pair?
468 dbus::MessageReader sub_reader(NULL); 511 dbus::MessageReader sub_reader(NULL);
469 if (!response || !dbus::MessageReader(response).PopArray(&sub_reader)) { 512 if (!response || !dbus::MessageReader(response).PopArray(&sub_reader)) {
470 callback.Run(false, logs); 513 callback.Run(false, logs);
471 return; 514 return;
472 } 515 }
473 while (sub_reader.HasMoreData()) { 516 while (sub_reader.HasMoreData()) {
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 DebugDaemonClient::EmptyStopSystemTracingCallback() { 659 DebugDaemonClient::EmptyStopSystemTracingCallback() {
617 return base::Bind(&EmptyStopSystemTracingCallbackBody); 660 return base::Bind(&EmptyStopSystemTracingCallbackBody);
618 } 661 }
619 662
620 // static 663 // static
621 DebugDaemonClient* DebugDaemonClient::Create() { 664 DebugDaemonClient* DebugDaemonClient::Create() {
622 return new DebugDaemonClientImpl(); 665 return new DebugDaemonClientImpl();
623 } 666 }
624 667
625 } // namespace chromeos 668 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698