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

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

Issue 10736066: Adding histograms showing fraction of page load times (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_NET_CACHE_STATS_H_
6 #define CHROME_BROWSER_NET_CACHE_STATS_H_
7 #pragma once
8
9 #include <map>
10 #include <string>
11 #include <vector>
12
13 #include "base/basictypes.h"
14 #include "base/hash_tables.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/singleton.h"
17 #include "base/message_loop.h"
18 #include "base/time.h"
19 #include "content/public/browser/web_contents_observer.h"
20 #include "net/base/network_delegate.h"
21
22 class TabContents;
23
24 namespace base {
25 class Histogram;
26 }
27
28 namespace net {
29 class URLRequest;
30 }
31
32 namespace chrome_browser_net {
33
34 // This class collects UMA stats about cache performance.
35
36 class CacheStats : public MessageLoop::DestructionObserver {
mmenke 2012/07/19 17:55:34 Document this class - singleton, lives on IO threa
tburkard 2012/07/19 22:54:33 Done.
37 public:
38 enum TabEvent {
39 SPINNER_START,
40 SPINNER_STOP,
41 RENDERER_DESTROY
42 };
43 static CacheStats* GetInstance();
44 void OnCacheWaitStateChange(const net::URLRequest& request,
45 net::NetworkDelegate::CacheWaitState state);
46 void OnTabEvent(std::pair<int, int> render_view_id, TabEvent event);
47 virtual void WillDestroyCurrentMessageLoop() OVERRIDE;
48 virtual ~CacheStats();
49 private:
mmenke 2012/07/19 17:55:34 nit: Add blank line before "private"
tburkard 2012/07/19 22:54:33 Done.
50 friend struct DefaultSingletonTraits<CacheStats>;
51 struct TabLoadStats;
52
53 CacheStats();
54 TabLoadStats* GetTabLoadStats(std::pair<int, int> render_view_id);
55 void RemoveTabLoadStats(std::pair<int, int> render_view_id);
56 void ScheduleTimer(TabLoadStats* stats, int timer_index);
57 void TimerCb(TabLoadStats* stats, int timer_index);
58 void RecordCacheFractionHistogram(base::TimeDelta elapsed,
59 base::TimeDelta cache_time,
60 bool is_load_done);
mmenke 2012/07/19 17:55:34 These functions should be documented
tburkard 2012/07/19 22:54:33 Done.
61 typedef std::map< std::pair<int, int>, TabLoadStats*> TabLoadStatsMap;
mmenke 2012/07/19 17:55:34 typedefs should go before method declarations.
tburkard 2012/07/19 22:54:33 Done.
62 TabLoadStatsMap tab_load_stats_;
mmenke 2012/07/19 17:55:34 Please add a blank line before the class variables
tburkard 2012/07/19 22:54:33 Done.
63 std::vector<base::Histogram*> final_histograms_;
64 std::vector<base::Histogram*> intermediate_histograms_;
65 bool registered_message_loop_destruction_observer_;
66 };
mmenke 2012/07/19 17:55:34 Fix indent
tburkard 2012/07/19 22:54:33 Done.
67
68 class CacheStatsTabHelper : public content::WebContentsObserver {
mmenke 2012/07/19 17:55:34 Document the class.
tburkard 2012/07/19 22:54:33 Done.
69 public:
70 explicit CacheStatsTabHelper(TabContents* tab);
71 virtual void DidStartProvisionalLoadForFrame(
72 int64 frame_id,
73 bool is_main_frame,
74 const GURL& validated_url,
75 bool is_error_page,
76 content::RenderViewHost* render_view_host) OVERRIDE;
77 virtual void DidStopLoading() OVERRIDE;
78 virtual void RenderViewCreated(content::RenderViewHost* render_view_host)
79 OVERRIDE;
80 virtual ~CacheStatsTabHelper();
81 private:
mmenke 2012/07/19 17:55:34 nit: Add blank line before "private"
tburkard 2012/07/19 22:54:33 Done.
82 void NotifyCacheStats(CacheStats::TabEvent event);
mmenke 2012/07/19 17:55:34 This should be documented.
tburkard 2012/07/19 22:54:33 Done.
83 CacheStats* cache_stats_;
mmenke 2012/07/19 17:55:34 Please add a blank line before the class variables
tburkard 2012/07/19 22:54:33 Done.
84 bool is_loading_;
85 std::pair<int, int> render_view_id_;
86 bool render_view_id_initialized_;
87 };
88
89 } // namespace chrome_browser_net
90
91 #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