Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 return 0; | 76 return 0; |
| 77 } | 77 } |
| 78 | 78 |
| 79 static void reportFatalErrorInMainThread(const char* location, const char* messa ge) | 79 static void reportFatalErrorInMainThread(const char* location, const char* messa ge) |
| 80 { | 80 { |
| 81 int memoryUsageMB = blink::Platform::current()->actualMemoryUsageMB(); | 81 int memoryUsageMB = blink::Platform::current()->actualMemoryUsageMB(); |
| 82 printf("V8 error: %s (%s). Current memory usage: %d MB\n", message, locatio n, memoryUsageMB); | 82 printf("V8 error: %s (%s). Current memory usage: %d MB\n", message, locatio n, memoryUsageMB); |
| 83 CRASH(); | 83 CRASH(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 static LocalFrame* retrieveFrameWithGlobalObjectCheck(v8::Handle<v8::Context> co ntext) | |
| 87 { | |
| 88 if (context.IsEmpty()) | |
| 89 return 0; | |
| 90 | |
| 91 // FIXME: This is a temporary hack for crbug.com/345014. | |
| 92 // Currently it's possible that V8 can trigger Debugger::ProcessDebugEvent f or a context | |
| 93 // that is being initialized (i.e., inside Context::New() of the context). | |
| 94 // We should fix the V8 side so that it won't trigger the event for a half-b aked context | |
| 95 // because there is no way in the embedder side to check if the context is h alf-baked or not. | |
| 96 if (isMainThread() && DOMWrapperWorld::windowIsBeingInitialized()) | |
| 97 return 0; | |
| 98 | |
| 99 v8::Handle<v8::Value> global = V8Window::findInstanceInPrototypeChain(contex t->Global(), context->GetIsolate()); | |
| 100 if (global.IsEmpty()) | |
| 101 return 0; | |
| 102 | |
| 103 return toFrameIfNotDetached(context); | |
|
abarth-chromium
2014/11/19 02:05:40
If you're the only client of this function, you ca
| |
| 104 } | |
| 105 | |
| 86 static void messageHandlerInMainThread(v8::Handle<v8::Message> message, v8::Hand le<v8::Value> data) | 106 static void messageHandlerInMainThread(v8::Handle<v8::Message> message, v8::Hand le<v8::Value> data) |
| 87 { | 107 { |
| 88 ASSERT(isMainThread()); | 108 ASSERT(isMainThread()); |
| 89 // It's possible that messageHandlerInMainThread() is invoked while we're in itializing a window. | 109 // It's possible that messageHandlerInMainThread() is invoked while we're in itializing a window. |
| 90 // In that half-baked situation, we don't have a valid context nor a valid w orld, | 110 // In that half-baked situation, we don't have a valid context nor a valid w orld, |
| 91 // so just return immediately. | 111 // so just return immediately. |
| 92 if (DOMWrapperWorld::windowIsBeingInitialized()) | 112 if (DOMWrapperWorld::windowIsBeingInitialized()) |
| 93 return; | 113 return; |
| 94 | 114 |
| 95 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 115 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 116 // Check if we're in the V8DebugContext which does not have a window object. | |
| 117 if (!retrieveFrameWithGlobalObjectCheck(isolate->GetCurrentContext())) { | |
| 118 printf("Unhandled: %s %s\n", | |
| 119 toCoreString(message->Get()).ascii().data(), | |
| 120 toCoreString(message->GetSourceLine()).ascii().data()); | |
| 121 return; | |
| 122 } | |
| 96 // If called during context initialization, there will be no entered window. | 123 // If called during context initialization, there will be no entered window. |
| 97 LocalDOMWindow* enteredWindow = enteredDOMWindow(isolate); | 124 LocalDOMWindow* enteredWindow = enteredDOMWindow(isolate); |
| 98 if (!enteredWindow) | 125 if (!enteredWindow) |
| 99 return; | 126 return; |
| 100 | 127 |
| 101 String errorMessage = toCoreString(message->Get()); | 128 String errorMessage = toCoreString(message->Get()); |
| 102 | 129 |
| 103 v8::Handle<v8::StackTrace> stackTrace = message->GetStackTrace(); | 130 v8::Handle<v8::StackTrace> stackTrace = message->GetStackTrace(); |
| 104 RefPtr<ScriptCallStack> callStack = nullptr; | 131 RefPtr<ScriptCallStack> callStack = nullptr; |
| 105 int scriptId = message->GetScriptOrigin().ScriptID()->Value(); | 132 int scriptId = message->GetScriptOrigin().ScriptID()->Value(); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 v8::V8::SetFatalErrorHandler(reportFatalErrorInMainThread); | 219 v8::V8::SetFatalErrorHandler(reportFatalErrorInMainThread); |
| 193 v8::V8::AddMessageListener(messageHandlerInMainThread); | 220 v8::V8::AddMessageListener(messageHandlerInMainThread); |
| 194 v8::V8::SetFailedAccessCheckCallbackFunction(failedAccessCheckCallbackInMain Thread); | 221 v8::V8::SetFailedAccessCheckCallbackFunction(failedAccessCheckCallbackInMain Thread); |
| 195 | 222 |
| 196 isolate->SetEventLogger(timerTraceProfilerInMainThread); | 223 isolate->SetEventLogger(timerTraceProfilerInMainThread); |
| 197 | 224 |
| 198 ScriptProfiler::initialize(); | 225 ScriptProfiler::initialize(); |
| 199 } | 226 } |
| 200 | 227 |
| 201 } // namespace blink | 228 } // namespace blink |
| OLD | NEW |