OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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 <blimp/net/blimp_connection_statistics.h> | |
6 #include "base/bind.h" | |
7 #include "base/logging.h" | |
8 #include "base/threading/thread.h" | |
9 | |
10 namespace blimp { | |
11 | |
12 BlimpConnectionStatistics::BlimpConnectionStatistics( | |
13 const scoped_refptr<base::TaskRunner>& main_thread_task_runner) | |
14 : main_thread_task_runner_(main_thread_task_runner), weak_factory_(this) {} | |
15 | |
16 BlimpConnectionStatistics::~BlimpConnectionStatistics() {} | |
17 | |
18 void BlimpConnectionStatistics::Add(EventType type, int data) { | |
19 main_thread_task_runner_->PostTask( | |
20 FROM_HERE, base::Bind(&BlimpConnectionStatistics::AddOnMain, | |
21 weak_factory_.GetWeakPtr(), type, data)); | |
22 } | |
23 | |
24 void BlimpConnectionStatistics::Increment(EventType type) { | |
25 main_thread_task_runner_->PostTask( | |
26 FROM_HERE, base::Bind(&BlimpConnectionStatistics::IncrementOnMain, | |
27 weak_factory_.GetWeakPtr(), type)); | |
28 } | |
29 | |
30 void BlimpConnectionStatistics::AddOnMain(EventType type, int data) { | |
31 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); | |
32 statistics_[type] += data; | |
33 } | |
34 | |
35 void BlimpConnectionStatistics::IncrementOnMain(EventType type) { | |
Kevin M
2016/05/20 01:02:03
No need for this function; increment is basically
shaktisahu
2016/05/22 22:36:57
Ok.
| |
36 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); | |
37 statistics_[type]++; | |
38 } | |
39 | |
40 void BlimpConnectionStatistics::GetDebugInfo( | |
41 const base::Callback<void(StatisticsMap stats)>& callback) { | |
42 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); | |
43 VLOG(0) << "statistics_" << statistics_[BYTES_RECEIVED]; | |
Kevin M
2016/05/20 01:02:03
This logging line doesn't look very useful; remove
shaktisahu
2016/05/22 22:36:57
Done.
| |
44 callback.Run(statistics_); | |
45 } | |
46 | |
47 } // namespace blimp | |
OLD | NEW |