sync bookmark descriptions
authorDan Mills <thunder@mozilla.com>
Mon, 12 May 2008 10:11:07 -0700
changeset 44443 16fbae904d87401d38343766e49c4b206fffaad1
parent 44441 3f84b87252ccff16953feb4051d051aaf4f3154c
child 44444 96e822e57bdc9811e19c969cf6ef4ae41248da6a
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
sync bookmark descriptions
services/sync/modules/stores.js
--- a/services/sync/modules/stores.js
+++ b/services/sync/modules/stores.js
@@ -356,16 +356,21 @@ BookmarksStore.prototype = {
       let URI = Utils.makeURI(command.data.URI);
       newId = this._bms.insertBookmark(parentId,
                                        URI,
                                        command.data.index,
                                        command.data.title);
       this._ts.untagURI(URI, null);
       this._ts.tagURI(URI, command.data.tags);
       this._bms.setKeywordForBookmark(newId, command.data.keyword);
+      if (command.data.description) {
+        this._ans.setItemAnnotation(newId, "bookmarkProperties/description",
+                                    command.data.description, 0,
+                                    this._ans.EXPIRE_NEVER);
+      }
 
       if (command.data.type == "microsummary") {
         this._log.debug("   \-> is a microsummary");
         let genURI = Utils.makeURI(command.data.generatorURI);
         try {
           let micsum = this._ms.createMicrosummary(URI, genURI);
           this._ms.setMicrosummary(newId, micsum);
         }
@@ -492,16 +497,23 @@ BookmarksStore.prototype = {
       case "tags": {
         let tagsURI = this._bms.getBookmarkURI(itemId);
         this._ts.untagURI(tagsURI, null);
         this._ts.tagURI(tagsURI, command.data.tags);
       } break;
       case "keyword":
         this._bms.setKeywordForBookmark(itemId, command.data.keyword);
         break;
+      case "description":
+        if (command.data.description) {
+          this._ans.setItemAnnotation(itemId, "bookmarkProperties/description",
+                                      command.data.description, 0,
+                                      this._ans.EXPIRE_NEVER);
+        }
+        break;
       case "generatorURI": {
         let micsumURI = Utils.makeURI(this._bms.getBookmarkURI(itemId));
         let genURI = Utils.makeURI(command.data.generatorURI);
         let micsum = this._ms.createMicrosummary(micsumURI, genURI);
         this._ms.setMicrosummary(itemId, micsum);
       } break;
       case "siteURI":
         this._ls.setSiteURI(itemId, Utils.makeURI(command.data.siteURI));
@@ -568,16 +580,24 @@ BookmarksStore.prototype = {
         item.generatorURI = micsum.generator.uri.spec; // breaks local generators
       } else if (node.type == node.RESULT_TYPE_QUERY) {
         item.type = "query";
         item.title = node.title;
       } else {
         item.type = "bookmark";
         item.title = node.title;
       }
+
+      try {
+        item.description =
+          this._ans.getItemAnnotation(node.itemId, "bookmarkProperties/description");
+      } catch (e) {
+        item.description = undefined;
+      }
+
       item.URI = node.uri;
       item.tags = this._ts.getTagsForURI(Utils.makeURI(node.uri), {});
       item.keyword = this._bms.getKeywordForBookmark(node.itemId);
 
     } else if (node.type == node.RESULT_TYPE_SEPARATOR) {
       item.type = "separator";
 
     } else {
@@ -792,20 +812,20 @@ CookieStore.prototype = {
 			     command.data.expiry );
   },
 
   _removeCommand: function CookieStore__removeCommand(command) {
     /* we got a command to remove a cookie from the local browser
        in order to sync with the server.
        command.data appears to be equivalent to what wrap() puts in
        the JSON dictionary. */
-    
+
     this._log.info("CookieStore got removeCommand: " + command );
 
-    /* I think it goes like this, according to 
+    /* I think it goes like this, according to
       http://developer.mozilla.org/en/docs/nsICookieManager
       the last argument is "always block cookies from this domain?"
       and the answer is "no". */
     this._cookieManager.remove( command.data.host,
 				command.data.name,
 				command.data.path,
 				false );
   },
@@ -816,23 +836,23 @@ CookieStore.prototype = {
     this._log.info("CookieStore got editCommand: " + command );
 
     /* Look up the cookie that matches the one in the command: */
     var iter = this._cookieManager.enumerator;
     var matchingCookie = null;
     while (iter.hasMoreElements()){
       let cookie = iter.getNext();
       if (cookie instanceof Ci.nsICookie){
-        // see if host:path:name of cookie matches GUID given in command 
+        // see if host:path:name of cookie matches GUID given in command
 	let key = cookie.host + ":" + cookie.path + ":" + cookie.name;
 	if (key == command.GUID) {
 	  matchingCookie = cookie;
 	  break;
 	}
-      }   
+      }
     }
     // Update values in the cookie:
     for (var key in command.data) {
       // Whatever values command.data has, use them
       matchingCookie[ key ] = command.data[ key ]
     }
     // Remove the old incorrect cookie from the manager:
     this._cookieManager.remove( matchingCookie.host,
@@ -843,17 +863,17 @@ CookieStore.prototype = {
     this._cookieManager.add( matchingCookie.host,
 			     matchingCookie.path,
 			     matchingCookie.name,
 			     matchingCookie.value,
 			     matchingCookie.isSecure,
 			     matchingCookie.isHttpOnly,
 			     matchingCookie.isSession,
 			     matchingCookie.expiry );
-    
+
     // Also, there's an exception raised because
     // this._data[comand.GUID] is undefined
   },
 
   wrap: function CookieStore_wrap() {
     /* Return contents of this store, as JSON.
        A dictionary of cookies where the keys are GUIDs and the
        values are sub-dictionaries containing all cookie fields. */
@@ -873,21 +893,21 @@ CookieStore.prototype = {
 			 host: cookie.host,
 			 path: cookie.path,
 			 isSecure: cookie.isSecure,
 			 // nsICookie2 values:
 			 rawHost: cookie.rawHost,
 			 isSession: cookie.isSession,
 			 expiry: cookie.expiry,
 			 isHttpOnly: cookie.isHttpOnly }
-	
+
 	/* See http://developer.mozilla.org/en/docs/nsICookie
 	   Note: not syncing "expires", "status", or "policy"
 	   since they're deprecated. */
-	
+
       }
     }
     return items;
   },
 
   wipe: function CookieStore_wipe() {
     /* Remove everything from the store.  Return nothing.
        TODO are the semantics of this just wiping out an internal