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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 { | 57 { |
| 58 return NativeValueTraits<T>::nativeValue(isolate, value.v8Value(), excep tionState, arguments...); | 58 return NativeValueTraits<T>::nativeValue(isolate, value.v8Value(), excep tionState, arguments...); |
| 59 } | 59 } |
| 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); |
|
haraken
2015/03/25 05:08:29
I'm just wondering but is it valid that m_scriptSt
bashi
2015/03/25 07:25:32
You mean we should just ASSERT(m_scriptState)? I t
bashi
2015/03/25 07:35:01
It seems that some tests fail when dropping isEmpt
haraken
2015/03/25 09:04:23
Thanks for the investigation. Yeah, if the value i
| |
| 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); | |
|
haraken
2015/03/25 05:08:29
Ditto.
| |
| 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 Loading... | |
| 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 |
| OLD | NEW |