| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007-2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2007-2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 if (!frame->script().canExecuteScripts(AboutToExecuteScript)) | 76 if (!frame->script().canExecuteScripts(AboutToExecuteScript)) |
| 77 return; | 77 return; |
| 78 execute(frame); | 78 execute(frame); |
| 79 } else { | 79 } else { |
| 80 execute(toWorkerGlobalScope(context)); | 80 execute(toWorkerGlobalScope(context)); |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 | 83 |
| 84 void ScheduledAction::execute(LocalFrame* frame) | 84 void ScheduledAction::execute(LocalFrame* frame) |
| 85 { | 85 { |
| 86 if (m_scriptState->contextIsEmpty()) | 86 if (m_scriptState->contextIsValue()) |
| 87 return; | 87 return; |
| 88 | 88 |
| 89 TRACE_EVENT0("v8", "ScheduledAction::execute"); | 89 TRACE_EVENT0("v8", "ScheduledAction::execute"); |
| 90 ScriptState::Scope scope(m_scriptState.get()); | 90 ScriptState::Scope scope(m_scriptState.get()); |
| 91 if (!m_function.isEmpty()) { | 91 if (!m_function.isEmpty()) { |
| 92 Vector<v8::Handle<v8::Value> > info; | 92 Vector<v8::Handle<v8::Value> > info; |
| 93 createLocalHandlesForArgs(&info); | 93 createLocalHandlesForArgs(&info); |
| 94 frame->script().callFunction(m_function.newLocal(m_scriptState->isolate(
)), m_scriptState->context()->Global(), info.size(), info.data()); | 94 frame->script().callFunction(m_function.newLocal(m_scriptState->isolate(
)), m_scriptState->context()->Global(), info.size(), info.data()); |
| 95 } else { | 95 } else { |
| 96 frame->script().executeScriptAndReturnValue(m_scriptState->context(), Sc
riptSourceCode(m_code)); | 96 frame->script().executeScriptAndReturnValue(m_scriptState->context(), Sc
riptSourceCode(m_code)); |
| 97 } | 97 } |
| 98 | 98 |
| 99 // The frame might be invalid at this point because JavaScript could have re
leased it. | 99 // The frame might be invalid at this point because JavaScript could have re
leased it. |
| 100 } | 100 } |
| 101 | 101 |
| 102 void ScheduledAction::execute(WorkerGlobalScope* worker) | 102 void ScheduledAction::execute(WorkerGlobalScope* worker) |
| 103 { | 103 { |
| 104 ASSERT(worker->thread()->isCurrentThread()); | 104 ASSERT(worker->thread()->isCurrentThread()); |
| 105 ASSERT(!m_scriptState->contextIsEmpty()); | 105 ASSERT(!m_scriptState->contextIsValue()); |
| 106 if (!m_function.isEmpty()) { | 106 if (!m_function.isEmpty()) { |
| 107 ScriptState::Scope scope(m_scriptState.get()); | 107 ScriptState::Scope scope(m_scriptState.get()); |
| 108 Vector<v8::Handle<v8::Value> > info; | 108 Vector<v8::Handle<v8::Value> > info; |
| 109 createLocalHandlesForArgs(&info); | 109 createLocalHandlesForArgs(&info); |
| 110 V8ScriptRunner::callFunction(m_function.newLocal(m_scriptState->isolate(
)), worker, m_scriptState->context()->Global(), info.size(), info.data(), m_scri
ptState->isolate()); | 110 V8ScriptRunner::callFunction(m_function.newLocal(m_scriptState->isolate(
)), worker, m_scriptState->context()->Global(), info.size(), info.data(), m_scri
ptState->isolate()); |
| 111 } else { | 111 } else { |
| 112 worker->script()->evaluate(m_code); | 112 worker->script()->evaluate(m_code); |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 | 115 |
| 116 void ScheduledAction::createLocalHandlesForArgs(Vector<v8::Handle<v8::Value> >*
handles) | 116 void ScheduledAction::createLocalHandlesForArgs(Vector<v8::Handle<v8::Value> >*
handles) |
| 117 { | 117 { |
| 118 handles->reserveCapacity(m_info.Size()); | 118 handles->reserveCapacity(m_info.Size()); |
| 119 for (size_t i = 0; i < m_info.Size(); ++i) | 119 for (size_t i = 0; i < m_info.Size(); ++i) |
| 120 handles->append(m_info.Get(i)); | 120 handles->append(m_info.Get(i)); |
| 121 } | 121 } |
| 122 | 122 |
| 123 } // namespace blink | 123 } // namespace blink |
| OLD | NEW |