Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 return m_scriptState ? isolate()->GetCurrentContext() : v8::Local<v8::Co ntext>(); | |
|
haraken
2015/03/25 04:29:59
This seems wrong. We need to use m_scriptState->co
bashi
2015/03/25 04:56:00
Done.
| |
| 98 } | |
| 99 | |
| 87 ScriptValue& operator=(const ScriptValue& value) | 100 ScriptValue& operator=(const ScriptValue& value) |
| 88 { | 101 { |
| 89 if (this != &value) { | 102 if (this != &value) { |
| 90 m_scriptState = value.m_scriptState; | 103 m_scriptState = value.m_scriptState; |
| 91 m_value = value.m_value; | 104 m_value = value.m_value; |
| 92 } | 105 } |
| 93 return *this; | 106 return *this; |
| 94 } | 107 } |
| 95 | 108 |
| 96 bool operator==(const ScriptValue& value) const | 109 bool operator==(const ScriptValue& value) const |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 static ScriptValue createNull(ScriptState*); | 171 static ScriptValue createNull(ScriptState*); |
| 159 | 172 |
| 160 private: | 173 private: |
| 161 RefPtr<ScriptState> m_scriptState; | 174 RefPtr<ScriptState> m_scriptState; |
| 162 RefPtr<SharedPersistent<v8::Value>> m_value; | 175 RefPtr<SharedPersistent<v8::Value>> m_value; |
| 163 }; | 176 }; |
| 164 | 177 |
| 165 } // namespace blink | 178 } // namespace blink |
| 166 | 179 |
| 167 #endif // ScriptValue_h | 180 #endif // ScriptValue_h |
| OLD | NEW |