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

Side by Side Diff: Source/WebCore/bindings/js/WorkerScriptController.cpp

Issue 6519013: Merge 77563 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/648/
Patch Set: Created 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2011 Google Inc. All Rights Reserved.
3 * 4 *
4 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
6 * are met: 7 * are met:
7 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 11 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 12 * documentation and/or other materials provided with the distribution.
12 * 13 *
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 JSLock lock(SilenceAssertionsOnly); 125 JSLock lock(SilenceAssertionsOnly);
125 126
126 ExecState* exec = m_workerContextWrapper->globalExec(); 127 ExecState* exec = m_workerContextWrapper->globalExec();
127 m_workerContextWrapper->globalData().timeoutChecker.start(); 128 m_workerContextWrapper->globalData().timeoutChecker.start();
128 Completion comp = JSC::evaluate(exec, exec->dynamicGlobalObject()->globalSco peChain(), sourceCode.jsSourceCode(), m_workerContextWrapper); 129 Completion comp = JSC::evaluate(exec, exec->dynamicGlobalObject()->globalSco peChain(), sourceCode.jsSourceCode(), m_workerContextWrapper);
129 m_workerContextWrapper->globalData().timeoutChecker.stop(); 130 m_workerContextWrapper->globalData().timeoutChecker.stop();
130 131
131 if (comp.complType() == Normal || comp.complType() == ReturnValue) 132 if (comp.complType() == Normal || comp.complType() == ReturnValue)
132 return comp.value(); 133 return comp.value();
133 134
134 if (comp.complType() == Throw) 135 if (comp.complType() == Throw) {
135 *exception = comp.value(); 136 String errorMessage;
137 int lineNumber = 0;
138 String sourceURL = sourceCode.url().string();
139 if (m_workerContext->sanitizeScriptError(errorMessage, lineNumber, sourc eURL))
140 *exception = ScriptValue(throwError(exec, createError(exec, errorMes sage.impl())));
141 else
142 *exception = comp.value();
143 }
136 return JSValue(); 144 return JSValue();
137 } 145 }
138 146
139 void WorkerScriptController::setException(ScriptValue exception) 147 void WorkerScriptController::setException(ScriptValue exception)
140 { 148 {
141 throwError(m_workerContextWrapper->globalExec(), exception.jsValue()); 149 throwError(m_workerContextWrapper->globalExec(), exception.jsValue());
142 } 150 }
143 151
144 void WorkerScriptController::forbidExecution(ForbidExecutionOption option) 152 void WorkerScriptController::forbidExecution(ForbidExecutionOption option)
145 { 153 {
146 // This function may be called from another thread. 154 // This function may be called from another thread.
147 // Mutex protection for m_executionForbidden is needed to guarantee that the value is synchronized between processors, because 155 // Mutex protection for m_executionForbidden is needed to guarantee that the value is synchronized between processors, because
148 // if it were not, the worker could re-enter JSC::evaluate(), but with timeo ut already reset. 156 // if it were not, the worker could re-enter JSC::evaluate(), but with timeo ut already reset.
149 // It is not critical for Terminator::m_shouldTerminate to be synchronized, we just rely on it reaching the worker thread's processor sooner or later. 157 // It is not critical for Terminator::m_shouldTerminate to be synchronized, we just rely on it reaching the worker thread's processor sooner or later.
150 MutexLocker lock(m_sharedDataMutex); 158 MutexLocker lock(m_sharedDataMutex);
151 m_executionForbidden = true; 159 m_executionForbidden = true;
152 if (option == TerminateRunningScript) 160 if (option == TerminateRunningScript)
153 m_globalData->terminator.terminateSoon(); 161 m_globalData->terminator.terminateSoon();
154 } 162 }
155 163
156 } // namespace WebCore 164 } // namespace WebCore
157 165
158 #endif // ENABLE(WORKERS) 166 #endif // ENABLE(WORKERS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698