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

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,84 @@
+// 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 {
+ public:
+ static CacheStats* GetInstance();
+ void OnCacheWaitStateChange(const net::URLRequest& request,
+ net::NetworkDelegate::CacheWaitState state);
+ void OnTabSpinnerChange(std::pair<int, int> render_view_id, bool loading);
+ virtual void WillDestroyCurrentMessageLoop() OVERRIDE;
+ virtual ~CacheStats();
+ private:
+ friend struct DefaultSingletonTraits<CacheStats>;
+ struct TabLoadStats;
+
+ CacheStats();
+ TabLoadStats* GetTabLoadStats(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);
+ std::map< std::pair<int, int>, TabLoadStats*> tab_load_stats_;
+ std::vector<base::Histogram*> final_histograms_;
+ std::vector<base::Histogram*> intermediate_histograms_;
+ bool registered_message_loop_destruction_observer_;
+ };
+
+class CacheStatsTabHelper : public content::WebContentsObserver {
+ 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:
+ void NotifyCacheStats(bool loading);
+ CacheStats* cache_stats_;
+ 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