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

Side by Side Diff: chrome/browser/net/cache_stats.h

Issue 10834313: Add histograms for network activity, and total/cumulative (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/net/cache_stats.cc » ('j') | chrome/browser/net/cache_stats.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_NET_CACHE_STATS_H_ 5 #ifndef CHROME_BROWSER_NET_CACHE_STATS_H_
6 #define CHROME_BROWSER_NET_CACHE_STATS_H_ 6 #define CHROME_BROWSER_NET_CACHE_STATS_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 26 matching lines...) Expand all
37 std::size_t operator()(const net::URLRequestContext* value) const { 37 std::size_t operator()(const net::URLRequestContext* value) const {
38 return reinterpret_cast<std::size_t>(value); 38 return reinterpret_cast<std::size_t>(value);
39 } 39 }
40 }; 40 };
41 } 41 }
42 42
43 #endif 43 #endif
44 44
45 namespace chrome_browser_net { 45 namespace chrome_browser_net {
46 46
47 // This class collects UMA stats about cache performance. 47 // This class collects UMA stats about cache performance.
rvargas (doing something else) 2012/08/15 22:36:50 This is now stale. And the class name is outdated
tburkard 2012/08/15 23:00:47 What's a good new name? CacheNetworkStats? PageC
rvargas (doing something else) 2012/08/16 01:18:40 LoadTimeStats or NetStats sound good to me.
tburkard 2012/08/16 22:37:43 Done.
48 class CacheStats { 48 class CacheStats {
49 public: 49 public:
50 enum TabEvent { 50 enum TabEvent {
51 SPINNER_START, 51 SPINNER_START,
52 SPINNER_STOP 52 SPINNER_STOP
53 }; 53 };
54 enum RequestStatus {
55 REQUEST_STATUS_CACHE_WAIT,
56 REQUEST_STATUS_NETWORK_WAIT,
57 REQUEST_STATUS_ACTIVE,
58 REQUEST_STATUS_NONE,
59 REQUEST_STATUS_MAX
60 };
61 enum HistogramType {
62 HISTOGRAM_FINAL_AGGREGATE,
63 HISTOGRAM_FINAL_CUMULATIVE,
64 HISTOGRAM_FINAL_CUMULATIVE_PERCENTAGE,
65 HISTOGRAM_INTERMEDIATE_AGGREGATE,
66 HISTOGRAM_INTERMEDIATE_CUMULATIVE,
67 HISTOGRAM_INTERMEDIATE_CUMULATIVE_PERCENTAGE,
68 HISTOGRAM_MAX
69 };
70
54 CacheStats(); 71 CacheStats();
55 ~CacheStats(); 72 ~CacheStats();
56 73
57 void OnCacheWaitStateChange(const net::URLRequest& request, 74 void OnRequestWaitStateChange(const net::URLRequest& request,
58 net::NetworkDelegate::CacheWaitState state); 75 net::NetworkDelegate::RequestWaitState state);
59 void OnTabEvent(std::pair<int, int> render_view_id, TabEvent event); 76 void OnTabEvent(std::pair<int, int> render_view_id, TabEvent event);
60 void RegisterURLRequestContext(const net::URLRequestContext* context, 77 void RegisterURLRequestContext(const net::URLRequestContext* context,
61 ChromeURLRequestContext::ContextType type); 78 ChromeURLRequestContext::ContextType type);
62 void UnregisterURLRequestContext(const net::URLRequestContext* context); 79 void UnregisterURLRequestContext(const net::URLRequestContext* context);
63 80
64 private: 81 private:
65 struct TabLoadStats; 82 struct TabLoadStats;
66 // A map mapping a renderer's process id and route id to a TabLoadStats, 83 // A map mapping a renderer's process id and route id to a TabLoadStats,
67 // representing that renderer's load statistics. 84 // representing that renderer's load statistics.
68 typedef std::map<std::pair<int, int>, TabLoadStats*> TabLoadStatsMap; 85 typedef std::map<std::pair<int, int>, TabLoadStats*> TabLoadStatsMap;
69 86
70 // Gets TabLoadStats for a given RenderView. 87 // Gets TabLoadStats for a given RenderView.
71 TabLoadStats* GetTabLoadStats(std::pair<int, int> render_view_id); 88 TabLoadStats* GetTabLoadStats(std::pair<int, int> render_view_id);
72 // Deletes TabLoadStats no longer needed for a render view. 89 // Deletes TabLoadStats no longer needed for a render view.
73 void RemoveTabLoadStats(std::pair<int, int> render_view_id); 90 void RemoveTabLoadStats(std::pair<int, int> render_view_id);
74 // Sets a timer for a given tab to collect stats. |timer_index| indicates 91 // Sets a timer for a given tab to collect stats. |timer_index| indicates
75 // how many times stats have been collected since the navigation has started 92 // how many times stats have been collected since the navigation has started
76 // for this tab. 93 // for this tab.
77 void ScheduleTimer(TabLoadStats* stats); 94 void ScheduleTimer(TabLoadStats* stats);
78 // The callback when a timer fires to collect stats again. 95 // The callback when a timer fires to collect stats again.
79 void TimerCallback(TabLoadStats* stats); 96 void TimerCallback(TabLoadStats* stats);
80 // Helper function to put the current set of cache statistics into an UMA 97 // Helper function to put the current set of statistics into UMA histograms.
81 // histogram. 98 void RecordHistograms(base::TimeDelta elapsed,
82 void RecordCacheFractionHistogram(base::TimeDelta elapsed, 99 TabLoadStats* stats,
83 base::TimeDelta cache_time, 100 bool is_load_done);
84 bool is_load_done,
85 int timer_index);
86 101
87 TabLoadStatsMap tab_load_stats_; 102 TabLoadStatsMap tab_load_stats_;
88 std::vector<base::Histogram*> final_histograms_; 103 std::vector<base::Histogram*> histograms_[REQUEST_STATUS_MAX][HISTOGRAM_MAX];
89 std::vector<base::Histogram*> intermediate_histograms_;
90 base::hash_set<const net::URLRequestContext*> main_request_contexts_; 104 base::hash_set<const net::URLRequestContext*> main_request_contexts_;
91 105
92 DISALLOW_COPY_AND_ASSIGN(CacheStats); 106 DISALLOW_COPY_AND_ASSIGN(CacheStats);
93 }; 107 };
94 108
95 // A WebContentsObserver watching all tabs, notifying CacheStats 109 // A WebContentsObserver watching all tabs, notifying CacheStats
96 // whenever the spinner starts or stops for a given tab, and when a renderer 110 // whenever the spinner starts or stops for a given tab, and when a renderer
97 // is no longer used. 111 // is no longer used.
98 class CacheStatsTabHelper : public content::WebContentsObserver { 112 class CacheStatsTabHelper : public content::WebContentsObserver {
99 public: 113 public:
(...skipping 18 matching lines...) Expand all
118 132
119 CacheStats* cache_stats_; 133 CacheStats* cache_stats_;
120 bool is_otr_profile_; 134 bool is_otr_profile_;
121 135
122 DISALLOW_COPY_AND_ASSIGN(CacheStatsTabHelper); 136 DISALLOW_COPY_AND_ASSIGN(CacheStatsTabHelper);
123 }; 137 };
124 138
125 } // namespace chrome_browser_net 139 } // namespace chrome_browser_net
126 140
127 #endif // CHROME_BROWSER_NET_CACHE_STATS_H_ 141 #endif // CHROME_BROWSER_NET_CACHE_STATS_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/net/cache_stats.cc » ('j') | chrome/browser/net/cache_stats.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698