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

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

Issue 2964613002: [Chromoting] Deprecate AggregatedProcessResourceUsage.* (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 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 "remoting/host/process_stats_sender.h" 5 #include "remoting/host/process_stats_sender.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "remoting/host/process_stats_agent.h" 11 #include "remoting/host/process_stats_agent.h"
12 #include "remoting/host/process_stats_util.h"
13 12
14 namespace remoting { 13 namespace remoting {
15 14
15 namespace {
16
17 bool IsEmptyProcessResourceUsage(const protocol::ProcessResourceUsage& usage) {
18 return !usage.has_process_name() && !usage.has_processor_usage() &&
joedow 2017/06/30 15:13:43 Is it ok to add a usage which is missing one of th
Hzj_jie 2017/06/30 22:39:29 Done.
19 !usage.has_working_set_size() && !usage.has_pagefile_size();
joedow 2017/06/30 15:13:43 I think the logic would be simpler if the method n
Hzj_jie 2017/06/30 22:39:29 Done.
20 }
21
22 } // namespace
23
16 ProcessStatsSender::ProcessStatsSender( 24 ProcessStatsSender::ProcessStatsSender(
17 protocol::ProcessStatsStub* host_stats_stub, 25 protocol::ProcessStatsStub* host_stats_stub,
18 base::TimeDelta interval, 26 base::TimeDelta interval,
19 std::initializer_list<ProcessStatsAgent*> agents) 27 std::initializer_list<ProcessStatsAgent*> agents)
20 : host_stats_stub_(host_stats_stub), 28 : host_stats_stub_(host_stats_stub),
21 agents_(agents), 29 agents_(agents),
22 thread_checker_() { 30 thread_checker_() {
23 DCHECK(thread_checker_.CalledOnValidThread()); 31 DCHECK(thread_checker_.CalledOnValidThread());
24 DCHECK(host_stats_stub_); 32 DCHECK(host_stats_stub_);
25 DCHECK(interval > base::TimeDelta()); 33 DCHECK(interval > base::TimeDelta());
26 DCHECK(!agents_.empty()); 34 DCHECK(!agents_.empty());
27 35
28 timer_.Start(FROM_HERE, interval, this, &ProcessStatsSender::ReportUsage); 36 timer_.Start(FROM_HERE, interval, this, &ProcessStatsSender::ReportUsage);
29 } 37 }
30 38
31 ProcessStatsSender::~ProcessStatsSender() { 39 ProcessStatsSender::~ProcessStatsSender() {
32 DCHECK(thread_checker_.CalledOnValidThread()); 40 DCHECK(thread_checker_.CalledOnValidThread());
33 timer_.Stop(); 41 timer_.Stop();
34 } 42 }
35 43
36 void ProcessStatsSender::ReportUsage() { 44 void ProcessStatsSender::ReportUsage() {
37 DCHECK(thread_checker_.CalledOnValidThread()); 45 DCHECK(thread_checker_.CalledOnValidThread());
38 46
39 std::vector<protocol::ProcessResourceUsage> usages; 47 protocol::AggregatedProcessResourceUsage aggregated;
40 for (auto* const agent : agents_) { 48 for (auto* const agent : agents_) {
41 DCHECK(agent); 49 DCHECK(agent);
42 protocol::ProcessResourceUsage usage = agent->GetResourceUsage(); 50 protocol::ProcessResourceUsage usage = agent->GetResourceUsage();
43 if (!IsEmptyProcessResourceUsage(usage)) { 51 if (!IsEmptyProcessResourceUsage(usage)) {
44 usages.push_back(std::move(usage)); 52 *aggregated.add_usages() = usage;
45 } 53 }
46 } 54 }
47 55
48 host_stats_stub_->OnProcessStats(AggregateProcessResourceUsage(usages)); 56 host_stats_stub_->OnProcessStats(aggregated);
49 } 57 }
50 58
51 } // namespace remoting 59 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698