Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: chrome/renderer/resources/extensions/utils.js

Issue 141803016: Hide Port privates (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/renderer/resources/extensions/messaging.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 schemaRegistry = requireNative('schema_registry'); 5 var schemaRegistry = requireNative('schema_registry');
6 var CHECK = requireNative('logging').CHECK; 6 var CHECK = requireNative('logging').CHECK;
7 var WARNING = requireNative('logging').WARNING; 7 var WARNING = requireNative('logging').WARNING;
8 8
9 // An object forEach. Calls |f| with each (key, value) pair of |obj|, using 9 // An object forEach. Calls |f| with each (key, value) pair of |obj|, using
10 // |self| as the target. 10 // |self| as the target.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 var types = schemaRegistry.GetSchema(schemaName).types; 45 var types = schemaRegistry.GetSchema(schemaName).types;
46 } 46 }
47 for (var i = 0; i < types.length; ++i) { 47 for (var i = 0; i < types.length; ++i) {
48 if (types[i].id == typeName) 48 if (types[i].id == typeName)
49 return types[i]; 49 return types[i];
50 } 50 }
51 return null; 51 return null;
52 } 52 }
53 53
54 // expose takes a private class implementation |cls| and exposes a subset of its 54 // expose takes a private class implementation |cls| and exposes a subset of its
55 // methods |funcs| in a public wrapper class that it returns. 55 // methods |funcs| in a public wrapper class that it returns.
not at google - send to devlin 2014/01/27 23:21:56 explain |props| in this comment as well, though wh
Fady Samuel 2014/01/28 20:45:45 Done. As per our offline discussion, it's fairly m
56 function expose(cls, funcs) { 56 function expose(cls, funcs, props) {
57 function publicClass() { 57 function publicClass() {
58 var privateObj = $Object.create(cls.prototype); 58 var privateObj = $Object.create(cls.prototype);
59 $Function.apply(cls, privateObj, arguments); 59 $Function.apply(cls, privateObj, arguments);
60 privateObj.wrapper = this; 60 privateObj.wrapper = this;
61 privates(this).impl = privateObj; 61 privates(this).impl = privateObj;
62 } 62 }
63 63
64 $Array.forEach(funcs, function(func) { 64
65 publicClass.prototype[func] = function() { 65 if (funcs) {
66 var impl = privates(this).impl; 66 $Array.forEach(funcs, function(func) {
67 return $Function.apply(impl[func], impl, arguments); 67 publicClass.prototype[func] = function() {
68 }; 68 var impl = privates(this).impl;
69 }); 69 return $Function.apply(impl[func], impl, arguments);
70 };
71 });
72 }
73
74 if (props) {
75 $Array.forEach(props, function(prop) {
76 $Object.defineProperty(publicClass.prototype, prop, {
77 enumerable: true,
78 get: function() {
79 var impl = privates(this).impl;
80 return impl[prop];
81 }
not at google - send to devlin 2014/01/27 23:21:56 Hm this is pretty tricky. You should make this se
Fady Samuel 2014/01/28 20:45:45 Done.
82 });
83 });
84 }
70 85
71 return publicClass; 86 return publicClass;
72 } 87 }
73 88
74 exports.forEach = forEach; 89 exports.forEach = forEach;
75 exports.loadTypeSchema = loadTypeSchema; 90 exports.loadTypeSchema = loadTypeSchema;
76 exports.lookup = lookup; 91 exports.lookup = lookup;
77 exports.expose = expose; 92 exports.expose = expose;
OLDNEW
« no previous file with comments | « chrome/renderer/resources/extensions/messaging.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698