OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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 #include "chrome/browser/renderer_host/thread_hop_resource_throttle.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "base/bind_helpers.h" | |
9 #include "base/location.h" | |
10 #include "base/metrics/field_trial.h" | |
11 #include "base/metrics/histogram_macros.h" | |
12 #include "base/strings/string_util.h" | |
13 #include "base/time/time.h" | |
14 #include "content/public/browser/browser_thread.h" | |
15 #include "content/public/browser/resource_controller.h" | |
mmenke
2015/10/01 21:37:33
include header for RedirectInfo?
davidben
2015/10/01 22:06:25
The forward-decl from resource_throttle.h should b
mmenke
2015/10/01 22:12:20
Ah, right.
| |
16 | |
17 ThreadHopResourceThrottle::ThreadHopResourceThrottle() : weak_factory_(this) {} | |
18 | |
19 ThreadHopResourceThrottle::~ThreadHopResourceThrottle() {} | |
20 | |
21 // static | |
mmenke
2015/10/01 21:36:01
nit: New style guide doesn't require comments lik
davidben
2015/10/01 22:06:25
Really? I rather liked those. :-( Removed.
| |
22 bool ThreadHopResourceThrottle::IsEnabled() { | |
23 const std::string group_name = | |
24 base::FieldTrialList::FindFullName("ThreadHopResourceThrottle"); | |
25 return base::StartsWith(group_name, "Enabled", base::CompareCase::SENSITIVE); | |
26 } | |
27 | |
28 void ThreadHopResourceThrottle::WillStartRequest(bool* defer) { | |
29 *defer = true; | |
30 ResumeAfterThreadHop(); | |
31 } | |
32 | |
33 void ThreadHopResourceThrottle::WillRedirectRequest( | |
34 const net::RedirectInfo& redirect_info, | |
35 bool* defer) { | |
36 *defer = true; | |
37 ResumeAfterThreadHop(); | |
38 } | |
39 | |
40 void ThreadHopResourceThrottle::WillProcessResponse(bool* defer) { | |
41 *defer = true; | |
42 ResumeAfterThreadHop(); | |
43 } | |
44 | |
45 const char* ThreadHopResourceThrottle::GetNameForLogging() const { | |
46 return "ThreadHopResourceThrottle"; | |
47 } | |
48 | |
49 void ThreadHopResourceThrottle::ResumeAfterThreadHop() { | |
50 content::BrowserThread::PostTaskAndReply( | |
51 content::BrowserThread::UI, FROM_HERE, base::Bind(&base::DoNothing), | |
52 base::Bind(&ThreadHopResourceThrottle::Resume, weak_factory_.GetWeakPtr(), | |
53 base::TimeTicks::Now())); | |
54 } | |
55 | |
56 void ThreadHopResourceThrottle::Resume(const base::TimeTicks& time) { | |
57 UMA_HISTOGRAM_CUSTOM_TIMES("Net.ThreadHopResourceThrottleTime", | |
58 base::TimeTicks::Now() - time, | |
59 base::TimeDelta::FromSeconds(0), | |
mmenke
2015/10/01 21:36:01
base::TimeDelta()? Or base::TimeDelta::FromMillis
davidben
2015/10/01 22:06:25
Done.
| |
60 base::TimeDelta::FromMilliseconds(100), 100); | |
mmenke
2015/10/01 21:36:01
I don't think we need 100 buckets? I think even 2
davidben
2015/10/01 22:06:25
I mostly copied from elsewhere. You sure 20 is eno
mmenke
2015/10/01 22:12:20
I'm honestly not sure...I think 100 is way more th
| |
61 controller()->Resume(); | |
62 } | |
OLD | NEW |