Changeset 917

Show
Ignore:
Timestamp:
2008-03-30 21:18:52 (2 years ago)
Author:
MaierMan
Message:

#662 Use nsIJSON as serializer

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/chrome/content/dta/manager.js

    r911 r917  
    16621662                        ); 
    16631663                } 
    1664                 return e.toSource(); 
     1664                return Serializer.encode(e); 
    16651665        } 
    16661666} 
     
    26832683        } 
    26842684}; 
     2685 
     2686var Serializer = { 
     2687        encode: function(obj) { 
     2688                if ('nsIJSON' in Ci) { 
     2689                        Debug.logString("hello json"); 
     2690                        let json = Serv('@mozilla.org/dom/json;1', 'nsIJSON'); 
     2691                        this.encode = function(obj) { 
     2692                                return json.encode(obj); 
     2693                        } 
     2694                } 
     2695                else { 
     2696                        this.encode = function(obj) { 
     2697                                return obj.toSource(); 
     2698                        } 
     2699                } 
     2700                return this.encode(obj); 
     2701        }, 
     2702        decode: function(str) { 
     2703                if ('nsIJSON' in Ci) { 
     2704                        Debug.logString("hello json"); 
     2705                        let json = Serv('@mozilla.org/dom/json;1', 'nsIJSON'); 
     2706                        this.decode = function(str) { 
     2707                                return json.decode(str); 
     2708                        } 
     2709                } 
     2710                else { 
     2711                        this.decode = function(str) { 
     2712                                return eval(str); 
     2713                        } 
     2714                } 
     2715                return this.decode(str); 
     2716        } 
     2717}; 
  • trunk/chrome/content/dta/manager/sessionmanager.js

    r903 r917  
    4242 
    4343var SessionManager = { 
    44  
    4544        init: function() { 
    4645                this._con = Serv('@mozilla.org/storage/service;1', 'mozIStorageService') 
     
    169168                        try { 
    170169                                let dbId = stmt.getInt64(0); 
    171                                 let down = eval(stmt.getUTF8String(1)); 
     170                                let down = Serializer.decode(stmt.getUTF8String(1)); 
    172171                                let get = function(attr) { 
    173172                                        if (attr in down) {