Commit d68db3dc authored by tburkard@chromium.org's avatar tburkard@chromium.org

Add options to disable each of the two aspects of the prerender service

(current URL based hinting and candidate URL upload).
R=jam@chromium.org

Review URL: https://codereview.chromium.org/23506038

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222082 0039d316-1c4b-4281-b951-d872f2087c98
parent fd3f5aa7
...@@ -47,6 +47,10 @@ const char kPrerenderLaunchKeyName[] = "PrerenderLaunch"; ...@@ -47,6 +47,10 @@ const char kPrerenderLaunchKeyName[] = "PrerenderLaunch";
const char kPrerenderAlwaysControlKeyName[] = "PrerenderAlwaysControl"; const char kPrerenderAlwaysControlKeyName[] = "PrerenderAlwaysControl";
const char kPrerenderQueryPrerenderServiceKeyName[] = const char kPrerenderQueryPrerenderServiceKeyName[] =
"PrerenderQueryPrerenderService"; "PrerenderQueryPrerenderService";
const char kPrerenderQueryPrerenderServiceCurrentURLKeyName[] =
"PrerenderQueryPrerenderServiceCurrentURL";
const char kPrerenderQueryPrerenderServiceCandidateURLsKeyName[] =
"PrerenderQueryPrerenderServiceCandidateURLs";
const char kPrerenderServiceBehaviorIDKeyName[] = "PrerenderServiceBehaviorID"; const char kPrerenderServiceBehaviorIDKeyName[] = "PrerenderServiceBehaviorID";
const char kPrerenderServiceFetchTimeoutKeyName[] = const char kPrerenderServiceFetchTimeoutKeyName[] =
"PrerenderServiceFetchTimeoutMs"; "PrerenderServiceFetchTimeoutMs";
...@@ -373,6 +377,16 @@ bool ShouldQueryPrerenderService(Profile* profile) { ...@@ -373,6 +377,16 @@ bool ShouldQueryPrerenderService(Profile* profile) {
kEnabledGroup; kEnabledGroup;
} }
bool ShouldQueryPrerenderServiceForCurrentURL() {
return GetLocalPredictorSpecValue(
kPrerenderQueryPrerenderServiceCurrentURLKeyName) != kDisabledGroup;
}
bool ShouldQueryPrerenderServiceForCandidateURLs() {
return GetLocalPredictorSpecValue(
kPrerenderQueryPrerenderServiceCandidateURLsKeyName) != kDisabledGroup;
}
string GetPrerenderServiceURLPrefix() { string GetPrerenderServiceURLPrefix() {
string prefix = chrome_variations::GetVariationParamValue( string prefix = chrome_variations::GetVariationParamValue(
kLocalPredictorSpecTrialName, kLocalPredictorSpecTrialName,
......
...@@ -42,6 +42,11 @@ bool IsLocalPredictorPrerenderAlwaysControlEnabled(); ...@@ -42,6 +42,11 @@ bool IsLocalPredictorPrerenderAlwaysControlEnabled();
// provided. // provided.
bool ShouldQueryPrerenderService(Profile* profile); bool ShouldQueryPrerenderService(Profile* profile);
// Indicates whether we should query the prerender service for the current URL
// and candidate URLs, respectively.
bool ShouldQueryPrerenderServiceForCurrentURL();
bool ShouldQueryPrerenderServiceForCandidateURLs();
// Returns the URL prefix to be used for the prerender service. The only thing // Returns the URL prefix to be used for the prerender service. The only thing
// that will be appended is the urlencoded query json. // that will be appended is the urlencoded query json.
std::string GetPrerenderServiceURLPrefix(); std::string GetPrerenderServiceURLPrefix();
......
...@@ -642,7 +642,8 @@ void PrerenderLocalPredictor::DoPrerenderServiceCheck( ...@@ -642,7 +642,8 @@ void PrerenderLocalPredictor::DoPrerenderServiceCheck(
DictionaryValue* req = new DictionaryValue(); DictionaryValue* req = new DictionaryValue();
req->SetInteger("version", 1); req->SetInteger("version", 1);
req->SetInteger("behavior_id", GetPrerenderServiceBehaviorID()); req->SetInteger("behavior_id", GetPrerenderServiceBehaviorID());
if (info->source_url_.url_lookup_success) { if (ShouldQueryPrerenderServiceForCurrentURL() &&
info->source_url_.url_lookup_success) {
ListValue* browse_history = new ListValue(); ListValue* browse_history = new ListValue();
DictionaryValue* browse_item = new DictionaryValue(); DictionaryValue* browse_item = new DictionaryValue();
browse_item->SetString("url", info->source_url_.url.spec()); browse_item->SetString("url", info->source_url_.url.spec());
...@@ -656,7 +657,8 @@ void PrerenderLocalPredictor::DoPrerenderServiceCheck( ...@@ -656,7 +657,8 @@ void PrerenderLocalPredictor::DoPrerenderServiceCheck(
if (info->candidate_urls_[i].url_lookup_success) if (info->candidate_urls_[i].url_lookup_success)
num_candidate_urls++; num_candidate_urls++;
} }
if (num_candidate_urls > 0) { if (ShouldQueryPrerenderServiceForCandidateURLs() &&
num_candidate_urls > 0) {
ListValue* candidates = new ListValue(); ListValue* candidates = new ListValue();
DictionaryValue* candidate; DictionaryValue* candidate;
for (int i = 0; i < static_cast<int>(info->candidate_urls_.size()); i++) { for (int i = 0; i < static_cast<int>(info->candidate_urls_.size()); i++) {
...@@ -757,8 +759,12 @@ bool PrerenderLocalPredictor::ApplyParsedPrerenderServiceResponse( ...@@ -757,8 +759,12 @@ bool PrerenderLocalPredictor::ApplyParsedPrerenderServiceResponse(
} }
if (!dict->GetList("prerender_response.candidate_check_response.candidates", if (!dict->GetList("prerender_response.candidate_check_response.candidates",
&list)) { &list)) {
if (info->candidate_urls_.size() > 0) if (ShouldQueryPrerenderServiceForCandidateURLs()) {
return false; for (int i = 0; i < static_cast<int>(info->candidate_urls_.size()); i++) {
if (info->candidate_urls_[i].url_lookup_success)
return false;
}
}
} else { } else {
for (size_t i = 0; i < list->GetSize(); i++) { for (size_t i = 0; i < list->GetSize(); i++) {
DictionaryValue* d; DictionaryValue* d;
...@@ -791,47 +797,52 @@ bool PrerenderLocalPredictor::ApplyParsedPrerenderServiceResponse( ...@@ -791,47 +797,52 @@ bool PrerenderLocalPredictor::ApplyParsedPrerenderServiceResponse(
} }
} }
for (size_t i = 0; i < info->candidate_urls_.size(); i++) { for (size_t i = 0; i < info->candidate_urls_.size(); i++) {
if (!info->candidate_urls_[i].service_whitelist_reported) if (info->candidate_urls_[i].url_lookup_success &&
!info->candidate_urls_[i].service_whitelist_reported) {
return false; return false;
}
} }
} }
list = NULL; if (ShouldQueryPrerenderServiceForCurrentURL() &&
if (dict->GetInteger("prerender_response.hint_response.hinting_timed_out", info->source_url_.url_lookup_success) {
&int_value) && list = NULL;
int_value == 1) { if (dict->GetInteger("prerender_response.hint_response.hinting_timed_out",
*hinting_timed_out = true; &int_value) &&
} else if (!dict->GetList("prerender_response.hint_response.candidates", int_value == 1) {
&list)) { *hinting_timed_out = true;
return false; } else if (!dict->GetList("prerender_response.hint_response.candidates",
} else { &list)) {
for (int i = 0; i < static_cast<int>(list->GetSize()); i++) { return false;
DictionaryValue* d; } else {
if (!list->GetDictionary(i, &d)) for (int i = 0; i < static_cast<int>(list->GetSize()); i++) {
return false; DictionaryValue* d;
string url; if (!list->GetDictionary(i, &d))
double priority; return false;
if (!d->GetString("url", &url) || !d->GetDouble("likelihood", &priority) string url;
|| !GURL(url).is_valid()) { double priority;
return false; if (!d->GetString("url", &url) || !d->GetDouble("likelihood", &priority)
} || !GURL(url).is_valid()) {
int in_index_timed_out = 0; return false;
int in_index = 0; }
if ((!d->GetInteger("in_index_timed_out", &in_index_timed_out) || int in_index_timed_out = 0;
in_index_timed_out != 1) && int in_index = 0;
!d->GetInteger("in_index", &in_index)) { if ((!d->GetInteger("in_index_timed_out", &in_index_timed_out) ||
return false; in_index_timed_out != 1) &&
} !d->GetInteger("in_index", &in_index)) {
if (priority < 0.0 || priority > 1.0 || in_index < 0 || in_index > 1 || return false;
in_index_timed_out < 0 || in_index_timed_out > 1) { }
return false; if (priority < 0.0 || priority > 1.0 || in_index < 0 || in_index > 1 ||
in_index_timed_out < 0 || in_index_timed_out > 1) {
return false;
}
if (in_index_timed_out == 1)
*hinting_url_lookup_timed_out = true;
info->MaybeAddCandidateURLFromService(GURL(url),
priority,
in_index == 1,
(1 - in_index_timed_out) == 1);
} }
if (in_index_timed_out == 1)
*hinting_url_lookup_timed_out = true;
info->MaybeAddCandidateURLFromService(GURL(url),
priority,
in_index == 1,
(1 - in_index_timed_out) == 1);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment