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

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

Issue 1035623002: bindings: Use Maybe APIs in ScriptPromise (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 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
1 /* 1 /*
2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2008, 2009 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 ScriptValue() { } 61 ScriptValue() { }
62 62
63 ScriptValue(ScriptState* scriptState, v8::Handle<v8::Value> value) 63 ScriptValue(ScriptState* scriptState, v8::Handle<v8::Value> value)
64 : m_scriptState(scriptState) 64 : m_scriptState(scriptState)
65 , m_value(value.IsEmpty() ? nullptr : SharedPersistent<v8::Value>::creat e(value, scriptState->isolate())) 65 , m_value(value.IsEmpty() ? nullptr : SharedPersistent<v8::Value>::creat e(value, scriptState->isolate()))
66 { 66 {
67 ASSERT(isEmpty() || m_scriptState); 67 ASSERT(isEmpty() || m_scriptState);
68 } 68 }
69 69
70 template <typename T>
71 ScriptValue(ScriptState* scriptState, v8::MaybeLocal<T> value)
72 : m_scriptState(scriptState)
73 , m_value(value.IsEmpty() ? nullptr : SharedPersistent<v8::Value>::creat e(value.ToLocalChecked(), scriptState->isolate()))
74 {
75 ASSERT(isEmpty() || m_scriptState);
76 }
77
70 ScriptValue(const ScriptValue& value) 78 ScriptValue(const ScriptValue& value)
71 : m_scriptState(value.m_scriptState) 79 : m_scriptState(value.m_scriptState)
72 , m_value(value.m_value) 80 , m_value(value.m_value)
73 { 81 {
74 ASSERT(isEmpty() || m_scriptState); 82 ASSERT(isEmpty() || m_scriptState);
75 } 83 }
76 84
77 ScriptState* scriptState() const 85 ScriptState* scriptState() const
78 { 86 {
79 return m_scriptState.get(); 87 return m_scriptState.get();
80 } 88 }
81 89
82 v8::Isolate* isolate() const 90 v8::Isolate* isolate() const
83 { 91 {
84 return m_scriptState ? m_scriptState->isolate() : v8::Isolate::GetCurren t(); 92 return m_scriptState ? m_scriptState->isolate() : v8::Isolate::GetCurren t();
85 } 93 }
86 94
95 v8::Local<v8::Context> context() const
96 {
97 ASSERT(m_scriptState.get());
98 return m_scriptState->context();
99 }
100
87 ScriptValue& operator=(const ScriptValue& value) 101 ScriptValue& operator=(const ScriptValue& value)
88 { 102 {
89 if (this != &value) { 103 if (this != &value) {
90 m_scriptState = value.m_scriptState; 104 m_scriptState = value.m_scriptState;
91 m_value = value.m_value; 105 m_value = value.m_value;
92 } 106 }
93 return *this; 107 return *this;
94 } 108 }
95 109
96 bool operator==(const ScriptValue& value) const 110 bool operator==(const ScriptValue& value) const
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 static ScriptValue createNull(ScriptState*); 172 static ScriptValue createNull(ScriptState*);
159 173
160 private: 174 private:
161 RefPtr<ScriptState> m_scriptState; 175 RefPtr<ScriptState> m_scriptState;
162 RefPtr<SharedPersistent<v8::Value>> m_value; 176 RefPtr<SharedPersistent<v8::Value>> m_value;
163 }; 177 };
164 178
165 } // namespace blink 179 } // namespace blink
166 180
167 #endif // ScriptValue_h 181 #endif // ScriptValue_h
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/ScriptPromisePropertyBase.cpp ('k') | Source/bindings/templates/methods.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698