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

Unified Diff: Source/core/inspector/PromiseTracker.h

Issue 433653003: Support Promises event-based instrumentation on backend. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Disable PromiseTracker and REBASE Created 6 years, 4 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: Source/core/inspector/PromiseTracker.h
diff --git a/Source/core/inspector/PromiseTracker.h b/Source/core/inspector/PromiseTracker.h
new file mode 100644
index 0000000000000000000000000000000000000000..c2d532d04e0f78cf5abbfdc0ebaadb8082eb7e52
--- /dev/null
+++ b/Source/core/inspector/PromiseTracker.h
@@ -0,0 +1,64 @@
+// Copyright 2014 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.
+
+#ifndef PromiseTracker_h
+#define PromiseTracker_h
+
+#include "bindings/core/v8/ScopedPersistent.h"
+#include "core/inspector/ScriptCallFrame.h"
+#include "wtf/HashMap.h"
+#include "wtf/Noncopyable.h"
+#include "wtf/RefPtr.h"
+#include "wtf/Vector.h"
+#include "wtf/WeakPtr.h"
+#include <v8.h>
+
+namespace blink {
+
+class ScriptState;
+
+class PromiseTracker {
+ WTF_MAKE_NONCOPYABLE(PromiseTracker);
+public:
+ PromiseTracker() : m_isEnabled(false) { }
+
+ bool isEnabled() const { return m_isEnabled; }
+ void enable();
+ void disable();
+
+ void clear();
+
+ void didReceiveV8PromiseEvent(ScriptState*, v8::Handle<v8::Object> promise, v8::Handle<v8::Value> parentPromise, int status);
+
+ class PromiseData : public RefCounted<PromiseData> {
+ public:
+ PromiseData(v8::Isolate*, int promiseHash, v8::Handle<v8::Object> promise, v8::Handle<v8::Object> parentPromise, int status, bool captureStack = false);
+
+ int promiseHash() const { return m_promiseHash; }
+ ScopedPersistent<v8::Object>& promise() { return m_promise; }
+
+ private:
+ friend class PromiseTracker;
+
+ int m_promiseHash;
+
+ ScopedPersistent<v8::Object> m_promise;
+ ScriptCallFrame m_callFrame;
+ ScopedPersistent<v8::Object> m_parentPromise;
+ int m_status;
+
+ WeakPtrFactory<PromiseData> m_weakPtrFactory;
+ };
+
+ typedef Vector<RefPtr<PromiseData> > PromiseDataVector;
+ typedef HashMap<int, PromiseDataVector> PromiseDataMap;
+
+private:
+ bool m_isEnabled;
+ PromiseDataMap m_promiseDataMap;
+};
+
+} // namespace blink
+
+#endif // !defined(PromiseTracker_h)

Powered by Google App Engine
This is Rietveld 408576698