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

Unified Diff: lib/isolate/frog/isolateimpl.dart

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/compiler/implementation/emitter.dart ('k') | lib/isolate/frog/natives.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/isolate/frog/isolateimpl.dart
diff --git a/lib/isolate/frog/isolateimpl.dart b/lib/isolate/frog/isolateimpl.dart
index 876a2b06f9634b5025a497375b9fe997e2feb46a..eb0165f26daf238d7196215053cd9ad48f700b04 100644
--- a/lib/isolate/frog/isolateimpl.dart
+++ b/lib/isolate/frog/isolateimpl.dart
@@ -125,10 +125,9 @@ class _Manager {
}
void _nativeDetectEnvironment() native @"""
- this.isWorker = typeof ($globalThis['importScripts']) != 'undefined';
+ this.isWorker = $isWorker;
+ this.supportsWorkers = $supportsWorkers;
this.fromCommandLine = typeof(window) == 'undefined';
- this.supportsWorkers = this.isWorker ||
- ((typeof $globalThis['Worker']) != 'undefined');
""";
void _nativeInitWorkerMessageHandler() native @"""
@@ -386,34 +385,7 @@ class _IsolateNatives {
* The src url for the script tag that loaded this code. Used to create
* JavaScript workers.
*/
- static String get _thisScript() {
- if (_thisScriptCache == null) {
- _thisScriptCache = _computeThisScript();
- }
- return _thisScriptCache;
- }
-
- static String _thisScriptCache;
-
- // TODO(sigmund): fix - this code should be run synchronously when loading the
- // script. Running lazily on DOMContentLoaded will yield incorrect results.
- static String _computeThisScript() native @"""
- if (!$globalState.supportsWorkers || $globalState.isWorker) return (void 0);
-
- // TODO(5334778): Find a cross-platform non-brittle way of getting the
- // currently running script.
- var scripts = document.getElementsByTagName('script');
- // The scripts variable only contains the scripts that have already been
- // executed. The last one is the currently running script.
- var script = scripts[scripts.length - 1];
- var src = script && script.src;
- if (!src) {
- // TODO()
- src = "FIXME:5407062" + "_" + Math.random().toString();
- if (script) script.src = src;
- }
- return src;
- """;
+ static String get _thisScript() native @"return $thisScriptUrl";
/** Starts a new worker with the given URL. */
static _WorkerStub _newWorker(url) native "return new Worker(url);";
« no previous file with comments | « lib/compiler/implementation/emitter.dart ('k') | lib/isolate/frog/natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698