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

Unified Diff: remoting/host/process_stats_sender.cc

Issue 2964613002: [Chromoting] Deprecate AggregatedProcessResourceUsage.* (Closed)
Patch Set: Use latest ipc_message_protobuf_utils to serialize and deserialize AggregatedProcessResourceUsage Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/desktop_session_agent_unittest.cc ('k') | remoting/host/process_stats_sender_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/process_stats_sender.cc
diff --git a/remoting/host/process_stats_sender.cc b/remoting/host/process_stats_sender.cc
index 7a2f7f8a2afe362f89984e744d4131ae9ceb234d..3ec1e2d3377d6672bcaf17fdb67a30ba9f342b45 100644
--- a/remoting/host/process_stats_sender.cc
+++ b/remoting/host/process_stats_sender.cc
@@ -9,10 +9,18 @@
#include "base/location.h"
#include "base/logging.h"
#include "remoting/host/process_stats_agent.h"
-#include "remoting/host/process_stats_util.h"
namespace remoting {
+namespace {
+
+bool IsProcessResourceUsageValid(const protocol::ProcessResourceUsage& usage) {
+ return usage.has_process_name() && usage.has_processor_usage() &&
+ usage.has_working_set_size() && usage.has_pagefile_size();
+}
+
+} // namespace
+
ProcessStatsSender::ProcessStatsSender(
protocol::ProcessStatsStub* host_stats_stub,
base::TimeDelta interval,
@@ -41,16 +49,20 @@ base::TimeDelta ProcessStatsSender::interval() const {
void ProcessStatsSender::ReportUsage() {
DCHECK(thread_checker_.CalledOnValidThread());
- std::vector<protocol::ProcessResourceUsage> usages;
+ protocol::AggregatedProcessResourceUsage aggregated;
for (auto* const agent : agents_) {
DCHECK(agent);
protocol::ProcessResourceUsage usage = agent->GetResourceUsage();
- if (!IsEmptyProcessResourceUsage(usage)) {
- usages.push_back(std::move(usage));
+ if (IsProcessResourceUsageValid(usage)) {
+ *aggregated.add_usages() = usage;
+ } else {
+ LOG(ERROR) << "Invalid ProcessResourceUsage "
+ << usage.process_name()
+ << " received.";
}
}
- host_stats_stub_->OnProcessStats(AggregateProcessResourceUsage(usages));
+ host_stats_stub_->OnProcessStats(aggregated);
}
} // namespace remoting
« no previous file with comments | « remoting/host/desktop_session_agent_unittest.cc ('k') | remoting/host/process_stats_sender_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698