| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 var chrome = chrome || {}; | 5 var chrome = chrome || {}; |
| 6 |
| 6 // TODO(akalin): Add mocking code for e.g. chrome.send() so that we | 7 // TODO(akalin): Add mocking code for e.g. chrome.send() so that we |
| 7 // can test this without rebuilding chrome. | 8 // can test this without rebuilding chrome. |
| 9 |
| 10 /** |
| 11 * Organize sync event listeners and asynchronous requests. |
| 12 * This object is one of a kind; its constructor is not public. |
| 13 * @type {Object} |
| 14 */ |
| 8 chrome.sync = chrome.sync || {}; | 15 chrome.sync = chrome.sync || {}; |
| 9 (function () { | 16 (function() { |
| 10 | 17 |
| 11 // This Event class is a simplified version of the one from | 18 // This Event class is a simplified version of the one from |
| 12 // event_bindings.js. | 19 // event_bindings.js. |
| 13 function Event() { | 20 function Event() { |
| 14 this.listeners_ = []; | 21 this.listeners_ = []; |
| 15 } | 22 } |
| 16 | 23 |
| 17 Event.prototype.addListener = function(listener) { | 24 Event.prototype.addListener = function(listener) { |
| 18 this.listeners_.push(listener); | 25 this.listeners_.push(listener); |
| 19 }; | 26 }; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 | 145 |
| 139 // Client server communication logging functions. | 146 // Client server communication logging functions. |
| 140 'getClientServerTraffic', | 147 'getClientServerTraffic', |
| 141 | 148 |
| 142 // Node lookup functions. See chrome/browser/sync/engine/syncapi.h | 149 // Node lookup functions. See chrome/browser/sync/engine/syncapi.h |
| 143 // for docs. | 150 // for docs. |
| 144 'getRootNodeDetails', | 151 'getRootNodeDetails', |
| 145 'getNodeSummariesById', | 152 'getNodeSummariesById', |
| 146 'getNodeDetailsById', | 153 'getNodeDetailsById', |
| 147 'getChildNodeIds', | 154 'getChildNodeIds', |
| 148 'findNodesContainingString' | 155 'getAllNodes', |
| 149 ]; | 156 ]; |
| 150 | 157 |
| 151 for (var i = 0; i < syncFunctions.length; ++i) { | 158 for (var i = 0; i < syncFunctions.length; ++i) { |
| 152 var syncFunction = syncFunctions[i]; | 159 var syncFunction = syncFunctions[i]; |
| 153 chrome.sync[syncFunction] = makeSyncFunction(syncFunction); | 160 chrome.sync[syncFunction] = makeSyncFunction(syncFunction); |
| 154 } | 161 } |
| 155 | 162 |
| 156 /** | 163 /** |
| 157 * Returns an object which measures elapsed time. | 164 * Returns an object which measures elapsed time. |
| 158 */ | 165 */ |
| 159 chrome.sync.makeTimer = function() { | 166 chrome.sync.makeTimer = function() { |
| 160 var start = new Date(); | 167 var start = new Date(); |
| 161 | 168 |
| 162 return { | 169 return { |
| 163 /** | 170 /** |
| 164 * @return {number} The number of seconds since the timer was | 171 * @return {number} The number of seconds since the timer was |
| 165 * created. | 172 * created. |
| 166 */ | 173 */ |
| 167 get elapsedSeconds() { | 174 get elapsedSeconds() { |
| 168 return ((new Date()).getTime() - start.getTime()) / 1000.0; | 175 return ((new Date()).getTime() - start.getTime()) / 1000.0; |
| 169 } | 176 } |
| 170 }; | 177 }; |
| 171 }; | 178 }; |
| 172 | 179 |
| 173 })(); | 180 })(); |
| OLD | NEW |