| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 #include "ScriptController.h" | 43 #include "ScriptController.h" |
| 44 #include "V8Binding.h" | 44 #include "V8Binding.h" |
| 45 #include "V8GCController.h" | 45 #include "V8GCController.h" |
| 46 #include "V8RecursionScope.h" | 46 #include "V8RecursionScope.h" |
| 47 #include "WorkerContext.h" | 47 #include "WorkerContext.h" |
| 48 #include "WorkerThread.h" | 48 #include "WorkerThread.h" |
| 49 | 49 |
| 50 namespace WebCore { | 50 namespace WebCore { |
| 51 | 51 |
| 52 ScheduledAction::ScheduledAction(v8::Handle<v8::Context> context, v8::Handle<v8:
:Function> function, int argc, v8::Handle<v8::Value> argv[]) | 52 ScheduledAction::ScheduledAction(v8::Handle<v8::Context> context, v8::Handle<v8:
:Function> function, int argc, v8::Handle<v8::Value> argv[], v8::Isolate* isolat
e) |
| 53 : m_context(context) | 53 : m_context(context) |
| 54 , m_function(function) | 54 , m_function(function) |
| 55 , m_code(String(), KURL(), TextPosition::belowRangePosition()) | 55 , m_code(String(), KURL(), TextPosition::belowRangePosition()) |
| 56 , m_isolate(isolate) |
| 56 { | 57 { |
| 57 v8::Isolate* isolate = m_context->GetIsolate(); | |
| 58 m_args.reserveCapacity(argc); | 58 m_args.reserveCapacity(argc); |
| 59 for (int i = 0; i < argc; ++i) | 59 for (int i = 0; i < argc; ++i) |
| 60 m_args.append(v8::Persistent<v8::Value>::New(isolate, argv[i])); | 60 m_args.append(v8::Persistent<v8::Value>::New(m_isolate, argv[i])); |
| 61 } |
| 62 |
| 63 ScheduledAction::ScheduledAction(v8::Handle<v8::Context> context, const String&
code, const KURL& url, v8::Isolate* isolate) |
| 64 : m_context(context) |
| 65 , m_code(code, url) |
| 66 , m_isolate(isolate) |
| 67 { |
| 61 } | 68 } |
| 62 | 69 |
| 63 ScheduledAction::~ScheduledAction() | 70 ScheduledAction::~ScheduledAction() |
| 64 { | 71 { |
| 65 for (size_t i = 0; i < m_args.size(); ++i) { | 72 for (size_t i = 0; i < m_args.size(); ++i) { |
| 66 m_args[i].Dispose(m_context->GetIsolate()); | 73 m_args[i].Dispose(m_isolate); |
| 67 m_args[i].Clear(); | 74 m_args[i].Clear(); |
| 68 } | 75 } |
| 69 } | 76 } |
| 70 | 77 |
| 71 void ScheduledAction::execute(ScriptExecutionContext* context) | 78 void ScheduledAction::execute(ScriptExecutionContext* context) |
| 72 { | 79 { |
| 73 if (context->isDocument()) { | 80 if (context->isDocument()) { |
| 74 Frame* frame = static_cast<Document*>(context)->frame(); | 81 Frame* frame = static_cast<Document*>(context)->frame(); |
| 75 if (!frame) | 82 if (!frame) |
| 76 return; | 83 return; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 ASSERT(!context.IsEmpty()); | 130 ASSERT(!context.IsEmpty()); |
| 124 v8::Context::Scope scope(context); | 131 v8::Context::Scope scope(context); |
| 125 | 132 |
| 126 m_function->Call(context->Global(), m_args.size(), m_args.data()); | 133 m_function->Call(context->Global(), m_args.size(), m_args.data()); |
| 127 } else | 134 } else |
| 128 worker->script()->evaluate(m_code); | 135 worker->script()->evaluate(m_code); |
| 129 } | 136 } |
| 130 #endif | 137 #endif |
| 131 | 138 |
| 132 } // namespace WebCore | 139 } // namespace WebCore |
| OLD | NEW |