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

Side by Side Diff: sky/engine/bindings/core/v8/ScheduledAction.cpp

Issue 922053002: Remove unused V8 integration code in Sky (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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
(Empty)
1 /*
2 * Copyright (C) 2007-2009 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #include "sky/engine/config.h"
32 #include "sky/engine/bindings/core/v8/ScheduledAction.h"
33
34 #include "sky/engine/bindings/core/v8/ScriptController.h"
35 #include "sky/engine/bindings/core/v8/ScriptSourceCode.h"
36 #include "sky/engine/bindings/core/v8/V8Binding.h"
37 #include "sky/engine/bindings/core/v8/V8GCController.h"
38 #include "sky/engine/bindings/core/v8/V8ScriptRunner.h"
39 #include "sky/engine/core/dom/Document.h"
40 #include "sky/engine/core/dom/ExecutionContext.h"
41 #include "sky/engine/core/frame/LocalFrame.h"
42 #include "sky/engine/platform/Logging.h"
43 #include "sky/engine/platform/TraceEvent.h"
44
45 namespace blink {
46
47 ScheduledAction::ScheduledAction(ScriptState* scriptState, v8::Handle<v8::Functi on> function, int argc, v8::Handle<v8::Value> argv[], v8::Isolate* isolate)
48 : m_scriptState(scriptState)
49 , m_function(isolate, function)
50 , m_info(isolate)
51 , m_code(String(), KURL(), TextPosition::belowRangePosition())
52 {
53 m_info.ReserveCapacity(argc);
54 for (int i = 0; i < argc; ++i)
55 m_info.Append(argv[i]);
56 }
57
58 ScheduledAction::ScheduledAction(ScriptState* scriptState, const String& code, c onst KURL& url, v8::Isolate* isolate)
59 : m_scriptState(scriptState)
60 , m_info(isolate)
61 , m_code(code, url)
62 {
63 }
64
65 ScheduledAction::~ScheduledAction()
66 {
67 }
68
69 void ScheduledAction::execute(ExecutionContext* context)
70 {
71 LocalFrame* frame = toDocument(context)->frame();
72 if (!frame) {
73 WTF_LOG(Timers, "ScheduledAction::execute %p: no frame", this);
74 return;
75 }
76 execute(frame);
77 }
78
79 void ScheduledAction::execute(LocalFrame* frame)
80 {
81 if (m_scriptState->contextIsEmpty()) {
82 WTF_LOG(Timers, "ScheduledAction::execute %p: context is empty", this);
83 return;
84 }
85
86 TRACE_EVENT0("v8", "ScheduledAction::execute");
87 ScriptState::Scope scope(m_scriptState.get());
88 if (!m_function.isEmpty()) {
89 WTF_LOG(Timers, "ScheduledAction::execute %p: have function", this);
90 Vector<v8::Handle<v8::Value> > info;
91 createLocalHandlesForArgs(&info);
92 frame->script().callFunction(m_function.newLocal(m_scriptState->isolate( )), m_scriptState->context()->Global(), info.size(), info.data());
93 } else {
94 WTF_LOG(Timers, "ScheduledAction::execute %p: executing from source", th is);
95 frame->script().executeScriptAndReturnValue(m_scriptState->context(), Sc riptSourceCode(m_code));
96 }
97
98 // The frame might be invalid at this point because JavaScript could have re leased it.
99 }
100
101 void ScheduledAction::createLocalHandlesForArgs(Vector<v8::Handle<v8::Value> >* handles)
102 {
103 handles->reserveCapacity(m_info.Size());
104 for (size_t i = 0; i < m_info.Size(); ++i)
105 handles->append(m_info.Get(i));
106 }
107
108 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/bindings/core/v8/ScheduledAction.h ('k') | sky/engine/bindings/core/v8/ScopedPersistent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698