Bug 1259510 - record usage of the search service's update feature, r=adw,bsmedberg.

--HG--
extra : rebase_source : 95b84e7c1cc0a7f1b84d60f278ad257af405b498
This commit is contained in:
Florian Quèze 2016-04-05 12:13:55 +02:00
Родитель 8844aff4db
Коммит 13873d680d
5 изменённых файлов: 84 добавлений и 0 удалений

Просмотреть файл

@ -2739,6 +2739,7 @@ SearchService.prototype = {
Services.obs.notifyObservers(null, SEARCH_SERVICE_TOPIC, "init-complete");
Services.telemetry.getHistogramById("SEARCH_SERVICE_INIT_SYNC").add(true);
this._recordEnginesWithUpdate();
LOG("_syncInit end");
},
@ -2781,6 +2782,7 @@ SearchService.prototype = {
this._initObservers.resolve(this._initRV);
Services.obs.notifyObservers(null, SEARCH_SERVICE_TOPIC, "init-complete");
Services.telemetry.getHistogramById("SEARCH_SERVICE_INIT_SYNC").add(false);
this._recordEnginesWithUpdate();
LOG("_asyncInit: Completed _asyncInit");
}.bind(this));
@ -3149,6 +3151,7 @@ SearchService.prototype = {
// Typically we'll re-init as a result of a pref observer,
// so signal to 'callers' that we're done.
Services.obs.notifyObservers(null, SEARCH_SERVICE_TOPIC, "init-complete");
this._recordEnginesWithUpdate();
gInitialized = true;
} catch (err) {
LOG("Reinit failed: " + err);
@ -4233,6 +4236,23 @@ SearchService.prototype = {
return result;
},
_recordEnginesWithUpdate: function() {
let hasUpdates = false;
let hasIconUpdates = false;
for (let name in this._engines) {
let engine = this._engines[name];
if (engine._hasUpdates) {
hasUpdates = true;
if (engine._iconUpdateURL) {
hasIconUpdates = true;
break;
}
}
}
Services.telemetry.getHistogramById("SEARCH_SERVICE_HAS_UPDATES").add(hasUpdates);
Services.telemetry.getHistogramById("SEARCH_SERVICE_HAS_ICON_UPDATES").add(hasIconUpdates);
},
/**
* This map is built lazily after the available search engines change. It
* allows quick parsing of an URL representing a search submission into the

Просмотреть файл

@ -0,0 +1,10 @@
<SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/">
<ShortName>update</ShortName>
<Description>update</Description>
<InputEncoding>UTF-8</InputEncoding>
<Url type="text/html" method="GET" template="http://searchtest.local">
<Param name="search" value="{searchTerms}"/>
</Url>
<UpdateUrl>http://searchtest.local/opensearch.xml</UpdateUrl>
<IconUpdateUrl>http://searchtest.local/favicon.ico</IconUpdateUrl>
</SearchPlugin>

Просмотреть файл

@ -0,0 +1,36 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
function run_test() {
do_check_false(Services.search.isInitialized);
useHttpServer();
run_next_test();
}
function checkTelemetry(histogramName, expected) {
let histogram = Services.telemetry.getHistogramById(histogramName);
let snapshot = histogram.snapshot();
let expectedCounts = [0, 0, 0];
expectedCounts[expected ? 1 : 0] = 1;
Assert.deepEqual(snapshot.counts, expectedCounts,
"histogram has expected content");
histogram.clear();
}
add_task(function* ignore_cache_files_without_engines() {
yield asyncInit();
checkTelemetry("SEARCH_SERVICE_HAS_UPDATES", false);
checkTelemetry("SEARCH_SERVICE_HAS_ICON_UPDATES", false);
// Add an engine with update urls and re-init, as we record the presence of
// engine update urls only while initializing the search service.
yield addTestEngines([
{ name: "update", xmlFileName: "engine-update.xml" },
]);
yield asyncReInit();
checkTelemetry("SEARCH_SERVICE_HAS_UPDATES", true);
checkTelemetry("SEARCH_SERVICE_HAS_ICON_UPDATES", true);
});

Просмотреть файл

@ -17,6 +17,7 @@ support-files =
data/engine-rel-searchform-post.xml
data/engine-rel-searchform-purpose.xml
data/engine-system-purpose.xml
data/engine-update.xml
data/engineImages.xml
data/ico-size-16x16-png.ico
data/invalid-engine.xml
@ -89,4 +90,5 @@ tags = addons
[test_hidden.js]
[test_currentEngine_fallback.js]
[test_require_engines_in_cache.js]
[test_update_telemetry.js]
[test_svg_icon.js]

Просмотреть файл

@ -5375,6 +5375,22 @@
"kind": "boolean",
"description": "search service has been initialized synchronously"
},
"SEARCH_SERVICE_HAS_UPDATES": {
"alert_emails": ["florian@mozilla.com"],
"expires_in_version": "50",
"kind": "boolean",
"bug_numbers": [1259510],
"description": "Recorded once per session near startup: records true/false whether the search service has engines with update URLs.",
"releaseChannelCollection": "opt-out"
},
"SEARCH_SERVICE_HAS_ICON_UPDATES": {
"alert_emails": ["florian@mozilla.com"],
"expires_in_version": "50",
"kind": "boolean",
"bug_numbers": [1259510],
"description": "Recorded once per session near startup: records true/false whether the search service has engines with icon update URLs.",
"releaseChannelCollection": "opt-out"
},
"SEARCH_SERVICE_BUILD_CACHE_MS": {
"expires_in_version": "40",
"kind": "exponential",