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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ScheduledAction.cpp

Issue 2817533003: Replace ASSERT, RELEASE_ASSERT, and ASSERT_NOT_REACHED in bindings (Closed)
Patch Set: Created 3 years, 8 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
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "core/workers/WorkerGlobalScope.h" 44 #include "core/workers/WorkerGlobalScope.h"
45 #include "core/workers/WorkerThread.h" 45 #include "core/workers/WorkerThread.h"
46 #include "platform/instrumentation/tracing/TraceEvent.h" 46 #include "platform/instrumentation/tracing/TraceEvent.h"
47 47
48 namespace blink { 48 namespace blink {
49 49
50 ScheduledAction* ScheduledAction::Create(ScriptState* script_state, 50 ScheduledAction* ScheduledAction::Create(ScriptState* script_state,
51 ExecutionContext* target, 51 ExecutionContext* target,
52 const ScriptValue& handler, 52 const ScriptValue& handler,
53 const Vector<ScriptValue>& arguments) { 53 const Vector<ScriptValue>& arguments) {
54 ASSERT(handler.IsFunction()); 54 DCHECK(handler.IsFunction());
55 if (!script_state->World().IsWorkerWorld()) { 55 if (!script_state->World().IsWorkerWorld()) {
56 if (!BindingSecurity::ShouldAllowAccessToFrame( 56 if (!BindingSecurity::ShouldAllowAccessToFrame(
57 EnteredDOMWindow(script_state->GetIsolate()), 57 EnteredDOMWindow(script_state->GetIsolate()),
58 ToDocument(target)->GetFrame(), 58 ToDocument(target)->GetFrame(),
59 BindingSecurity::ErrorReportOption::kDoNotReport)) { 59 BindingSecurity::ErrorReportOption::kDoNotReport)) {
60 UseCounter::Count(target, UseCounter::kScheduledActionIgnored); 60 UseCounter::Count(target, UseCounter::kScheduledActionIgnored);
61 return new ScheduledAction(script_state); 61 return new ScheduledAction(script_state);
62 } 62 }
63 } 63 }
64 return new ScheduledAction(script_state, handler, arguments); 64 return new ScheduledAction(script_state, handler, arguments);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 Execute(ToWorkerGlobalScope(context)); 113 Execute(ToWorkerGlobalScope(context));
114 } 114 }
115 } 115 }
116 116
117 ScheduledAction::ScheduledAction(ScriptState* script_state, 117 ScheduledAction::ScheduledAction(ScriptState* script_state,
118 const ScriptValue& function, 118 const ScriptValue& function,
119 const Vector<ScriptValue>& arguments) 119 const Vector<ScriptValue>& arguments)
120 : script_state_(script_state), 120 : script_state_(script_state),
121 info_(script_state->GetIsolate()), 121 info_(script_state->GetIsolate()),
122 code_(String(), KURL(), TextPosition::BelowRangePosition()) { 122 code_(String(), KURL(), TextPosition::BelowRangePosition()) {
123 ASSERT(function.IsFunction()); 123 DCHECK(function.IsFunction());
124 function_.Set(script_state->GetIsolate(), 124 function_.Set(script_state->GetIsolate(),
125 v8::Local<v8::Function>::Cast(function.V8Value())); 125 v8::Local<v8::Function>::Cast(function.V8Value()));
126 info_.ReserveCapacity(arguments.size()); 126 info_.ReserveCapacity(arguments.size());
127 for (const ScriptValue& argument : arguments) 127 for (const ScriptValue& argument : arguments)
128 info_.Append(argument.V8Value()); 128 info_.Append(argument.V8Value());
129 } 129 }
130 130
131 ScheduledAction::ScheduledAction(ScriptState* script_state, const String& code) 131 ScheduledAction::ScheduledAction(ScriptState* script_state, const String& code)
132 : script_state_(script_state), 132 : script_state_(script_state),
133 info_(script_state->GetIsolate()), 133 info_(script_state->GetIsolate()),
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 << ": executing from source"; 167 << ": executing from source";
168 frame->Script().ExecuteScriptAndReturnValue(script_state_->GetContext(), 168 frame->Script().ExecuteScriptAndReturnValue(script_state_->GetContext(),
169 ScriptSourceCode(code_)); 169 ScriptSourceCode(code_));
170 } 170 }
171 171
172 // The frame might be invalid at this point because JavaScript could have 172 // The frame might be invalid at this point because JavaScript could have
173 // released it. 173 // released it.
174 } 174 }
175 175
176 void ScheduledAction::Execute(WorkerGlobalScope* worker) { 176 void ScheduledAction::Execute(WorkerGlobalScope* worker) {
177 ASSERT(worker->GetThread()->IsCurrentThread()); 177 DCHECK(worker->GetThread()->IsCurrentThread());
178 178
179 if (!script_state_->ContextIsValid()) { 179 if (!script_state_->ContextIsValid()) {
180 DVLOG(1) << "ScheduledAction::execute " << this << ": context is empty"; 180 DVLOG(1) << "ScheduledAction::execute " << this << ": context is empty";
181 return; 181 return;
182 } 182 }
183 183
184 if (!function_.IsEmpty()) { 184 if (!function_.IsEmpty()) {
185 ScriptState::Scope scope(script_state_.Get()); 185 ScriptState::Scope scope(script_state_.Get());
186 v8::Local<v8::Function> function = 186 v8::Local<v8::Function> function =
187 function_.NewLocal(script_state_->GetIsolate()); 187 function_.NewLocal(script_state_->GetIsolate());
(...skipping 15 matching lines...) Expand all
203 } 203 }
204 204
205 void ScheduledAction::CreateLocalHandlesForArgs( 205 void ScheduledAction::CreateLocalHandlesForArgs(
206 Vector<v8::Local<v8::Value>>* handles) { 206 Vector<v8::Local<v8::Value>>* handles) {
207 handles->ReserveCapacity(info_.Size()); 207 handles->ReserveCapacity(info_.Size());
208 for (size_t i = 0; i < info_.Size(); ++i) 208 for (size_t i = 0; i < info_.Size(); ++i)
209 handles->push_back(info_.Get(i)); 209 handles->push_back(info_.Get(i));
210 } 210 }
211 211
212 } // namespace blink 212 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698