Bug 956936 - Include supported Sync protocol versions in desktop client records. r=gps, a=bajaj
authorRichard Newman <rnewman@mozilla.com>
Mon, 06 Jan 2014 21:45:26 -0800
changeset 167900 66cd15a015ac55a32d1c95c3a2ae910bc2483c58
parent 167899 33a9463936823d9bb954bfd6d8076be778c24e93
child 167901 3ede91e790a2a39532ee1ea85fef65a3025c1e94
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps, bajaj
bugs956936
milestone27.0
Bug 956936 - Include supported Sync protocol versions in desktop client records. r=gps, a=bajaj
services/sync/modules/engines/clients.js
services/sync/tests/unit/test_clients_engine.js
--- a/services/sync/modules/engines/clients.js
+++ b/services/sync/modules/engines/clients.js
@@ -13,26 +13,28 @@ Cu.import("resource://services-common/st
 Cu.import("resource://services-sync/constants.js");
 Cu.import("resource://services-sync/engines.js");
 Cu.import("resource://services-sync/record.js");
 Cu.import("resource://services-sync/util.js");
 
 const CLIENTS_TTL = 1814400; // 21 days
 const CLIENTS_TTL_REFRESH = 604800; // 7 days
 
+const SUPPORTED_PROTOCOL_VERSIONS = ["1.1"];
+
 this.ClientsRec = function ClientsRec(collection, id) {
   CryptoWrapper.call(this, collection, id);
 }
 ClientsRec.prototype = {
   __proto__: CryptoWrapper.prototype,
   _logName: "Sync.Record.Clients",
   ttl: CLIENTS_TTL
 };
 
-Utils.deferGetSet(ClientsRec, "cleartext", ["name", "type", "commands", "version"]);
+Utils.deferGetSet(ClientsRec, "cleartext", ["name", "type", "commands", "version", "protocols"]);
 
 
 this.ClientEngine = function ClientEngine(service) {
   SyncEngine.call(this, "Clients", service);
 
   // Reset the client on every startup so that we fetch recent clients
   this._resetClient();
 }
@@ -382,16 +384,17 @@ ClientStore.prototype = {
     let record = new ClientsRec(collection, id);
 
     // Package the individual components into a record for the local client
     if (id == this.engine.localID) {
       record.name = this.engine.localName;
       record.type = this.engine.localType;
       record.commands = this.engine.localCommands;
       record.version = Services.appinfo.version;
+      record.protocols = SUPPORTED_PROTOCOL_VERSIONS;
     }
     else
       record.cleartext = this._remoteClients[id];
 
     return record;
   },
 
   itemExists: function itemExists(id) id in this.getAllIDs(),
--- a/services/sync/tests/unit/test_clients_engine.js
+++ b/services/sync/tests/unit/test_clients_engine.js
@@ -27,16 +27,18 @@ function check_record_version(user, id) 
     rec.ciphertext = payload.ciphertext;
     rec.hmac = payload.hmac;
     rec.IV = payload.IV;
 
     let cleartext = rec.decrypt(Service.collectionKeys.keyForCollection("clients"));
 
     _("Payload is " + JSON.stringify(cleartext));
     do_check_eq(Services.appinfo.version, cleartext.version);
+    do_check_eq(1, cleartext.protocols.length);
+    do_check_eq("1.1", cleartext.protocols[0]);
 }
 
 add_test(function test_bad_hmac() {
   _("Ensure that Clients engine deletes corrupt records.");
   let contents = {
     meta: {global: {engines: {clients: {version: engine.version,
                                         syncID: engine.syncID}}}},
     clients: {},