Chromium Code Reviews| 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 | |
| 22 // Returns true if preconnect is enabled for given motivation. | |
| 23 // The preconnect via {mouse,gesture} event is enabled for limited userbase | |
| 24 // for Finch field trial. | |
| 25 bool isPreconnectEnabledForMotivation( | |
| 26 WebKit::WebPreconnectMotivation motivation) { | |
| 27 std::string group = | |
| 28 base::FieldTrialList::FindFullName(kMouseEventPreconnectFieldTrialName); | |
| 29 | |
| 30 switch (motivation) { | |
| 31 case WebKit::WebPreconnectMotivationLinkMouseDown: | |
| 32 return group == kMouseEventPreconnectFieldTrialMouseDownGroup; | |
| 33 case WebKit::WebPreconnectMotivationLinkMouseOver: | |
| 34 return group == kMouseEventPreconnectFieldTrialMouseOverGroup; | |
| 35 case WebKit::WebPreconnectMotivationLinkTapUnconfirmed: | |
| 36 return group == kMouseEventPreconnectFieldTrialTapUnconfirmedGroup; | |
| 37 case WebKit::WebPreconnectMotivationLinkTapDown: | |
| 38 return group == kMouseEventPreconnectFieldTrialTapDownGroup; | |
| 39 default: | |
| 40 return false; | |
| 41 } | |
| 42 } | |
| 43 | |
| 44 } // namespace | |
| 45 | |
| 12 PrescientNetworkingDispatcher::~PrescientNetworkingDispatcher() { | 46 PrescientNetworkingDispatcher::~PrescientNetworkingDispatcher() { |
| 13 } | 47 } |
| 14 | 48 |
| 15 void PrescientNetworkingDispatcher::preconnect( | 49 void PrescientNetworkingDispatcher::preconnect( |
| 16 const WebKit::WebURL& url, | 50 const WebKit::WebURL& url, |
| 17 WebKit::WebPreconnectMotivation motivation) { | 51 WebKit::WebPreconnectMotivation motivation) { |
| 18 // FIXME(kouhei) actual pre-connecting is currently disabled. | 52 if (!isPreconnectEnabledForMotivation(motivation)) { |
| 19 // This should shortly be enabled via Finch field trials in upcoming patch. | 53 return; |
| 20 // content::RenderThread::Get()->Send(new ChromeViewHostMsg_Preconnect(url)); | 54 } |
| 55 | |
| 56 content::RenderThread::Get()->Send(new ChromeViewHostMsg_Preconnect(url)); | |
|
Nico
2013/05/30 00:26:23
If it fits in 80 cols, write
if (isPrec…)
R
kouhei (in TOK)
2013/05/30 00:30:36
Done.
| |
| 21 } | 57 } |
| 22 | 58 |
| OLD | NEW |