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

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

Issue 1962393004: Added a debug info UI for Blimp (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactored menu into ToolbarMenu 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
« no previous file with comments | « blimp/net/blimp_connection_details.h ('k') | blimp/net/blimp_message_pump.h » ('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 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_details.h"
6
7 #include "base/bind.h"
8 #include "base/logging.h"
9 #include "base/threading/thread.h"
10
11 namespace blimp {
12
13 BlimpConnectionDetails::BlimpConnectionDetails(
Kevin M 2016/05/18 18:38:28 The name "Connection Details" isn't a good fit her
shaktisahu 2016/05/19 21:39:19 Done.
14 base::WeakPtr<NetworkActivityObserver> observer,
15 const scoped_refptr<base::TaskRunner>& main_thread_task_runner,
16 const scoped_refptr<base::TaskRunner>& io_thread_task_runner)
17 : debug_info_enabled_(false),
18 bytes_received_(0),
19 bytes_sent_(0),
20 commits_(0),
21 observer_(observer),
22 main_thread_task_runner_(main_thread_task_runner),
23 io_thread_task_runner_(io_thread_task_runner),
24 weak_factory_(this) {}
25
26 BlimpConnectionDetails::~BlimpConnectionDetails() {}
27
28 void BlimpConnectionDetails::EnableDebugInfo(bool enable) {
29 debug_info_enabled_ = enable;
30 }
31
32 void BlimpConnectionDetails::OnPacketReceived(int bytes) {
33 bytes_received_ += bytes;
34 if (debug_info_enabled_) {
35 main_thread_task_runner_->PostTask(
36 FROM_HERE,
37 base::Bind(&NetworkActivityObserver::UpdateDebugInfo, observer_,
Kevin M 2016/05/18 18:38:28 I think that this push approach is really ineffici
Khushal 2016/05/18 20:41:10 I'm not sure how that will run, Java will make a c
shaktisahu 2016/05/19 21:39:19 Done.
38 bytes_received_, bytes_sent_, commits_));
39 }
40 }
41
42 void BlimpConnectionDetails::OnPacketSent(int bytes) {
Kevin M 2016/05/18 18:38:28 There is a lot of code duplication with the way th
shaktisahu 2016/05/19 21:39:19 Done.
43 bytes_sent_ += bytes;
44 if (debug_info_enabled_) {
45 main_thread_task_runner_->PostTask(
46 FROM_HERE,
47 base::Bind(&NetworkActivityObserver::UpdateDebugInfo, observer_,
48 bytes_received_, bytes_sent_, commits_));
49 }
50 }
51
52 void BlimpConnectionDetails::OnCommit() {
Khushal 2016/05/18 20:41:10 I think this call is made on the main thread, you
shaktisahu 2016/05/19 21:39:19 Done.
53 commits_++;
54 if (debug_info_enabled_) {
55 main_thread_task_runner_->PostTask(
56 FROM_HERE,
57 base::Bind(&NetworkActivityObserver::UpdateDebugInfo, observer_,
58 bytes_received_, bytes_sent_, commits_));
59 }
60 }
61
62 void BlimpConnectionDetails::ResetStats() {
Kevin M 2016/05/18 18:38:28 I don't think we should add resetting at this leve
Khushal 2016/05/18 20:41:10 We'll either way not have per navigation data even
shaktisahu 2016/05/19 21:39:19 Done.
63 io_thread_task_runner_->PostTask(
64 FROM_HERE, base::Bind(&BlimpConnectionDetails::ResetStatsOnIOThread,
65 weak_factory_.GetWeakPtr()));
66 commits_ = 0;
67 }
68
69 void BlimpConnectionDetails::ResetStatsOnIOThread() {
70 bytes_received_ = 0;
71 bytes_sent_ = 0;
72 }
73
74 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/net/blimp_connection_details.h ('k') | blimp/net/blimp_message_pump.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698