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

Unified Diff: third_party/WebKit/Source/platform/instrumentation/inspector/PlatformIdentifiersFactory.cpp

Issue 2706643002: DevTools: Move network request instrumentation points for timeline down the stack. (Closed)
Patch Set: addressing comment Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/instrumentation/inspector/PlatformIdentifiersFactory.cpp
diff --git a/third_party/WebKit/Source/platform/instrumentation/inspector/PlatformIdentifiersFactory.cpp b/third_party/WebKit/Source/platform/instrumentation/inspector/PlatformIdentifiersFactory.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4d5daf95cc5e59b3ea90fc2631f88b4d8b7a8073
--- /dev/null
+++ b/third_party/WebKit/Source/platform/instrumentation/inspector/PlatformIdentifiersFactory.cpp
@@ -0,0 +1,57 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "platform/instrumentation/inspector/PlatformIdentifiersFactory.h"
+
+#include "public/platform/Platform.h"
+#include "wtf/Assertions.h"
+#include "wtf/text/StringBuilder.h"
+
+namespace blink {
+
+namespace {
+
+volatile int s_lastUsedIdentifier = 0;
+
+} // namespace
+
+// static
+String PlatformIdentifiersFactory::createIdentifier() {
+ int identifier = atomicIncrement(&s_lastUsedIdentifier);
+ return addProcessIdPrefixTo(identifier);
+}
+
+// static
+String PlatformIdentifiersFactory::requestId(unsigned long identifier) {
+ return identifier ? addProcessIdPrefixTo(identifier) : String();
+}
+
+// static
+String PlatformIdentifiersFactory::addProcessIdPrefixTo(int 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 PlatformIdentifiersFactory::removeProcessIdPrefixFrom(const String& id,
+ bool* ok) {
+ size_t dotIndex = id.find('.');
+
+ if (dotIndex == kNotFound) {
+ *ok = false;
+ return 0;
+ }
+ return id.substring(dotIndex + 1).toInt(ok);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698