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

Unified Diff: remoting/host/chromoting_param_traits.cc

Issue 2964613002: [Chromoting] Deprecate AggregatedProcessResourceUsage.* (Closed)
Patch Set: Resolve review comments Created 3 years, 6 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/chromoting_param_traits.h ('k') | remoting/host/desktop_session_agent_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/chromoting_param_traits.cc
diff --git a/remoting/host/chromoting_param_traits.cc b/remoting/host/chromoting_param_traits.cc
index 0a5f26b372a7c96349f63f1345db4d272515a5b8..965c7cadc26007a9c807f4c5ad05d06caae9dd10 100644
--- a/remoting/host/chromoting_param_traits.cc
+++ b/remoting/host/chromoting_param_traits.cc
@@ -280,14 +280,31 @@ void ParamTraits<remoting::DesktopEnvironmentOptions>::Log(
l->append("DesktopEnvironmentOptions()");
}
+// static
+void ParamTraits<remoting::protocol::AggregatedProcessResourceUsage>::GetSize(
+ base::PickleSizer* s, const param_type& p) {
+ GetParamSize(s, p.usages_size());
+ for (int i = 0; i < p.usages_size(); i++) {
+ const auto& usage = p.usages().Get(i);
+ GetParamSize(s, usage.process_name());
+ GetParamSize(s, usage.processor_usage());
+ GetParamSize(s, usage.working_set_size());
+ GetParamSize(s, usage.pagefile_size());
+ }
+}
+
// static
void ParamTraits<remoting::protocol::AggregatedProcessResourceUsage>::Write(
base::Pickle* m,
const remoting::protocol::AggregatedProcessResourceUsage& p) {
- m->WriteString(p.name());
- m->WriteDouble(p.processor_usage());
- m->WriteUInt64(p.working_set_size());
- m->WriteUInt64(p.pagefile_size());
+ m->WriteInt(p.usages_size());
estark 2017/07/02 00:24:04 Can this be a WriteUint64?
Hzj_jie 2017/07/02 20:59:05 According to the generated code (https://cs.chromi
dcheng 2017/07/06 00:01:56 Since this is specified to return int (currently),
Hzj_jie 2017/07/06 00:45:37 Since RepeatedField<T> is a standard instead of an
dcheng 2017/07/06 08:08:10 Well, it seems like this CL introduces serializati
Hzj_jie 2017/07/07 00:59:49 Definitely, the change is at https://codereview.ch
+ for (int i = 0; i < p.usages_size(); i++) {
+ const auto& usage = p.usages().Get(i);
+ m->WriteString(usage.process_name());
+ m->WriteDouble(usage.processor_usage());
+ m->WriteUInt64(usage.working_set_size());
+ m->WriteUInt64(usage.pagefile_size());
+ }
}
// static
@@ -295,21 +312,30 @@ bool ParamTraits<remoting::protocol::AggregatedProcessResourceUsage>::Read(
const base::Pickle* m,
base::PickleIterator* iter,
remoting::protocol::AggregatedProcessResourceUsage* p) {
- std::string name;
- double processor_usage;
- uint64_t working_set_size;
- uint64_t pagefile_size;
- if (!iter->ReadString(&name) ||
- !iter->ReadDouble(&processor_usage) ||
- !iter->ReadUInt64(&working_set_size) ||
- !iter->ReadUInt64(&pagefile_size)) {
+ int usages_size = 0;
+ if (!iter->ReadInt(&usages_size)) {
return false;
}
- p->set_name(name);
- p->set_processor_usage(processor_usage);
- p->set_working_set_size(working_set_size);
- p->set_pagefile_size(pagefile_size);
+ for (int i = 0; i < usages_size; i++) {
dcheng 2017/07/06 00:01:57 Most importantly, that lets us consolidate checks
Hzj_jie 2017/07/06 00:45:37 I have replaced GetInt() with GetLength(). But I d
dcheng 2017/07/06 08:08:09 It won't crash here. But in general, it's preferab
Hzj_jie 2017/07/07 00:59:49 Got you. The newly prepared change should also fix
+ std::string process_name;
+ double processor_usage;
+ uint64_t working_set_size;
+ uint64_t pagefile_size;
+ if (!iter->ReadString(&process_name) ||
+ !iter->ReadDouble(&processor_usage) ||
+ !iter->ReadUInt64(&working_set_size) ||
+ !iter->ReadUInt64(&pagefile_size)) {
+ return false;
+ }
+
+ remoting::protocol::ProcessResourceUsage usage;
+ usage.set_process_name(process_name);
+ usage.set_processor_usage(processor_usage);
+ usage.set_working_set_size(working_set_size);
+ usage.set_pagefile_size(pagefile_size);
+ *p->add_usages() = usage;
+ }
return true;
}
« no previous file with comments | « remoting/host/chromoting_param_traits.h ('k') | remoting/host/desktop_session_agent_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698