OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/renderer/net/prescient_networking_dispatcher.h" | 5 #include "chrome/renderer/net/prescient_networking_dispatcher.h" |
6 | 6 |
7 #include "base/metrics/field_trial.h" | |
7 #include "chrome/common/render_messages.h" | 8 #include "chrome/common/render_messages.h" |
8 #include "content/public/renderer/render_thread.h" | 9 #include "content/public/renderer/render_thread.h" |
9 | 10 |
10 using WebKit::WebPrescientNetworking; | 11 using WebKit::WebPrescientNetworking; |
11 | 12 |
13 const char kMouseEventPreconnectFieldTrialName[] = "MouseEventPreconnect"; | |
14 const char kMouseEventPreconnectFieldTrialMouseDownGroup[] = "MouseDown"; | |
15 const char kMouseEventPreconnectFieldTrialMouseOverGroup[] = "MouseOver"; | |
16 const char kMouseEventPreconnectFieldTrialTapUnconfirmedGroup[] = | |
17 "TapUnconfirmed"; | |
18 const char kMouseEventPreconnectFieldTrialTapDownGroup[] = "TapDown"; | |
19 | |
20 namespace { | |
21 | |
Mathieu
2013/05/27 12:34:53
Document the function?
kouhei (in TOK)
2013/05/28 03:09:00
Done.
| |
22 bool isPreconnectEnabledForMotivation( | |
23 WebKit::WebPreconnectMotivation motivation) { | |
24 std::string group = | |
25 base::FieldTrialList::FindFullName(kMouseEventPreconnectFieldTrialName); | |
26 | |
27 switch (motivation) { | |
28 case WebKit::WebPreconnectMotivationLinkMouseDown: | |
29 return group == kMouseEventPreconnectFieldTrialMouseDownGroup; | |
30 case WebKit::WebPreconnectMotivationLinkMouseOver: | |
31 return group == kMouseEventPreconnectFieldTrialMouseOverGroup; | |
32 case WebKit::WebPreconnectMotivationLinkTapUnconfirmed: | |
33 return group == kMouseEventPreconnectFieldTrialTapUnconfirmedGroup; | |
34 case WebKit::WebPreconnectMotivationLinkTapDown: | |
35 return group == kMouseEventPreconnectFieldTrialTapDownGroup; | |
36 default: | |
37 return false; | |
38 } | |
39 } | |
40 | |
41 } | |
Mathieu
2013/05/27 12:34:53
nit: // end namespace
Mathieu
2013/05/27 12:50:48
or rather // namespace, sorry
kouhei (in TOK)
2013/05/28 03:09:00
Done.
| |
42 | |
12 PrescientNetworkingDispatcher::~PrescientNetworkingDispatcher() { | 43 PrescientNetworkingDispatcher::~PrescientNetworkingDispatcher() { |
13 } | 44 } |
14 | 45 |
15 void PrescientNetworkingDispatcher::preconnect( | 46 void PrescientNetworkingDispatcher::preconnect( |
16 const WebKit::WebURL& url, | 47 const WebKit::WebURL& url, |
17 WebKit::WebPreconnectMotivation motivation) { | 48 WebKit::WebPreconnectMotivation motivation) { |
18 // FIXME(kouhei) actual pre-connecting is currently disabled. | 49 if (!isPreconnectEnabledForMotivation(motivation)) { |
19 // This should shortly be enabled via Finch field trials in upcoming patch. | 50 return; |
20 // content::RenderThread::Get()->Send(new ChromeViewHostMsg_Preconnect(url)); | 51 } |
52 | |
53 content::RenderThread::Get()->Send(new ChromeViewHostMsg_Preconnect(url)); | |
21 } | 54 } |
22 | 55 |
OLD | NEW |