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 // Custom bindings for the storage API. | 5 // Custom bindings for the storage API. |
6 | 6 |
7 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); | 7 var Bindings = require('schema_binding_generator').Bindings; |
8 var bindings = new Bindings('storage'); | |
not at google - send to devlin
2013/01/24 21:10:12
for all instances of this pattern: having a bindin
cduvall
2013/01/24 22:15:15
Done.
| |
9 | |
8 var normalizeArgumentsAndValidate = | 10 var normalizeArgumentsAndValidate = |
9 require('schemaUtils').normalizeArgumentsAndValidate | 11 require('schemaUtils').normalizeArgumentsAndValidate |
10 var sendRequest = require('sendRequest').sendRequest; | 12 var sendRequest = require('sendRequest').sendRequest; |
11 | 13 |
12 chromeHidden.registerCustomType('storage.StorageArea', function() { | 14 bindings.registerCustomType('storage.StorageArea', function() { |
13 function extendSchema(schema) { | 15 function extendSchema(schema) { |
14 var extendedSchema = schema.slice(); | 16 var extendedSchema = schema.slice(); |
15 extendedSchema.unshift({'type': 'string'}); | 17 extendedSchema.unshift({'type': 'string'}); |
16 return extendedSchema; | 18 return extendedSchema; |
17 } | 19 } |
18 | 20 |
19 function StorageArea(namespace, schema) { | 21 function StorageArea(namespace, schema) { |
20 // Binds an API function for a namespace to its browser-side call, e.g. | 22 // Binds an API function for a namespace to its browser-side call, e.g. |
21 // storage.sync.get('foo') -> (binds to) -> | 23 // storage.sync.get('foo') -> (binds to) -> |
22 // storage.get('sync', 'foo'). | 24 // storage.get('sync', 'foo'). |
(...skipping 13 matching lines...) Expand all Loading... | |
36 extendSchema(funSchema.definition.parameters), | 38 extendSchema(funSchema.definition.parameters), |
37 {preserveNullInObjects: true}); | 39 {preserveNullInObjects: true}); |
38 }; | 40 }; |
39 } | 41 } |
40 var apiFunctions = ['get', 'set', 'remove', 'clear', 'getBytesInUse']; | 42 var apiFunctions = ['get', 'set', 'remove', 'clear', 'getBytesInUse']; |
41 apiFunctions.forEach(bindApiFunction); | 43 apiFunctions.forEach(bindApiFunction); |
42 } | 44 } |
43 | 45 |
44 return StorageArea; | 46 return StorageArea; |
45 }); | 47 }); |
48 | |
49 exports.bindings = bindings.generate(); | |
OLD | NEW |