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

Side by Side Diff: remoting/host/process_stats_util.cc

Issue 2775983003: [Chromoting] Retrieve process resource usage (ProcessStats) and its tests (Closed)
Patch Set: thread_checker_ should be correctly constructed Created 3 years, 7 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
« no previous file with comments | « remoting/host/process_stats_util.h ('k') | remoting/proto/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "remoting/host/process_stats_util.h"
6
7 #include <stdint.h>
8
9 #include <string>
10 #include <utility>
11
12 namespace remoting {
13
14 bool IsEmptyProcessResourceUsage(const protocol::ProcessResourceUsage& usage) {
15 return !usage.has_process_name() && !usage.has_processor_usage() &&
16 !usage.has_working_set_size() && !usage.has_pagefile_size();
17 }
18
19 protocol::AggregatedProcessResourceUsage AggregateProcessResourceUsage(
20 const std::vector<protocol::ProcessResourceUsage>& usages) {
21 if (usages.empty()) {
22 return protocol::AggregatedProcessResourceUsage();
23 }
24
25 if (usages.size() == 1) {
26 const protocol::ProcessResourceUsage& usage = usages[0];
27 protocol::AggregatedProcessResourceUsage aggregated;
28 aggregated.set_name(usage.process_name());
29 aggregated.set_processor_usage(usage.processor_usage());
30 aggregated.set_working_set_size(usage.working_set_size());
31 aggregated.set_pagefile_size(usage.pagefile_size());
32 return aggregated;
33 }
34
35 std::string name = "aggregate { ";
36 double processor_usage = 0;
37 uint64_t working_set_size = 0;
38 uint64_t pagefile_size = 0;
39 protocol::AggregatedProcessResourceUsage aggregated;
40 for (const auto& usage : usages) {
41 name.append(usage.process_name()).append(", ");
42 processor_usage += usage.processor_usage();
43 working_set_size += usage.working_set_size();
44 pagefile_size += usage.pagefile_size();
45 *aggregated.add_usages() = usage;
46 }
47 name += " }";
48 aggregated.set_name(std::move(name));
49 aggregated.set_processor_usage(processor_usage);
50 aggregated.set_working_set_size(working_set_size);
51 aggregated.set_pagefile_size(pagefile_size);
52
53 return aggregated;
54 }
55
56 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/process_stats_util.h ('k') | remoting/proto/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698