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

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

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
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 #ifndef BLIMP_NET_BLIMP_CONNECTION_DETAILS_H_
6 #define BLIMP_NET_BLIMP_CONNECTION_DETAILS_H_
7
8 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h"
10 #include "blimp/net/blimp_net_export.h"
11
12 namespace blimp {
13
14 /**
15 * Observer to be notified in the event of network activities. Observer methods
16 * are to be called on UI thread.
17 */
18 class NetworkActivityObserver {
19 public:
20 virtual void UpdateDebugInfo(int received, int sent, int commits) = 0;
21 };
22
23 // Collects network traffic statistics. Maintains a counter for number of
24 // completed commits, bytes sent and received over network and notifies its
25 // observers on the main thread. Presents the data on a per navigation basis.
26 // This class is supposed to live an entire session, created and destroyed along
27 // it.
28 class BLIMP_NET_EXPORT BlimpConnectionDetails {
29 public:
30 BlimpConnectionDetails(
31 base::WeakPtr<NetworkActivityObserver> observer,
32 const scoped_refptr<base::TaskRunner>& main_thread_task_runner,
33 const scoped_refptr<base::TaskRunner>& io_thread_task_runner);
34
35 ~BlimpConnectionDetails();
36
37 void EnableDebugInfo(bool enable);
38
39 // Called on the IO thread.
40 void OnPacketReceived(int bytes);
41
42 // Called on the IO thread.
43 void OnPacketSent(int bytes);
44
45 // Called on the main thread.
46 void OnCommit();
47
48 // Called on the main thread.
49 void ResetStats();
50
51 private:
52 void ResetStatsOnIOThread();
53
54 // Flag to show/hide the debug data on blimp view.
55 bool debug_info_enabled_;
56
57 // Total number of bytes sent/received during a navigation. Accessed on IO
58 // thread.
59 int bytes_received_;
60 int bytes_sent_;
61
62 // Total number of commits completed on the client. Accessed on main thread.
63 int commits_;
64
65 base::WeakPtr<NetworkActivityObserver> observer_;
66 scoped_refptr<base::TaskRunner> main_thread_task_runner_;
67 scoped_refptr<base::TaskRunner> io_thread_task_runner_;
68 base::WeakPtrFactory<BlimpConnectionDetails> weak_factory_;
69
70 DISALLOW_COPY_AND_ASSIGN(BlimpConnectionDetails);
71 };
72
73 } // namespace blimp
74
75 #endif // BLIMP_NET_BLIMP_CONNECTION_DETAILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698