Chromium Code Reviews| Index: Source/bindings/v8/V8PerContextData.cpp |
| diff --git a/Source/bindings/v8/V8PerContextData.cpp b/Source/bindings/v8/V8PerContextData.cpp |
| index c32699780bdd8d773931c913882d77642f07235c..3a0c91b85932554839a25dee16bac346fb8590b5 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,47 @@ int V8PerContextDebugData::contextDebugId(v8::Handle<v8::Context> context) |
| return atoi(comma + 1); |
| } |
| +String V8PerContextDebugData::contextCategory(v8::Handle<v8::Context> context) |
| +{ |
| + v8::HandleScope scope; |
| + v8::Handle<v8::Value> data = debugData(context); |
| + |
| + if (!data->IsString()) |
| + return ""; |
| + |
| + v8::String::AsciiValue ascii(data); |
| + char* comma = strnstr(*ascii, ",", ascii.length()); |
| + if (!comma) |
| + return ""; |
| + |
| + return String(*ascii, comma - *ascii); |
| +} |
| + |
| +static V8PerContextDebugData::SystemScope* currentSystemScope = 0; |
|
pfeldman
2013/05/01 07:33:55
static scope is likely to be non-workers friendly
|
| + |
| +bool V8PerContextDebugData::isSystemScope(v8::Handle<v8::Context> context) |
|
pfeldman
2013/05/01 07:33:55
isSystemScope for Context does not correlate with
|
| +{ |
| + if (currentSystemScope) { |
| + return currentSystemScope->matches(context); |
| + } else { |
| + return false; |
| + } |
| +} |
| + |
| +V8PerContextDebugData::SystemScope::SystemScope(v8::Handle<v8::Context> context) |
| + : m_context(context) |
| +{ |
| + currentSystemScope = this; |
| +} |
| + |
| +V8PerContextDebugData::SystemScope::~SystemScope() |
| +{ |
| + currentSystemScope = 0; |
| +} |
| + |
| +bool V8PerContextDebugData::SystemScope::matches(v8::Handle<v8::Context> context) |
| +{ |
| + return context == m_context; |
| +} |
| + |
| } // namespace WebCore |