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

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: fixed dcheck build error 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 } else { 107 } else {
108 DVLOG(1) << "ScheduledAction::execute " << this << ": worker scope"; 108 DVLOG(1) << "ScheduledAction::execute " << this << ": worker scope";
109 Execute(ToWorkerGlobalScope(context)); 109 Execute(ToWorkerGlobalScope(context));
110 } 110 }
111 } 111 }
112 112
113 ScheduledAction::ScheduledAction(ScriptState* script_state, 113 ScheduledAction::ScheduledAction(ScriptState* script_state,
114 const ScriptValue& function, 114 const ScriptValue& function,
115 const Vector<ScriptValue>& arguments) 115 const Vector<ScriptValue>& arguments)
116 : script_state_(script_state), info_(script_state->GetIsolate()) { 116 : script_state_(script_state), info_(script_state->GetIsolate()) {
117 ASSERT(function.IsFunction()); 117 DCHECK(function.IsFunction());
118 function_.Set(script_state->GetIsolate(), 118 function_.Set(script_state->GetIsolate(),
119 v8::Local<v8::Function>::Cast(function.V8Value())); 119 v8::Local<v8::Function>::Cast(function.V8Value()));
120 info_.ReserveCapacity(arguments.size()); 120 info_.ReserveCapacity(arguments.size());
121 for (const ScriptValue& argument : arguments) 121 for (const ScriptValue& argument : arguments)
122 info_.Append(argument.V8Value()); 122 info_.Append(argument.V8Value());
123 } 123 }
124 124
125 ScheduledAction::ScheduledAction(ScriptState* script_state, const String& code) 125 ScheduledAction::ScheduledAction(ScriptState* script_state, const String& code)
126 : script_state_(script_state), 126 : script_state_(script_state),
127 info_(script_state->GetIsolate()), 127 info_(script_state->GetIsolate()),
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 << ": executing from source"; 159 << ": executing from source";
160 frame->GetScriptController().ExecuteScriptAndReturnValue( 160 frame->GetScriptController().ExecuteScriptAndReturnValue(
161 script_state_->GetContext(), ScriptSourceCode(code_)); 161 script_state_->GetContext(), ScriptSourceCode(code_));
162 } 162 }
163 163
164 // The frame might be invalid at this point because JavaScript could have 164 // The frame might be invalid at this point because JavaScript could have
165 // released it. 165 // released it.
166 } 166 }
167 167
168 void ScheduledAction::Execute(WorkerGlobalScope* worker) { 168 void ScheduledAction::Execute(WorkerGlobalScope* worker) {
169 ASSERT(worker->GetThread()->IsCurrentThread()); 169 DCHECK(worker->GetThread()->IsCurrentThread());
170 170
171 if (!script_state_->ContextIsValid()) { 171 if (!script_state_->ContextIsValid()) {
172 DVLOG(1) << "ScheduledAction::execute " << this << ": context is empty"; 172 DVLOG(1) << "ScheduledAction::execute " << this << ": context is empty";
173 return; 173 return;
174 } 174 }
175 175
176 if (!function_.IsEmpty()) { 176 if (!function_.IsEmpty()) {
177 ScriptState::Scope scope(script_state_.Get()); 177 ScriptState::Scope scope(script_state_.Get());
178 v8::Local<v8::Function> function = 178 v8::Local<v8::Function> function =
179 function_.NewLocal(script_state_->GetIsolate()); 179 function_.NewLocal(script_state_->GetIsolate());
(...skipping 15 matching lines...) Expand all
195 } 195 }
196 196
197 void ScheduledAction::CreateLocalHandlesForArgs( 197 void ScheduledAction::CreateLocalHandlesForArgs(
198 Vector<v8::Local<v8::Value>>* handles) { 198 Vector<v8::Local<v8::Value>>* handles) {
199 handles->ReserveCapacity(info_.Size()); 199 handles->ReserveCapacity(info_.Size());
200 for (size_t i = 0; i < info_.Size(); ++i) 200 for (size_t i = 0; i < info_.Size(); ++i)
201 handles->push_back(info_.Get(i)); 201 handles->push_back(info_.Get(i));
202 } 202 }
203 203
204 } // namespace blink 204 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698