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 #include "chrome/browser/net/load_time_stats.h" | 5 #include "chrome/browser/net/load_time_stats.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/timer.h" | 10 #include "base/timer.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/io_thread.h" | 12 #include "chrome/browser/io_thread.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
15 #include "content/public/browser/render_process_host.h" | 15 #include "content/public/browser/render_process_host.h" |
16 #include "content/public/browser/render_view_host.h" | 16 #include "content/public/browser/render_view_host.h" |
17 #include "content/public/browser/resource_request_info.h" | 17 #include "content/public/browser/resource_request_info.h" |
18 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
19 #include "net/url_request/url_request.h" | 19 #include "net/url_request/url_request.h" |
20 | 20 |
21 using content::BrowserThread; | 21 using content::BrowserThread; |
22 using content::RenderViewHost; | 22 using content::RenderViewHost; |
23 using content::ResourceRequestInfo; | 23 using content::ResourceRequestInfo; |
24 using std::string; | 24 using std::string; |
25 | 25 |
| 26 DEFINE_WEB_CONTENTS_USER_DATA_KEY(chrome_browser_net::LoadTimeStatsTabHelper) |
| 27 |
26 namespace { | 28 namespace { |
27 | 29 |
28 bool GetRenderView(const net::URLRequest& request, | 30 bool GetRenderView(const net::URLRequest& request, |
29 int* process_id, int* route_id) { | 31 int* process_id, int* route_id) { |
30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 32 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
31 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(&request); | 33 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(&request); |
32 if (!info) | 34 if (!info) |
33 return false; | 35 return false; |
34 return info->GetAssociatedRenderView(process_id, route_id); | 36 return info->GetAssociatedRenderView(process_id, route_id); |
35 } | 37 } |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 private: | 249 private: |
248 base::TimeTicks GetCurrentTime() { | 250 base::TimeTicks GetCurrentTime() { |
249 return base::TimeTicks::Now(); | 251 return base::TimeTicks::Now(); |
250 } | 252 } |
251 bool done_; | 253 bool done_; |
252 base::TimeTicks start_time_; | 254 base::TimeTicks start_time_; |
253 RequestStatus status_; | 255 RequestStatus status_; |
254 base::TimeDelta status_times_[REQUEST_STATUS_MAX]; | 256 base::TimeDelta status_times_[REQUEST_STATUS_MAX]; |
255 }; | 257 }; |
256 | 258 |
257 int LoadTimeStatsTabHelper::kUserDataKey; | |
258 | |
259 LoadTimeStatsTabHelper::LoadTimeStatsTabHelper( | 259 LoadTimeStatsTabHelper::LoadTimeStatsTabHelper( |
260 content::WebContents* web_contents) | 260 content::WebContents* web_contents) |
261 : content::WebContentsObserver(web_contents) { | 261 : content::WebContentsObserver(web_contents) { |
262 is_otr_profile_ = web_contents->GetBrowserContext()->IsOffTheRecord(); | 262 is_otr_profile_ = web_contents->GetBrowserContext()->IsOffTheRecord(); |
263 } | 263 } |
264 | 264 |
265 LoadTimeStatsTabHelper::~LoadTimeStatsTabHelper() { | 265 LoadTimeStatsTabHelper::~LoadTimeStatsTabHelper() { |
266 } | 266 } |
267 | 267 |
268 void LoadTimeStatsTabHelper::DidStartProvisionalLoadForFrame( | 268 void LoadTimeStatsTabHelper::DidStartProvisionalLoadForFrame( |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 if (type == ChromeURLRequestContext::CONTEXT_TYPE_MAIN) | 546 if (type == ChromeURLRequestContext::CONTEXT_TYPE_MAIN) |
547 main_request_contexts_.insert(context); | 547 main_request_contexts_.insert(context); |
548 } | 548 } |
549 | 549 |
550 void LoadTimeStats::UnregisterURLRequestContext( | 550 void LoadTimeStats::UnregisterURLRequestContext( |
551 const net::URLRequestContext* context) { | 551 const net::URLRequestContext* context) { |
552 main_request_contexts_.erase(context); | 552 main_request_contexts_.erase(context); |
553 } | 553 } |
554 | 554 |
555 } // namespace chrome_browser_net | 555 } // namespace chrome_browser_net |
OLD | NEW |