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

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 {
37 public:
38 static CacheStats* GetInstance();
39 void OnCacheWaitStateChange(const net::URLRequest& request,
40 net::NetworkDelegate::CacheWaitState state);
41 void OnTabSpinnerChange(std::pair<int, int> render_view_id, bool loading);
42 virtual void WillDestroyCurrentMessageLoop() OVERRIDE;
43 virtual ~CacheStats();
44 private:
45 friend struct DefaultSingletonTraits<CacheStats>;
46 struct TabLoadStats;
47
48 CacheStats();
49 TabLoadStats* GetTabLoadStats(std::pair<int, int> render_view_id);
50 void ScheduleTimer(TabLoadStats* stats, int timer_index);
51 void TimerCb(TabLoadStats* stats, int timer_index);
52 void RecordCacheFractionHistogram(base::TimeDelta elapsed,
53 base::TimeDelta cache_time,
54 bool is_load_done);
55 std::map< std::pair<int, int>, TabLoadStats*> tab_load_stats_;
56 std::vector<base::Histogram*> final_histograms_;
57 std::vector<base::Histogram*> intermediate_histograms_;
58 bool registered_message_loop_destruction_observer_;
59 };
60
61 class CacheStatsTabHelper : public content::WebContentsObserver {
62 public:
63 explicit CacheStatsTabHelper(TabContents* tab);
64 virtual void DidStartProvisionalLoadForFrame(
65 int64 frame_id,
66 bool is_main_frame,
67 const GURL& validated_url,
68 bool is_error_page,
69 content::RenderViewHost* render_view_host) OVERRIDE;
70 virtual void DidStopLoading() OVERRIDE;
71 virtual void RenderViewCreated(content::RenderViewHost* render_view_host)
72 OVERRIDE;
73 virtual ~CacheStatsTabHelper();
74 private:
75 void NotifyCacheStats(bool loading);
76 CacheStats* cache_stats_;
77 bool is_loading_;
78 std::pair<int, int> render_view_id_;
79 bool render_view_id_initialized_;
80 };
81
82 } // namespace chrome_browser_net
83
84 #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