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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/net/cache_stats.cc » ('j') | chrome/browser/net/cache_stats.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/net/cache_stats.h
===================================================================
--- chrome/browser/net/cache_stats.h (revision 0)
+++ chrome/browser/net/cache_stats.h (revision 0)
@@ -0,0 +1,91 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_NET_CACHE_STATS_H_
+#define CHROME_BROWSER_NET_CACHE_STATS_H_
+#pragma once
+
+#include <map>
+#include <string>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/hash_tables.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/singleton.h"
+#include "base/message_loop.h"
+#include "base/time.h"
+#include "content/public/browser/web_contents_observer.h"
+#include "net/base/network_delegate.h"
+
+class TabContents;
+
+namespace base {
+class Histogram;
+}
+
+namespace net {
+class URLRequest;
+}
+
+namespace chrome_browser_net {
+
+// This class collects UMA stats about cache performance.
+
+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.
+ public:
+ enum TabEvent {
+ SPINNER_START,
+ SPINNER_STOP,
+ RENDERER_DESTROY
+ };
+ static CacheStats* GetInstance();
+ void OnCacheWaitStateChange(const net::URLRequest& request,
+ net::NetworkDelegate::CacheWaitState state);
+ void OnTabEvent(std::pair<int, int> render_view_id, TabEvent event);
+ virtual void WillDestroyCurrentMessageLoop() OVERRIDE;
+ virtual ~CacheStats();
+ private:
mmenke 2012/07/19 17:55:34 nit: Add blank line before "private"
tburkard 2012/07/19 22:54:33 Done.
+ friend struct DefaultSingletonTraits<CacheStats>;
+ struct TabLoadStats;
+
+ CacheStats();
+ TabLoadStats* GetTabLoadStats(std::pair<int, int> render_view_id);
+ void RemoveTabLoadStats(std::pair<int, int> render_view_id);
+ void ScheduleTimer(TabLoadStats* stats, int timer_index);
+ void TimerCb(TabLoadStats* stats, int timer_index);
+ void RecordCacheFractionHistogram(base::TimeDelta elapsed,
+ base::TimeDelta cache_time,
+ bool is_load_done);
mmenke 2012/07/19 17:55:34 These functions should be documented
tburkard 2012/07/19 22:54:33 Done.
+ 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.
+ 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.
+ std::vector<base::Histogram*> final_histograms_;
+ std::vector<base::Histogram*> intermediate_histograms_;
+ bool registered_message_loop_destruction_observer_;
+ };
mmenke 2012/07/19 17:55:34 Fix indent
tburkard 2012/07/19 22:54:33 Done.
+
+class CacheStatsTabHelper : public content::WebContentsObserver {
mmenke 2012/07/19 17:55:34 Document the class.
tburkard 2012/07/19 22:54:33 Done.
+ public:
+ explicit CacheStatsTabHelper(TabContents* tab);
+ virtual void DidStartProvisionalLoadForFrame(
+ int64 frame_id,
+ bool is_main_frame,
+ const GURL& validated_url,
+ bool is_error_page,
+ content::RenderViewHost* render_view_host) OVERRIDE;
+ virtual void DidStopLoading() OVERRIDE;
+ virtual void RenderViewCreated(content::RenderViewHost* render_view_host)
+ OVERRIDE;
+ virtual ~CacheStatsTabHelper();
+ private:
mmenke 2012/07/19 17:55:34 nit: Add blank line before "private"
tburkard 2012/07/19 22:54:33 Done.
+ void NotifyCacheStats(CacheStats::TabEvent event);
mmenke 2012/07/19 17:55:34 This should be documented.
tburkard 2012/07/19 22:54:33 Done.
+ 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.
+ bool is_loading_;
+ std::pair<int, int> render_view_id_;
+ bool render_view_id_initialized_;
+};
+
+} // namespace chrome_browser_net
+
+#endif // CHROME_BROWSER_NET_CACHE_STATS_H_
« 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