Index: Source/core/inspector/PromiseOfficer.h |
diff --git a/Source/core/inspector/PromiseOfficer.h b/Source/core/inspector/PromiseOfficer.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4065ff31fdbc800c5f8aee254a4acc80ad281d98 |
--- /dev/null |
+++ b/Source/core/inspector/PromiseOfficer.h |
@@ -0,0 +1,147 @@ |
+/* |
+ * Copyright (C) 2014 Google Inc. All rights reserved. |
+ * |
+ * Redistribution and use in source and binary forms, with or without |
+ * modification, are permitted provided that the following conditions are |
+ * met: |
+ * |
+ * * Redistributions of source code must retain the above copyright |
+ * notice, this list of conditions and the following disclaimer. |
+ * * Redistributions in binary form must reproduce the above |
+ * copyright notice, this list of conditions and the following disclaimer |
+ * in the documentation and/or other materials provided with the |
+ * distribution. |
+ * * Neither the name of Google Inc. nor the names of its |
+ * contributors may be used to endorse or promote products derived from |
+ * this software without specific prior written permission. |
+ * |
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
+ */ |
+ |
+#ifndef PromiseOfficer_h |
+#define PromiseOfficer_h |
+ |
+#include <v8.h> |
+#include "bindings/v8/custom/V8PromiseCustom.h" |
+#include "bindings/v8/ScopedPersistent.h" |
+#include "bindings/v8/ScriptCallStackFactory.h" |
+#include "wtf/HashMap.h" |
+#include "wtf/Noncopyable.h" |
+#include "wtf/RefPtr.h" |
+#include "wtf/Vector.h" |
+ |
+namespace WebCore { |
+ |
+class ExecutionContext; |
+class ScriptCallStack; |
+ |
+class PromiseOfficer { |
+ WTF_MAKE_NONCOPYABLE(PromiseOfficer); |
+public: |
+ PromiseOfficer() |
+ : m_isEnabled(false) |
aandrey
2014/02/28 16:08:13
make all in one line:
PromiseOfficer() : m_isEnabl
Alexandra Mikhaylova
2014/03/03 14:04:25
Done.
|
+ { |
+ } |
+ |
+ bool isEnabled() const { return m_isEnabled; } |
+ void enable(); |
+ void disable(); |
+ |
+ void clear(); |
+ |
+ void didCreatePromise(ExecutionContext* context, v8::Handle<v8::Object> promise, v8::Handle<v8::Object> parentPromise, V8PromiseCustom::PromiseState state); |
aandrey
2014/02/28 16:08:13
nit: remove "state", leave just V8PromiseCustom::P
Alexandra Mikhaylova
2014/03/03 14:04:25
Done.
|
+ void didUpdatePromiseParent(v8::Handle<v8::Object> promise, v8::Handle<v8::Object> parentPromise); |
+ void didUpdatePromiseState(v8::Handle<v8::Object> promise, V8PromiseCustom::PromiseState state, v8::Handle<v8::Value> result); |
aandrey
2014/02/28 16:08:13
remove "state"
Alexandra Mikhaylova
2014/03/03 14:04:25
Done.
|
+ |
+private: |
+ class PromiseData { |
+ public: |
+ PromiseData(v8::Handle<v8::Object> promise, v8::Handle<v8::Object> parentPromise, v8::Handle<v8::Value> result, V8PromiseCustom::PromiseState state, double timestamp, v8::Isolate* isolate) |
aandrey
2014/02/28 16:08:13
move to cpp
Alexandra Mikhaylova
2014/03/03 14:04:25
Done.
|
+ : m_isolate(isolate) |
+ , m_promise(m_isolate, promise) |
+ , m_parentPromise(m_isolate, parentPromise) |
+ , m_result(m_isolate, result) |
+ , m_state(state) |
+ , m_timeOnCreate(timestamp) |
+ , m_timeOnSettle(-1) |
+ , m_callStackOnCreate(createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture, true)) |
+ , m_callStackOnSettle(RefPtr<ScriptCallStack>()) |
+ { |
+ } |
+ |
+ v8::Handle<v8::Object> getPromise() |
aandrey
2014/02/28 16:08:13
can you remove all these methods from the header f
Alexandra Mikhaylova
2014/03/03 14:04:25
Done.
|
+ { |
+ return m_promise.newLocal(m_isolate); |
+ } |
+ |
+ v8::Handle<v8::Object> getParentPromise() |
+ { |
+ return m_parentPromise.newLocal(m_isolate); |
+ } |
+ |
+ v8::Handle<v8::Value> getResult() |
+ { |
+ return m_result.newLocal(m_isolate); |
+ } |
+ |
+ V8PromiseCustom::PromiseState getState() |
+ { |
+ return m_state; |
+ } |
+ |
+ void setParentPromise(v8::Handle<v8::Object> parentPromise) |
+ { |
+ m_parentPromise.set(m_isolate, parentPromise); |
+ } |
+ |
+ void setResult(v8::Handle<v8::Value> result) |
+ { |
+ m_result.set(m_isolate, result); |
+ } |
+ |
+ void setState(V8PromiseCustom::PromiseState state) |
+ { |
+ m_state = state; |
+ } |
+ |
+ void didSettlePromise(double timestamp) |
+ { |
+ m_timeOnSettle = timestamp; |
+ m_callStackOnSettle = createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture, true); |
+ } |
+ |
+ private: |
+ v8::Isolate* m_isolate; |
+ |
+ ScopedPersistent<v8::Object> m_promise; |
+ ScopedPersistent<v8::Object> m_parentPromise; |
+ ScopedPersistent<v8::Value> m_result; |
+ V8PromiseCustom::PromiseState m_state; |
+ |
+ // Time in milliseconds. |
+ double m_timeOnCreate; |
+ double m_timeOnSettle; |
+ |
+ RefPtr<ScriptCallStack> m_callStackOnCreate; |
+ RefPtr<ScriptCallStack> m_callStackOnSettle; |
+ }; |
+ |
+ bool m_isEnabled; |
+ typedef Vector<PromiseData*> PromiseDataVector; |
aandrey
2014/02/28 16:08:13
why Vector<PromiseData*>?
I think Vector<PromiseDa
Alexandra Mikhaylova
2014/03/03 14:04:25
Vector::append copies its argument, so I think it'
|
+ typedef HashMap<int, PromiseDataVector> PromiseDataMap; |
+ PromiseDataMap m_promiseDataMap; |
+}; |
+ |
+} // namespace WebCore |
+ |
+#endif // !defined(PromiseOfficer_h) |