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

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

Issue 1601283003: DevTools: deoilpanize inspector/v8 and related classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments addressed. Created 4 years, 11 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) 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 return 0; 89 return 0;
90 } 90 }
91 91
92 static void reportFatalErrorInMainThread(const char* location, const char* messa ge) 92 static void reportFatalErrorInMainThread(const char* location, const char* messa ge)
93 { 93 {
94 int memoryUsageMB = Platform::current()->actualMemoryUsageMB(); 94 int memoryUsageMB = Platform::current()->actualMemoryUsageMB();
95 printf("V8 error: %s (%s). Current memory usage: %d MB\n", message, locatio n, memoryUsageMB); 95 printf("V8 error: %s (%s). Current memory usage: %d MB\n", message, locatio n, memoryUsageMB);
96 CRASH(); 96 CRASH();
97 } 97 }
98 98
99 static PassRefPtrWillBeRawPtr<ScriptCallStack> extractCallStack(v8::Isolate* iso late, v8::Local<v8::Message> message, int* const scriptId) 99 static PassRefPtr<ScriptCallStack> extractCallStack(v8::Isolate* isolate, v8::Lo cal<v8::Message> message, int* const scriptId)
100 { 100 {
101 v8::Local<v8::StackTrace> stackTrace = message->GetStackTrace(); 101 v8::Local<v8::StackTrace> stackTrace = message->GetStackTrace();
102 RefPtrWillBeRawPtr<ScriptCallStack> callStack = nullptr; 102 RefPtr<ScriptCallStack> callStack = nullptr;
103 *scriptId = message->GetScriptOrigin().ScriptID()->Value(); 103 *scriptId = message->GetScriptOrigin().ScriptID()->Value();
104 // Currently stack trace is only collected when inspector is open. 104 // Currently stack trace is only collected when inspector is open.
105 if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) { 105 if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) {
106 callStack = createScriptCallStack(isolate, stackTrace, ScriptCallStack:: maxCallStackSizeToCapture); 106 callStack = createScriptCallStack(isolate, stackTrace, ScriptCallStack:: maxCallStackSizeToCapture);
107 bool success = false; 107 bool success = false;
108 int topScriptId = callStack->at(0).scriptId().toInt(&success); 108 int topScriptId = callStack->at(0).scriptId().toInt(&success);
109 if (success && topScriptId == *scriptId) 109 if (success && topScriptId == *scriptId)
110 *scriptId = 0; 110 *scriptId = 0;
111 } 111 }
112 return callStack.release(); 112 return callStack.release();
(...skipping 23 matching lines...) Expand all
136 static void messageHandlerInMainThread(v8::Local<v8::Message> message, v8::Local <v8::Value> data) 136 static void messageHandlerInMainThread(v8::Local<v8::Message> message, v8::Local <v8::Value> data)
137 { 137 {
138 ASSERT(isMainThread()); 138 ASSERT(isMainThread());
139 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 139 v8::Isolate* isolate = v8::Isolate::GetCurrent();
140 // If called during context initialization, there will be no entered window. 140 // If called during context initialization, there will be no entered window.
141 LocalDOMWindow* enteredWindow = enteredDOMWindow(isolate); 141 LocalDOMWindow* enteredWindow = enteredDOMWindow(isolate);
142 if (!enteredWindow || !enteredWindow->isCurrentlyDisplayedInFrame()) 142 if (!enteredWindow || !enteredWindow->isCurrentlyDisplayedInFrame())
143 return; 143 return;
144 144
145 int scriptId = 0; 145 int scriptId = 0;
146 RefPtrWillBeRawPtr<ScriptCallStack> callStack = extractCallStack(isolate, me ssage, &scriptId); 146 RefPtr<ScriptCallStack> callStack = extractCallStack(isolate, message, &scri ptId);
147 String resourceName = extractResourceName(message, enteredWindow->document() ); 147 String resourceName = extractResourceName(message, enteredWindow->document() );
148 AccessControlStatus accessControlStatus = NotSharableCrossOrigin; 148 AccessControlStatus accessControlStatus = NotSharableCrossOrigin;
149 if (message->IsOpaque()) 149 if (message->IsOpaque())
150 accessControlStatus = OpaqueResource; 150 accessControlStatus = OpaqueResource;
151 else if (message->IsSharedCrossOrigin()) 151 else if (message->IsSharedCrossOrigin())
152 accessControlStatus = SharableCrossOrigin; 152 accessControlStatus = SharableCrossOrigin;
153 153
154 ScriptState* scriptState = ScriptState::current(isolate); 154 ScriptState* scriptState = ScriptState::current(isolate);
155 String errorMessage = toCoreStringWithNullCheck(message->Get()); 155 String errorMessage = toCoreStringWithNullCheck(message->Get());
156 int lineNumber = 0; 156 int lineNumber = 0;
(...skipping 27 matching lines...) Expand all
184 } else { 184 } else {
185 enteredWindow->document()->reportException(event.release(), scriptId, ca llStack, accessControlStatus); 185 enteredWindow->document()->reportException(event.release(), scriptId, ca llStack, accessControlStatus);
186 } 186 }
187 } 187 }
188 188
189 namespace { 189 namespace {
190 190
191 static RejectedPromises& rejectedPromisesOnMainThread() 191 static RejectedPromises& rejectedPromisesOnMainThread()
192 { 192 {
193 ASSERT(isMainThread()); 193 ASSERT(isMainThread());
194 DEFINE_STATIC_LOCAL(RefPtrWillBePersistent<RejectedPromises>, rejectedPromis es, (RejectedPromises::create())); 194 DEFINE_STATIC_LOCAL(RefPtr<RejectedPromises>, rejectedPromises, (RejectedPro mises::create()));
195 return *rejectedPromises; 195 return *rejectedPromises;
196 } 196 }
197 197
198 } // namespace 198 } // namespace
199 199
200 void V8Initializer::reportRejectedPromisesOnMainThread() 200 void V8Initializer::reportRejectedPromisesOnMainThread()
201 { 201 {
202 rejectedPromisesOnMainThread().processQueue(); 202 rejectedPromisesOnMainThread().processQueue();
203 } 203 }
204 204
(...skipping 19 matching lines...) Expand all
224 if (!error.IsEmpty()) 224 if (!error.IsEmpty())
225 exception = error; 225 exception = error;
226 } 226 }
227 227
228 int scriptId = 0; 228 int scriptId = 0;
229 int lineNumber = 0; 229 int lineNumber = 0;
230 int columnNumber = 0; 230 int columnNumber = 0;
231 String resourceName = fallbackResourceName; 231 String resourceName = fallbackResourceName;
232 String errorMessage; 232 String errorMessage;
233 AccessControlStatus corsStatus = NotSharableCrossOrigin; 233 AccessControlStatus corsStatus = NotSharableCrossOrigin;
234 RefPtrWillBeRawPtr<ScriptCallStack> callStack = nullptr; 234 RefPtr<ScriptCallStack> callStack;
235 235
236 v8::Local<v8::Message> message = v8::Exception::CreateMessage(isolate, excep tion); 236 v8::Local<v8::Message> message = v8::Exception::CreateMessage(isolate, excep tion);
237 if (!message.IsEmpty()) { 237 if (!message.IsEmpty()) {
238 V8StringResource<> v8ResourceName(message->GetScriptOrigin().ResourceNam e()); 238 V8StringResource<> v8ResourceName(message->GetScriptOrigin().ResourceNam e());
239 if (v8ResourceName.prepare()) 239 if (v8ResourceName.prepare())
240 resourceName = v8ResourceName; 240 resourceName = v8ResourceName;
241 scriptId = message->GetScriptOrigin().ScriptID()->Value(); 241 scriptId = message->GetScriptOrigin().ScriptID()->Value();
242 if (v8Call(message->GetLineNumber(scriptState->context()), lineNumber) 242 if (v8Call(message->GetLineNumber(scriptState->context()), lineNumber)
243 && v8Call(message->GetStartColumn(scriptState->context()), columnNum ber)) 243 && v8Call(message->GetStartColumn(scriptState->context()), columnNum ber))
244 ++columnNumber; 244 ++columnNumber;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 if (perIsolateData->isReportingException()) 401 if (perIsolateData->isReportingException())
402 return; 402 return;
403 perIsolateData->setReportingException(true); 403 perIsolateData->setReportingException(true);
404 404
405 ScriptState* scriptState = ScriptState::current(isolate); 405 ScriptState* scriptState = ScriptState::current(isolate);
406 // During the frame teardown, there may not be a valid context. 406 // During the frame teardown, there may not be a valid context.
407 if (ExecutionContext* context = scriptState->executionContext()) { 407 if (ExecutionContext* context = scriptState->executionContext()) {
408 String errorMessage = toCoreStringWithNullCheck(message->Get()); 408 String errorMessage = toCoreStringWithNullCheck(message->Get());
409 TOSTRING_VOID(V8StringResource<>, sourceURL, message->GetScriptOrigin(). ResourceName()); 409 TOSTRING_VOID(V8StringResource<>, sourceURL, message->GetScriptOrigin(). ResourceName());
410 int scriptId = 0; 410 int scriptId = 0;
411 RefPtrWillBeRawPtr<ScriptCallStack> callStack = extractCallStack(isolate , message, &scriptId); 411 RefPtr<ScriptCallStack> callStack = extractCallStack(isolate, message, & scriptId);
412 412
413 int lineNumber = 0; 413 int lineNumber = 0;
414 int columnNumber = 0; 414 int columnNumber = 0;
415 if (v8Call(message->GetLineNumber(scriptState->context()), lineNumber) 415 if (v8Call(message->GetLineNumber(scriptState->context()), lineNumber)
416 && v8Call(message->GetStartColumn(scriptState->context()), columnNum ber)) 416 && v8Call(message->GetStartColumn(scriptState->context()), columnNum ber))
417 ++columnNumber; 417 ++columnNumber;
418 RefPtrWillBeRawPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, sourceURL, lineNumber, columnNumber, &DOMWrapperWorld::current(isolate)); 418 RefPtrWillBeRawPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, sourceURL, lineNumber, columnNumber, &DOMWrapperWorld::current(isolate));
419 AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? Sharab leCrossOrigin : NotSharableCrossOrigin; 419 AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? Sharab leCrossOrigin : NotSharableCrossOrigin;
420 420
421 // If execution termination has been triggered as part of constructing 421 // If execution termination has been triggered as part of constructing
(...skipping 19 matching lines...) Expand all
441 441
442 isolate->AddMessageListener(messageHandlerInWorker); 442 isolate->AddMessageListener(messageHandlerInWorker);
443 isolate->SetFatalErrorHandler(reportFatalErrorInWorker); 443 isolate->SetFatalErrorHandler(reportFatalErrorInWorker);
444 444
445 uint32_t here; 445 uint32_t here;
446 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi ze / sizeof(uint32_t*))); 446 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi ze / sizeof(uint32_t*)));
447 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); 447 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker);
448 } 448 }
449 449
450 } // namespace blink 450 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698