| OLD | NEW |
| 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_LOAD_TIME_STATS_H_ | 5 #ifndef CHROME_BROWSER_NET_LOAD_TIME_STATS_H_ |
| 6 #define CHROME_BROWSER_NET_LOAD_TIME_STATS_H_ | 6 #define CHROME_BROWSER_NET_LOAD_TIME_STATS_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/hash_tables.h" | 13 #include "base/hash_tables.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
| 16 #include "base/time.h" | 16 #include "base/time.h" |
| 17 #include "chrome/browser/net/chrome_url_request_context.h" | 17 #include "chrome/browser/net/chrome_url_request_context.h" |
| 18 #include "chrome/browser/tab_contents/web_contents_user_data.h" |
| 18 #include "content/public/browser/web_contents_observer.h" | 19 #include "content/public/browser/web_contents_observer.h" |
| 19 #include "net/base/network_delegate.h" | 20 #include "net/base/network_delegate.h" |
| 20 | 21 |
| 21 class TabContents; | |
| 22 | |
| 23 namespace base { | 22 namespace base { |
| 24 class Histogram; | 23 class Histogram; |
| 25 } | 24 } |
| 26 | 25 |
| 27 namespace net { | 26 namespace net { |
| 28 class URLRequest; | 27 class URLRequest; |
| 29 class URLRequestContext; | 28 class URLRequestContext; |
| 30 } | 29 } |
| 31 | 30 |
| 32 #if defined(COMPILER_GCC) | 31 #if defined(COMPILER_GCC) |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 bool is_load_done); | 110 bool is_load_done); |
| 112 | 111 |
| 113 TabLoadStatsMap tab_load_stats_; | 112 TabLoadStatsMap tab_load_stats_; |
| 114 RequestStatsMap request_stats_; | 113 RequestStatsMap request_stats_; |
| 115 std::vector<base::Histogram*> histograms_[REQUEST_STATUS_MAX][HISTOGRAM_MAX]; | 114 std::vector<base::Histogram*> histograms_[REQUEST_STATUS_MAX][HISTOGRAM_MAX]; |
| 116 base::hash_set<const net::URLRequestContext*> main_request_contexts_; | 115 base::hash_set<const net::URLRequestContext*> main_request_contexts_; |
| 117 | 116 |
| 118 DISALLOW_COPY_AND_ASSIGN(LoadTimeStats); | 117 DISALLOW_COPY_AND_ASSIGN(LoadTimeStats); |
| 119 }; | 118 }; |
| 120 | 119 |
| 121 // A WebContentsObserver watching all tabs, notifying LoadTimeStats | 120 // A WebContentsObserver watching a tab, notifying LoadTimeStats whenever the |
| 122 // whenever the spinner starts or stops for a given tab, and when a renderer | 121 // spinner starts or stops for it, and whenever a renderer is no longer used. |
| 123 // is no longer used. | 122 class LoadTimeStatsTabHelper |
| 124 class LoadTimeStatsTabHelper : public content::WebContentsObserver { | 123 : public content::WebContentsObserver, |
| 124 public WebContentsUserData<LoadTimeStatsTabHelper> { |
| 125 public: | 125 public: |
| 126 explicit LoadTimeStatsTabHelper(TabContents* tab); | |
| 127 virtual ~LoadTimeStatsTabHelper(); | 126 virtual ~LoadTimeStatsTabHelper(); |
| 128 | 127 |
| 129 // content::WebContentsObserver implementation | 128 // content::WebContentsObserver implementation |
| 130 virtual void DidStartProvisionalLoadForFrame( | 129 virtual void DidStartProvisionalLoadForFrame( |
| 131 int64 frame_id, | 130 int64 frame_id, |
| 132 bool is_main_frame, | 131 bool is_main_frame, |
| 133 const GURL& validated_url, | 132 const GURL& validated_url, |
| 134 bool is_error_page, | 133 bool is_error_page, |
| 135 content::RenderViewHost* render_view_host) OVERRIDE; | 134 content::RenderViewHost* render_view_host) OVERRIDE; |
| 136 virtual void DidStopLoading( | 135 virtual void DidStopLoading( |
| 137 content::RenderViewHost* render_view_host) OVERRIDE; | 136 content::RenderViewHost* render_view_host) OVERRIDE; |
| 138 | 137 |
| 139 private: | 138 private: |
| 139 explicit LoadTimeStatsTabHelper(content::WebContents* web_contents); |
| 140 static int kUserDataKey; |
| 141 friend class WebContentsUserData<LoadTimeStatsTabHelper>; |
| 142 |
| 140 // Calls into LoadTimeStats to notify that a reportable event has occurred | 143 // Calls into LoadTimeStats to notify that a reportable event has occurred |
| 141 // for the tab being observed. | 144 // for the tab being observed. |
| 142 void NotifyLoadTimeStats(LoadTimeStats::TabEvent event, | 145 void NotifyLoadTimeStats(LoadTimeStats::TabEvent event, |
| 143 content::RenderViewHost* render_view_host); | 146 content::RenderViewHost* render_view_host); |
| 144 | 147 |
| 145 bool is_otr_profile_; | 148 bool is_otr_profile_; |
| 146 | 149 |
| 147 DISALLOW_COPY_AND_ASSIGN(LoadTimeStatsTabHelper); | 150 DISALLOW_COPY_AND_ASSIGN(LoadTimeStatsTabHelper); |
| 148 }; | 151 }; |
| 149 | 152 |
| 150 } // namespace chrome_browser_net | 153 } // namespace chrome_browser_net |
| 151 | 154 |
| 152 #endif // CHROME_BROWSER_NET_LOAD_TIME_STATS_H_ | 155 #endif // CHROME_BROWSER_NET_LOAD_TIME_STATS_H_ |
| OLD | NEW |