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

Side by Side Diff: blimp/net/blimp_connection_statistics.cc

Issue 1962393004: Added a debug info UI for Blimp (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Kevin's comments Created 4 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
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698