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

Unified Diff: sdk/lib/js/dart2js/js_dart2js.dart

Issue 25138003: Cache the context proxy. Don't use window for global 'this'. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_internal/lib/js_helper.dart ('k') | sdk/lib/js/dartium/js_dartium.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/js/dart2js/js_dart2js.dart
diff --git a/sdk/lib/js/dart2js/js_dart2js.dart b/sdk/lib/js/dart2js/js_dart2js.dart
index 7f806b73f3744794eeca4b725e61093b6cf12008..a9b8afdd90a2634bc2c7bb071152e19cb30b57a7 100644
--- a/sdk/lib/js/dart2js/js_dart2js.dart
+++ b/sdk/lib/js/dart2js/js_dart2js.dart
@@ -5,10 +5,15 @@
library dart.js;
import 'dart:_foreign_helper' show JS;
-import 'dart:_js_helper' show convertDartClosureToJS;
+import 'dart:_js_helper' show convertDartClosureToJS, computeGlobalThis;
+JsObject _context;
vsm 2013/09/28 00:55:09 Can't you just do: final JsObject context = new J
justinfagnani 2013/09/28 01:02:15 Indeed. I keep forgetting about lazy static initia
+
JsObject get context {
- return new JsObject._fromJs(JS('=Object', 'window'));
+ if (_context == null) {
+ _context = new JsObject._fromJs(computeGlobalThis());
+ }
+ return _context;
}
JsObject jsify(dynamic data) => data == null ? null : new JsObject._json(data);
« no previous file with comments | « sdk/lib/_internal/lib/js_helper.dart ('k') | sdk/lib/js/dartium/js_dartium.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698