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

Side by Side Diff: Source/bindings/v8/ScriptPromise.h

Issue 26004002: Decouple ScriptPromise creation from ScriptPromiseResolver. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 7 years, 2 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
« no previous file with comments | « Source/bindings/bindings.gypi ('k') | Source/bindings/v8/ScriptPromise.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 20 matching lines...) Expand all
31 #ifndef ScriptPromise_h 31 #ifndef ScriptPromise_h
32 #define ScriptPromise_h 32 #define ScriptPromise_h
33 33
34 #include "bindings/v8/ScopedPersistent.h" 34 #include "bindings/v8/ScopedPersistent.h"
35 #include "bindings/v8/ScriptValue.h" 35 #include "bindings/v8/ScriptValue.h"
36 #include "bindings/v8/V8ScriptRunner.h" 36 #include "bindings/v8/V8ScriptRunner.h"
37 #include <v8.h> 37 #include <v8.h>
38 38
39 namespace WebCore { 39 namespace WebCore {
40 40
41 class ExecutionContext;
42
41 // ScriptPromise is the class for representing Promise values in C++ world. 43 // ScriptPromise is the class for representing Promise values in C++ world.
42 // ScriptPromise holds a Promise. 44 // ScriptPromise holds a Promise.
43 // So holding a ScriptPromise as a member variable in DOM object causes 45 // So holding a ScriptPromise as a member variable in DOM object causes
44 // memory leaks since it has a reference from C++ to V8. 46 // memory leaks since it has a reference from C++ to V8.
45 // 47 //
46 class ScriptPromise { 48 class ScriptPromise {
47 public: 49 public:
50 // Constructs an empty promise.
48 ScriptPromise() 51 ScriptPromise()
49 : m_promise() 52 : m_promise()
50 { 53 {
51 } 54 }
52 55
53 explicit ScriptPromise(const ScriptValue& promise) 56 explicit ScriptPromise(const ScriptValue& promise)
54 : m_promise(promise) 57 : m_promise(promise)
55 { 58 {
56 ASSERT(!m_promise.hasNoValue()); 59 ASSERT(!m_promise.hasNoValue());
57 } 60 }
(...skipping 27 matching lines...) Expand all
85 bool hasNoValue() const 88 bool hasNoValue() const
86 { 89 {
87 return m_promise.hasNoValue(); 90 return m_promise.hasNoValue();
88 } 91 }
89 92
90 void clear() 93 void clear()
91 { 94 {
92 m_promise.clear(); 95 m_promise.clear();
93 } 96 }
94 97
98 // Creates a pending promise.
abarth-chromium 2013/10/15 17:40:51 These comments aren't needed anymore. We can see
99 static ScriptPromise createPending();
100 // Creates a pending promise.
101 static ScriptPromise createPending(ExecutionContext*);
102
95 private: 103 private:
96 ScriptValue m_promise; 104 ScriptValue m_promise;
97 }; 105 };
98 106
99 } // namespace WebCore 107 } // namespace WebCore
100 108
101 109
102 #endif // ScriptPromise_h 110 #endif // ScriptPromise_h
OLDNEW
« no previous file with comments | « Source/bindings/bindings.gypi ('k') | Source/bindings/v8/ScriptPromise.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698