| Index: Source/bindings/v8/V8PerContextData.cpp
|
| diff --git a/Source/bindings/v8/V8PerContextData.cpp b/Source/bindings/v8/V8PerContextData.cpp
|
| index c27db781a0d069bd81ad6b6ad345c42b2536d445..009b8d58d68375f357aa99a95d789a70745f89a8 100644
|
| --- a/Source/bindings/v8/V8PerContextData.cpp
|
| +++ b/Source/bindings/v8/V8PerContextData.cpp
|
| @@ -139,6 +139,7 @@ v8::Local<v8::Function> V8PerContextData::constructorForTypeSlowCase(WrapperType
|
|
|
| return function;
|
| }
|
| +
|
| static v8::Handle<v8::Value> createDebugData(const char* worldName, int debugId)
|
| {
|
| char buffer[32];
|
| @@ -162,15 +163,18 @@ static v8::Handle<v8::Value> debugData(v8::Handle<v8::Context> context)
|
|
|
| static void setDebugData(v8::Handle<v8::Context> context, v8::Handle<v8::Value> value)
|
| {
|
| - v8::Context::Scope contextScope(context);
|
| + ASSERT(*value);
|
| + ASSERT(value->IsString());
|
| context->SetEmbedderData(v8ContextDebugIdIndex, value);
|
| }
|
|
|
| bool V8PerContextDebugData::setContextDebugData(v8::Handle<v8::Context> context, const char* worldName, int debugId)
|
| {
|
| + v8::HandleScope scope;
|
| if (!debugData(context)->IsUndefined())
|
| return false;
|
| - v8::HandleScope scope;
|
| + ASSERT(debugId);
|
| + v8::Context::Scope contextScope(context);
|
| v8::Handle<v8::Value> debugData = createDebugData(worldName, debugId);
|
| setDebugData(context, debugData);
|
| return true;
|
| @@ -190,4 +194,68 @@ int V8PerContextDebugData::contextDebugId(v8::Handle<v8::Context> context)
|
| return atoi(comma + 1);
|
| }
|
|
|
| +ContextCategory V8PerContextDebugData::contextCategory(v8::Handle<v8::Context> context)
|
| +{
|
| + v8::HandleScope scope;
|
| + v8::Handle<v8::Value> data = debugData(context);
|
| +
|
| + if (!data->IsString())
|
| + return NoContextCategory;
|
| +
|
| + v8::String::AsciiValue ascii(data);
|
| + char* comma = strnstr(*ascii, ",", ascii.length());
|
| + if (!comma)
|
| + return NoContextCategory;
|
| +
|
| + String categoryString(*ascii, comma - *ascii);
|
| + if (categoryString == "page") {
|
| + return PageContextCategory;
|
| + }
|
| + if (categoryString == "worker") {
|
| + return WorkerContextCategory;
|
| + }
|
| + if (categoryString == "injected") {
|
| + return ContentScriptContextCategory;
|
| + }
|
| + return NoContextCategory;
|
| +}
|
| +
|
| +static V8PerContextDebugData::ScopedWebCompilation* currentScopedWebCompilation = 0;
|
| +static bool matches(v8::Handle<v8::Context> l_context, v8::Handle<v8::Context> r_context)
|
| +{
|
| + return l_context == r_context;
|
| +}
|
| +
|
| +bool V8PerContextDebugData::isScopedWebCompilation(v8::Handle<v8::Context> context)
|
| +{
|
| + if (currentScopedWebCompilation) {
|
| + return matches(currentScopedWebCompilation->m_context, context);
|
| + } else {
|
| + return false;
|
| + }
|
| +}
|
| +
|
| +bool V8PerContextDebugData::isOneFunctionWebCompilation()
|
| +{
|
| + if (currentScopedWebCompilation) {
|
| + return currentScopedWebCompilation->m_oneFunctionResult;
|
| + } else {
|
| + return false;
|
| + }
|
| +}
|
| +
|
| +V8PerContextDebugData::ScopedWebCompilation::ScopedWebCompilation(v8::Handle<v8::Context> context, bool oneFunctionResult)
|
| + : m_context(context), m_oneFunctionResult(oneFunctionResult)
|
| +{
|
| + // In some cases we may over-write a value other than zero because we eg compile - run - compile all on the same
|
| + // call stack. This is ok: we only need the pointer before each compile and before we ever run the code.
|
| + currentScopedWebCompilation = this;
|
| +}
|
| +
|
| +V8PerContextDebugData::ScopedWebCompilation::~ScopedWebCompilation()
|
| +{
|
| + currentScopedWebCompilation = 0;
|
| +}
|
| +
|
| +
|
| } // namespace WebCore
|
|
|