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

Side by Side Diff: lib/isolate/frog/natives.js

Issue 10050035: isolate: fix how we get the current script now that frog automatically wraps the (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // Top-level native code needed by the frog compiler 5 // Top-level native code needed by the frog compiler
6 6
7 var $globalThis = this; 7 var $globalThis = this;
8 var $globals = null; 8 var $globals = null;
9 var $globalState = null; 9 var $globalState = null;
10 var $thisScriptUrl = null;
11 var $isWorker = typeof ($globalThis['importScripts']) != 'undefined';
12 var $supportsWorkers =
13 $isWorker || ((typeof $globalThis['Worker']) != 'undefined');
10 function $initGlobals(context) { context.isolateStatics = {}; } 14 function $initGlobals(context) { context.isolateStatics = {}; }
11 function $setGlobals(context) { $globals = context.isolateStatics; } 15 function $setGlobals(context) { $globals = context.isolateStatics; }
12 16
13 // Wrap a 0-arg dom-callback to bind it with the current isolate: 17 // Wrap a 0-arg dom-callback to bind it with the current isolate:
14 function $wrap_call$0(fn) { return fn && fn.wrap$call$0(); } 18 function $wrap_call$0(fn) { return fn && fn.wrap$call$0(); }
15 19
16 Function.prototype.wrap$call$0 = function() { 20 Function.prototype.wrap$call$0 = function() {
17 var isolateContext = $globalState.currentContext; 21 var isolateContext = $globalState.currentContext;
18 var self = this; 22 var self = this;
19 this.wrap$0 = function() { 23 this.wrap$0 = function() {
(...skipping 12 matching lines...) Expand all
32 var isolateContext = $globalState.currentContext; 36 var isolateContext = $globalState.currentContext;
33 var self = this; 37 var self = this;
34 this.wrap$1 = function(arg) { 38 this.wrap$1 = function(arg) {
35 var res = isolateContext.eval(function() { return self(arg); }); 39 var res = isolateContext.eval(function() { return self(arg); });
36 $globalState.topEventLoop.run(); 40 $globalState.topEventLoop.run();
37 return res; 41 return res;
38 }; 42 };
39 this.wrap$call$1 = function() { return this.wrap$1; }; 43 this.wrap$call$1 = function() { return this.wrap$1; };
40 return this.wrap$1; 44 return this.wrap$1;
41 }; 45 };
46
47 $thisScriptUrl = (function () {
48 if (!$supportsWorkers || $isWorker) return (void 0);
49
50 // TODO(5334778): Find a cross-platform non-brittle way of getting the
51 // currently running script.
52 var scripts = document.getElementsByTagName('script');
53 // The scripts variable only contains the scripts that have already been
54 // executed. The last one is the currently running script.
55 var script = scripts[scripts.length - 1];
56 var src = script && script.src;
57 if (!src) {
58 // TODO()
59 src = "FIXME:5407062" + "_" + Math.random().toString();
60 if (script) script.src = src;
61 }
62 return src;
63 })();
OLDNEW
« no previous file with comments | « lib/isolate/frog/isolateimpl.dart ('k') | tests/isolate/src/APIv2_computeThisScriptBrowserTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698