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

Side by Side Diff: Source/bindings/v8/custom/V8WorkerGlobalScopeCustom.cpp

Issue 54283002: Rename |args| to |info| in V8 bindings (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 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 29 matching lines...) Expand all
40 #include "core/inspector/ScriptCallStack.h" 40 #include "core/inspector/ScriptCallStack.h"
41 #include "core/frame/ContentSecurityPolicy.h" 41 #include "core/frame/ContentSecurityPolicy.h"
42 #include "core/frame/DOMTimer.h" 42 #include "core/frame/DOMTimer.h"
43 #include "core/frame/DOMWindowTimers.h" 43 #include "core/frame/DOMWindowTimers.h"
44 #include "core/workers/WorkerGlobalScope.h" 44 #include "core/workers/WorkerGlobalScope.h"
45 #include "modules/websockets/WebSocket.h" 45 #include "modules/websockets/WebSocket.h"
46 #include "wtf/OwnPtr.h" 46 #include "wtf/OwnPtr.h"
47 47
48 namespace WebCore { 48 namespace WebCore {
49 49
50 void SetTimeoutOrInterval(const v8::FunctionCallbackInfo<v8::Value>& args, bool singleShot) 50 void SetTimeoutOrInterval(const v8::FunctionCallbackInfo<v8::Value>& info, bool singleShot)
51 { 51 {
52 WorkerGlobalScope* workerGlobalScope = V8WorkerGlobalScope::toNative(args.Ho lder()); 52 WorkerGlobalScope* workerGlobalScope = V8WorkerGlobalScope::toNative(info.Ho lder());
53 53
54 int argumentCount = args.Length(); 54 int argumentCount = info.Length();
55 if (argumentCount < 1) 55 if (argumentCount < 1)
56 return; 56 return;
57 57
58 v8::Handle<v8::Value> function = args[0]; 58 v8::Handle<v8::Value> function = info[0];
59 59
60 WorkerScriptController* script = workerGlobalScope->script(); 60 WorkerScriptController* script = workerGlobalScope->script();
61 if (!script) 61 if (!script)
62 return; 62 return;
63 63
64 OwnPtr<ScheduledAction> action; 64 OwnPtr<ScheduledAction> action;
65 v8::Handle<v8::Context> v8Context = script->context(); 65 v8::Handle<v8::Context> v8Context = script->context();
66 if (function->IsString()) { 66 if (function->IsString()) {
67 if (ContentSecurityPolicy* policy = workerGlobalScope->contentSecurityPo licy()) { 67 if (ContentSecurityPolicy* policy = workerGlobalScope->contentSecurityPo licy()) {
68 if (!policy->allowEval()) { 68 if (!policy->allowEval()) {
69 v8SetReturnValue(args, 0); 69 v8SetReturnValue(info, 0);
70 return; 70 return;
71 } 71 }
72 } 72 }
73 action = adoptPtr(new ScheduledAction(v8Context, toWebCoreString(functio n.As<v8::String>()), workerGlobalScope->url(), args.GetIsolate())); 73 action = adoptPtr(new ScheduledAction(v8Context, toWebCoreString(functio n.As<v8::String>()), workerGlobalScope->url(), info.GetIsolate()));
74 } else if (function->IsFunction()) { 74 } else if (function->IsFunction()) {
75 size_t paramCount = argumentCount >= 2 ? argumentCount - 2 : 0; 75 size_t paramCount = argumentCount >= 2 ? argumentCount - 2 : 0;
76 OwnPtr<v8::Local<v8::Value>[]> params; 76 OwnPtr<v8::Local<v8::Value>[]> params;
77 if (paramCount > 0) { 77 if (paramCount > 0) {
78 params = adoptArrayPtr(new v8::Local<v8::Value>[paramCount]); 78 params = adoptArrayPtr(new v8::Local<v8::Value>[paramCount]);
79 for (size_t i = 0; i < paramCount; ++i) 79 for (size_t i = 0; i < paramCount; ++i)
80 params[i] = args[i+2]; 80 params[i] = info[i+2];
81 } 81 }
82 // ScheduledAction takes ownership of actual params and releases them in its destructor. 82 // ScheduledAction takes ownership of actual params and releases them in its destructor.
83 action = adoptPtr(new ScheduledAction(v8Context, v8::Handle<v8::Function >::Cast(function), paramCount, params.get(), args.GetIsolate())); 83 action = adoptPtr(new ScheduledAction(v8Context, v8::Handle<v8::Function >::Cast(function), paramCount, params.get(), info.GetIsolate()));
84 } else 84 } else
85 return; 85 return;
86 86
87 int32_t timeout = argumentCount >= 2 ? args[1]->Int32Value() : 0; 87 int32_t timeout = argumentCount >= 2 ? info[1]->Int32Value() : 0;
88 int timerId; 88 int timerId;
89 if (singleShot) 89 if (singleShot)
90 timerId = DOMWindowTimers::setTimeout(workerGlobalScope, action.release( ), timeout); 90 timerId = DOMWindowTimers::setTimeout(workerGlobalScope, action.release( ), timeout);
91 else 91 else
92 timerId = DOMWindowTimers::setInterval(workerGlobalScope, action.release (), timeout); 92 timerId = DOMWindowTimers::setInterval(workerGlobalScope, action.release (), timeout);
93 93
94 v8SetReturnValue(args, timerId); 94 v8SetReturnValue(info, timerId);
95 } 95 }
96 96
97 void V8WorkerGlobalScope::setTimeoutMethodCustom(const v8::FunctionCallbackInfo< v8::Value>& args) 97 void V8WorkerGlobalScope::setTimeoutMethodCustom(const v8::FunctionCallbackInfo< v8::Value>& info)
98 { 98 {
99 return SetTimeoutOrInterval(args, true); 99 return SetTimeoutOrInterval(info, true);
100 } 100 }
101 101
102 void V8WorkerGlobalScope::setIntervalMethodCustom(const v8::FunctionCallbackInfo <v8::Value>& args) 102 void V8WorkerGlobalScope::setIntervalMethodCustom(const v8::FunctionCallbackInfo <v8::Value>& info)
103 { 103 {
104 return SetTimeoutOrInterval(args, false); 104 return SetTimeoutOrInterval(info, false);
105 } 105 }
106 106
107 v8::Handle<v8::Value> toV8(WorkerGlobalScope* impl, v8::Handle<v8::Object> creat ionContext, v8::Isolate* isolate) 107 v8::Handle<v8::Value> toV8(WorkerGlobalScope* impl, v8::Handle<v8::Object> creat ionContext, v8::Isolate* isolate)
108 { 108 {
109 // Notice that we explicitly ignore creationContext because the WorkerGlobal Scope is its own creationContext. 109 // Notice that we explicitly ignore creationContext because the WorkerGlobal Scope is its own creationContext.
110 110
111 if (!impl) 111 if (!impl)
112 return v8NullWithCheck(isolate); 112 return v8NullWithCheck(isolate);
113 113
114 WorkerScriptController* script = impl->script(); 114 WorkerScriptController* script = impl->script();
115 if (!script) 115 if (!script)
116 return v8NullWithCheck(isolate); 116 return v8NullWithCheck(isolate);
117 117
118 v8::Handle<v8::Object> global = script->context()->Global(); 118 v8::Handle<v8::Object> global = script->context()->Global();
119 ASSERT(!global.IsEmpty()); 119 ASSERT(!global.IsEmpty());
120 return global; 120 return global;
121 } 121 }
122 122
123 } // namespace WebCore 123 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/custom/V8WorkerCustom.cpp ('k') | Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698