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

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

Issue 2847743004: Revert of [Chromoting] Retrieve process resource usage (ProcessStats) and its tests (Closed)
Patch Set: 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_sender.h ('k') | remoting/host/process_stats_sender_unittest.cc » ('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_sender.h"
6
7 #include <utility>
8
9 #include "base/location.h"
10 #include "base/logging.h"
11 #include "remoting/host/process_stats_agent.h"
12 #include "remoting/host/process_stats_util.h"
13
14 namespace remoting {
15
16 ProcessStatsSender::ProcessStatsSender(
17 protocol::ProcessStatsStub* host_stats_stub,
18 base::TimeDelta interval,
19 std::initializer_list<ProcessStatsAgent*> agents)
20 : host_stats_stub_(host_stats_stub),
21 agents_(agents) {
22 DCHECK(thread_checker_.CalledOnValidThread());
23 DCHECK(host_stats_stub_);
24 DCHECK(!interval.is_zero());
25 DCHECK(!agents_.empty());
26
27 timer_.Start(FROM_HERE, interval, this, &ProcessStatsSender::ReportUsage);
28 }
29
30 ProcessStatsSender::~ProcessStatsSender() {
31 DCHECK(thread_checker_.CalledOnValidThread());
32 timer_.Stop();
33 }
34
35 void ProcessStatsSender::ReportUsage() {
36 DCHECK(thread_checker_.CalledOnValidThread());
37
38 std::vector<protocol::ProcessResourceUsage> usages;
39 for (auto* const agent : agents_) {
40 DCHECK(agent);
41 protocol::ProcessResourceUsage usage = agent->GetResourceUsage();
42 if (!IsEmptyProcessResourceUsage(usage)) {
43 usages.push_back(std::move(usage));
44 }
45 }
46
47 host_stats_stub_->OnProcessStats(AggregateProcessResourceUsage(usages));
48 }
49
50 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/process_stats_sender.h ('k') | remoting/host/process_stats_sender_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698