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

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

Issue 361863003: Add a helper for implementing Promise-valued properties. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: More feedback. Keeping separate header file for now. Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/bindings/core/v8/ScriptPromiseProperties.h » ('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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 bool isEmpty() const 86 bool isEmpty() const
87 { 87 {
88 return m_promise.isEmpty(); 88 return m_promise.isEmpty();
89 } 89 }
90 90
91 void clear() 91 void clear()
92 { 92 {
93 m_promise.clear(); 93 m_promise.clear();
94 } 94 }
95 95
96 bool operator==(const ScriptPromise& value) const
97 {
98 return m_promise == value.m_promise;
99 }
100
101 bool operator!=(const ScriptPromise& value) const
102 {
103 return !operator==(value);
104 }
105
96 // Constructs and returns a ScriptPromise from |value|. 106 // Constructs and returns a ScriptPromise from |value|.
97 // if |value| is not a Promise object, returns a Promise object 107 // if |value| is not a Promise object, returns a Promise object
98 // resolved with |value|. 108 // resolved with |value|.
99 // Returns |value| itself if it is a Promise. 109 // Returns |value| itself if it is a Promise.
100 static ScriptPromise cast(ScriptState*, const ScriptValue& /*value*/); 110 static ScriptPromise cast(ScriptState*, const ScriptValue& /*value*/);
101 static ScriptPromise cast(ScriptState*, v8::Handle<v8::Value> /*value*/); 111 static ScriptPromise cast(ScriptState*, v8::Handle<v8::Value> /*value*/);
102 112
103 static ScriptPromise reject(ScriptState*, const ScriptValue&); 113 static ScriptPromise reject(ScriptState*, const ScriptValue&);
104 static ScriptPromise reject(ScriptState*, v8::Handle<v8::Value>); 114 static ScriptPromise reject(ScriptState*, v8::Handle<v8::Value>);
105 115
(...skipping 16 matching lines...) Expand all
122 132
123 private: 133 private:
124 RefPtr<ScriptState> m_scriptState; 134 RefPtr<ScriptState> m_scriptState;
125 ScriptValue m_promise; 135 ScriptValue m_promise;
126 }; 136 };
127 137
128 } // namespace WebCore 138 } // namespace WebCore
129 139
130 140
131 #endif // ScriptPromise_h 141 #endif // ScriptPromise_h
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/core/v8/ScriptPromiseProperties.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698