| Index: third_party/WebKit/Source/core/inspector/IdentifiersFactory.cpp
|
| diff --git a/third_party/WebKit/Source/core/inspector/IdentifiersFactory.cpp b/third_party/WebKit/Source/core/inspector/IdentifiersFactory.cpp
|
| index 5482e92ca76be424f6a670383041b077d9a05008..e88630d5903d366317d24dc9df3d61bf81fbd67c 100644
|
| --- a/third_party/WebKit/Source/core/inspector/IdentifiersFactory.cpp
|
| +++ b/third_party/WebKit/Source/core/inspector/IdentifiersFactory.cpp
|
| @@ -37,33 +37,16 @@ namespace blink {
|
|
|
| namespace {
|
|
|
| -static long s_lastUsedIdentifier = 0;
|
| -
|
| -// static
|
| -String& processIdPrefix()
|
| -{
|
| - DEFINE_STATIC_LOCAL(String, s_processIdPrefix, ());
|
| - return s_processIdPrefix;
|
| -}
|
| +volatile int s_lastUsedIdentifier = 0;
|
|
|
| } // namespace
|
|
|
|
|
| // static
|
| -void IdentifiersFactory::initialize()
|
| -{
|
| - StringBuilder builder;
|
| -
|
| - builder.appendNumber(Platform::current()->getUniqueIdForProcess());
|
| - builder.append('.');
|
| - ASSERT(processIdPrefix().isEmpty() || processIdPrefix() == builder.toString());
|
| - processIdPrefix() = builder.toString();
|
| -}
|
| -
|
| -// static
|
| String IdentifiersFactory::createIdentifier()
|
| {
|
| - return addProcessIdPrefixTo(++s_lastUsedIdentifier);
|
| + int identifier = atomicIncrement(&s_lastUsedIdentifier);
|
| + return addProcessIdPrefixTo(identifier);
|
| }
|
|
|
| // static
|
| @@ -110,19 +93,27 @@ DocumentLoader* IdentifiersFactory::loaderById(InspectedFrames* inspectedFrames,
|
| // static
|
| String IdentifiersFactory::addProcessIdPrefixTo(int id)
|
| {
|
| - if (processIdPrefix().isEmpty())
|
| - initialize();
|
| - return processIdPrefix() + String::number(id);
|
| + DEFINE_THREAD_SAFE_STATIC_LOCAL(uint32_t, s_processId, new uint32_t(Platform::current()->getUniqueIdForProcess()));
|
| +
|
| + StringBuilder builder;
|
| +
|
| + builder.appendNumber(s_processId);
|
| + builder.append('.');
|
| + builder.appendNumber(id);
|
| +
|
| + return builder.toString();
|
| }
|
|
|
| // static
|
| int IdentifiersFactory::removeProcessIdPrefixFrom(const String& id, bool* ok)
|
| {
|
| - if (id.length() < processIdPrefix().length()) {
|
| + size_t dotIndex = id.find('.');
|
| +
|
| + if (dotIndex == kNotFound) {
|
| *ok = false;
|
| return 0;
|
| }
|
| - return id.substring(processIdPrefix().length()).toInt(ok);
|
| + return id.substring(dotIndex + 1).toInt(ok);
|
| }
|
|
|
| } // namespace blink
|
|
|