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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 } | 82 } |
83 execute(frame); | 83 execute(frame); |
84 } else { | 84 } else { |
85 WTF_LOG(Timers, "ScheduledAction::execute %p: worker scope", this); | 85 WTF_LOG(Timers, "ScheduledAction::execute %p: worker scope", this); |
86 execute(toWorkerGlobalScope(context)); | 86 execute(toWorkerGlobalScope(context)); |
87 } | 87 } |
88 } | 88 } |
89 | 89 |
90 void ScheduledAction::execute(LocalFrame* frame) | 90 void ScheduledAction::execute(LocalFrame* frame) |
91 { | 91 { |
92 if (m_scriptState->contextIsValid()) { | 92 if (!m_scriptState->contextIsValid()) { |
93 WTF_LOG(Timers, "ScheduledAction::execute %p: context is empty", this); | 93 WTF_LOG(Timers, "ScheduledAction::execute %p: context is empty", this); |
94 return; | 94 return; |
95 } | 95 } |
96 | 96 |
97 TRACE_EVENT0("v8", "ScheduledAction::execute"); | 97 TRACE_EVENT0("v8", "ScheduledAction::execute"); |
98 ScriptState::Scope scope(m_scriptState.get()); | 98 ScriptState::Scope scope(m_scriptState.get()); |
99 if (!m_function.isEmpty()) { | 99 if (!m_function.isEmpty()) { |
100 WTF_LOG(Timers, "ScheduledAction::execute %p: have function", this); | 100 WTF_LOG(Timers, "ScheduledAction::execute %p: have function", this); |
101 Vector<v8::Handle<v8::Value> > info; | 101 Vector<v8::Handle<v8::Value> > info; |
102 createLocalHandlesForArgs(&info); | 102 createLocalHandlesForArgs(&info); |
103 frame->script().callFunction(m_function.newLocal(m_scriptState->isolate(
)), m_scriptState->context()->Global(), info.size(), info.data()); | 103 frame->script().callFunction(m_function.newLocal(m_scriptState->isolate(
)), m_scriptState->context()->Global(), info.size(), info.data()); |
104 } else { | 104 } else { |
105 WTF_LOG(Timers, "ScheduledAction::execute %p: executing from source", th
is); | 105 WTF_LOG(Timers, "ScheduledAction::execute %p: executing from source", th
is); |
106 frame->script().executeScriptAndReturnValue(m_scriptState->context(), Sc
riptSourceCode(m_code)); | 106 frame->script().executeScriptAndReturnValue(m_scriptState->context(), Sc
riptSourceCode(m_code)); |
107 } | 107 } |
108 | 108 |
109 // The frame might be invalid at this point because JavaScript could have re
leased it. | 109 // The frame might be invalid at this point because JavaScript could have re
leased it. |
110 } | 110 } |
111 | 111 |
112 void ScheduledAction::execute(WorkerGlobalScope* worker) | 112 void ScheduledAction::execute(WorkerGlobalScope* worker) |
113 { | 113 { |
114 ASSERT(worker->thread()->isCurrentThread()); | 114 ASSERT(worker->thread()->isCurrentThread()); |
115 ASSERT(!m_scriptState->contextIsValid()); | 115 ASSERT(m_scriptState->contextIsValid()); |
116 if (!m_function.isEmpty()) { | 116 if (!m_function.isEmpty()) { |
117 ScriptState::Scope scope(m_scriptState.get()); | 117 ScriptState::Scope scope(m_scriptState.get()); |
118 Vector<v8::Handle<v8::Value> > info; | 118 Vector<v8::Handle<v8::Value> > info; |
119 createLocalHandlesForArgs(&info); | 119 createLocalHandlesForArgs(&info); |
120 V8ScriptRunner::callFunction(m_function.newLocal(m_scriptState->isolate(
)), worker, m_scriptState->context()->Global(), info.size(), info.data(), m_scri
ptState->isolate()); | 120 V8ScriptRunner::callFunction(m_function.newLocal(m_scriptState->isolate(
)), worker, m_scriptState->context()->Global(), info.size(), info.data(), m_scri
ptState->isolate()); |
121 } else { | 121 } else { |
122 worker->script()->evaluate(m_code); | 122 worker->script()->evaluate(m_code); |
123 } | 123 } |
124 } | 124 } |
125 | 125 |
126 void ScheduledAction::createLocalHandlesForArgs(Vector<v8::Handle<v8::Value> >*
handles) | 126 void ScheduledAction::createLocalHandlesForArgs(Vector<v8::Handle<v8::Value> >*
handles) |
127 { | 127 { |
128 handles->reserveCapacity(m_info.Size()); | 128 handles->reserveCapacity(m_info.Size()); |
129 for (size_t i = 0; i < m_info.Size(); ++i) | 129 for (size_t i = 0; i < m_info.Size(); ++i) |
130 handles->append(m_info.Get(i)); | 130 handles->append(m_info.Get(i)); |
131 } | 131 } |
132 | 132 |
133 } // namespace blink | 133 } // namespace blink |
OLD | NEW |