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

Side by Side Diff: Source/core/inspector/PromiseOfficer.h

Issue 177773002: Support Promises instrumentation on backend. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix in printing NULL parent promises Created 6 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #ifndef PromiseOfficer_h
32 #define PromiseOfficer_h
33
34 #include <v8.h>
35 #include "bindings/v8/custom/V8PromiseCustom.h"
36 #include "bindings/v8/ScopedPersistent.h"
37 #include "bindings/v8/V8Binding.h" // toIsolate
38 #include "core/dom/ExecutionContext.h"
39 #include "wtf/HashMap.h"
40 #include "wtf/Noncopyable.h"
41 #include "wtf/RefPtr.h"
42 #include "wtf/Vector.h"
43
44 namespace WebCore {
45
46 class PromiseOfficer {
47 WTF_MAKE_NONCOPYABLE(PromiseOfficer);
48 public:
49 // TODO: maybe move the implementation of this class to .cpp?
50 class PromiseData : public RefCounted<PromiseData> {
51 public:
52 PromiseData(v8::Handle<v8::Object> promise, v8::Handle<v8::Object> paren tPromise, V8PromiseCustom::PromiseState state, ExecutionContext* context)
53 : m_isolate(toIsolate(context))
54 , m_promise(m_isolate, promise)
55 , m_parentPromise(m_isolate, parentPromise)
56 , m_state(state)
57 { }
58
59 v8::Handle<v8::Object> getPromise() {
60 return m_promise.newLocal(m_isolate);
61 }
62
63 v8::Handle<v8::Object> getParentPromise() {
64 return m_parentPromise.newLocal(m_isolate);
65 }
66
67 V8PromiseCustom::PromiseState getState() {
68 return m_state;
69 }
70
71 private:
72 v8::Isolate* m_isolate;
73 ScopedPersistent<v8::Object> m_promise;
74 ScopedPersistent<v8::Object> m_parentPromise;
75 V8PromiseCustom::PromiseState m_state;
76 // TODO: add m_value and maybe m_scriptLocation.
77 };
78
79 PromiseOfficer();
80
81 void addPromise(ExecutionContext* context, v8::Handle<v8::Object> promise, v 8::Handle<v8::Object> parentPromise, V8PromiseCustom::PromiseState state);
82 void updatePromise(ExecutionContext* context, v8::Handle<v8::Object> promise , v8::Handle<v8::Object> newParentPromise, V8PromiseCustom::PromiseState newStat e);
83 void updatePromiseParent(ExecutionContext* context, v8::Handle<v8::Object> p romise, v8::Handle<v8::Object> newParentPromise);
84 void updatePromiseState(ExecutionContext* context, v8::Handle<v8::Object> pr omise, V8PromiseCustom::PromiseState newState);
85
86 private:
87 typedef Vector<RefPtr<PromiseData> > PromiseDataVector;
88 typedef HashMap<int, PromiseDataVector> PromiseDataMap;
89 PromiseDataMap m_promiseDataMap;
90 };
91
92 } // namespace WebCore
93
94 #endif // !defined(PromiseOfficer_h)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698