Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 if (LIKELY(m_wrapperOrTypeInfo.isWrapperTypeInfo() || m_wrapperOrTypeInfo.is V8Wrapper())) { | 69 if (LIKELY(m_wrapperOrTypeInfo.isWrapperTypeInfo() || m_wrapperOrTypeInfo.is V8Wrapper())) { |
| 70 DartWrapperInfo* wrapperInfo = new DartWrapperInfo; | 70 DartWrapperInfo* wrapperInfo = new DartWrapperInfo; |
| 71 wrapperInfo->v8WrapperOrTypeInfo = m_wrapperOrTypeInfo; | 71 wrapperInfo->v8WrapperOrTypeInfo = m_wrapperOrTypeInfo; |
| 72 wrapperInfo->domData = domData; | 72 wrapperInfo->domData = domData; |
| 73 wrapperInfo->wrapper = wrapper; | 73 wrapperInfo->wrapper = wrapper; |
| 74 m_wrapperOrTypeInfo = TaggedPointer(wrapperInfo); | 74 m_wrapperOrTypeInfo = TaggedPointer(wrapperInfo); |
| 75 } else if (m_wrapperOrTypeInfo.isDartWrapperInfo()) { | 75 } else if (m_wrapperOrTypeInfo.isDartWrapperInfo()) { |
| 76 DartWrapperInfo* wrapperInfo = m_wrapperOrTypeInfo.dartWrapperInfo(); | 76 DartWrapperInfo* wrapperInfo = m_wrapperOrTypeInfo.dartWrapperInfo(); |
| 77 if (wrapperInfo->domData == domData) { | 77 if (wrapperInfo->domData == domData) { |
| 78 // Replace the current wrapper (e.g., upgrading a custom element). | 78 // Replace the current wrapper (e.g., upgrading a custom element). |
| 79 wrapperInfo->wrapper = wrapper; | 79 wrapperInfo->wrapper = wrapper; |
|
rmacnak
2014/06/05 01:26:21
This seems to actually come from a path related to
| |
| 80 } else { | 80 } else { |
| 81 // Inflate to a multiwrapper, unimplemented. | 81 // Inflate to a multiwrapper, unimplemented. |
| 82 DartMultiWrapperInfo* multiWrapperInfo = new DartMultiWrapperInfo; | |
| 83 multiWrapperInfo->v8WrapperOrTypeInfo = wrapperInfo->v8WrapperOrType Info; | |
| 84 multiWrapperInfo->domDatas.append(wrapperInfo->domData); | |
| 85 multiWrapperInfo->wrappers.append(wrapperInfo->wrapper); | |
| 86 multiWrapperInfo->domDatas.append(domData); | |
| 87 multiWrapperInfo->wrappers.append(wrapper); | |
| 88 m_wrapperOrTypeInfo = TaggedPointer(multiWrapperInfo); | |
| 89 delete wrapperInfo; | |
| 82 } | 90 } |
| 83 } else { | 91 } else { |
| 84 ASSERT(m_wrapperOrTypeInfo.isDartMultiWrapperInfo()); | 92 ASSERT(m_wrapperOrTypeInfo.isDartMultiWrapperInfo()); |
| 85 // Replace or append wrapper, unimplemented. | 93 DartMultiWrapperInfo* wrapperInfo = m_wrapperOrTypeInfo.dartMultiWrapper Info(); |
| 86 ASSERT_NOT_REACHED(); | 94 size_t len = wrapperInfo->domDatas.size(); |
| 95 for (size_t i = 0; i < len; i++) { | |
| 96 if (wrapperInfo->domDatas.at(i) == domData) { | |
| 97 // Replace the current wrapper (e.g., upgrading a custom element ). | |
| 98 ASSERT_NOT_REACHED(); | |
|
rmacnak
2014/06/05 01:26:21
Don't seem to hit this path, even with the new tes
siva
2014/06/05 18:05:49
Pete might be able to help with a test case that w
| |
| 99 wrapperInfo->wrappers[i] = wrapper; | |
| 100 return; | |
| 101 } | |
| 102 } | |
| 103 // Append wrapper for new isolate. | |
| 104 wrapperInfo->domDatas.append(domData); | |
| 105 wrapperInfo->wrappers.append(wrapper); | |
| 87 } | 106 } |
| 88 } | 107 } |
| 89 | 108 |
| 90 void* ScriptWrappable::getDartWrapper(void* domData) const | 109 void* ScriptWrappable::getDartWrapper(void* domData) const |
| 91 { | 110 { |
| 92 ASSERT(domData); | 111 ASSERT(domData); |
| 93 if (m_wrapperOrTypeInfo.isDartWrapperInfo()) { | 112 if (m_wrapperOrTypeInfo.isDartWrapperInfo()) { |
| 94 DartWrapperInfo* wrapperInfo = m_wrapperOrTypeInfo.dartWrapperInfo(); | 113 DartWrapperInfo* wrapperInfo = m_wrapperOrTypeInfo.dartWrapperInfo(); |
| 95 if (wrapperInfo->domData == domData) { | 114 if (wrapperInfo->domData == domData) { |
| 96 return wrapperInfo->wrapper; | 115 return wrapperInfo->wrapper; |
| 97 } | 116 } |
| 98 return 0; | 117 return 0; |
| 99 } | 118 } |
| 100 if (m_wrapperOrTypeInfo.isDartMultiWrapperInfo()) { | 119 if (m_wrapperOrTypeInfo.isDartMultiWrapperInfo()) { |
| 101 DartMultiWrapperInfo* wrapperInfo = m_wrapperOrTypeInfo.dartMultiWrapper Info(); | 120 DartMultiWrapperInfo* wrapperInfo = m_wrapperOrTypeInfo.dartMultiWrapper Info(); |
| 102 for (unsigned i = 0; i < wrapperInfo->domDatas.size(); ++i) { | 121 size_t len = wrapperInfo->domDatas.size(); |
| 103 if (wrapperInfo->domDatas.at(i) == domData) { | 122 for (size_t i = 0; i < len; ++i) { |
| 104 return wrapperInfo->wrappers.at(i); | 123 if (wrapperInfo->domDatas[i] == domData) { |
| 124 return wrapperInfo->wrappers[i]; | |
| 105 } | 125 } |
| 106 } | 126 } |
| 107 return 0; | 127 return 0; |
| 108 } | 128 } |
| 109 ASSERT(m_wrapperOrTypeInfo.isWrapperTypeInfo() || m_wrapperOrTypeInfo.isV8Wr apper()); | 129 ASSERT(m_wrapperOrTypeInfo.isWrapperTypeInfo() || m_wrapperOrTypeInfo.isV8Wr apper()); |
| 110 return 0; | 130 return 0; |
| 111 } | 131 } |
| 112 | 132 |
| 113 void ScriptWrappable::clearDartWrapper(void* domData, void* wrapper) | 133 void ScriptWrappable::clearDartWrapper(void* domData, void* wrapper) |
| 114 { | 134 { |
| 115 if (LIKELY(m_wrapperOrTypeInfo.isDartWrapperInfo())) { | 135 if (LIKELY(m_wrapperOrTypeInfo.isDartWrapperInfo())) { |
| 116 DartWrapperInfo* wrapperInfo = m_wrapperOrTypeInfo.dartWrapperInfo(); | 136 DartWrapperInfo* wrapperInfo = m_wrapperOrTypeInfo.dartWrapperInfo(); |
| 117 // FIXMEDART: Replace conditional with assert when wrappers for multiple isolates are implemented. | 137 ASSERT(domData == wrapperInfo->domData); |
| 118 if (domData == wrapperInfo->domData) { | |
| 119 #ifdef DEBUG | 138 #ifdef DEBUG |
| 120 DartApiScope scope; | 139 DartApiScope scope; |
| 121 ASSERT(Dart_IdentityEquals((Dart_Handle)wrapper, (Dart_Handle)wrappe rInfo->wrapper)); | 140 ASSERT(Dart_IdentityEquals((Dart_Handle)wrapper, (Dart_Handle)wrapperInf o->wrapper)); |
| 122 #endif | 141 #endif |
| 123 m_wrapperOrTypeInfo = wrapperInfo->v8WrapperOrTypeInfo; | 142 m_wrapperOrTypeInfo = wrapperInfo->v8WrapperOrTypeInfo; |
| 124 delete wrapperInfo; | 143 delete wrapperInfo; |
| 144 } else if (m_wrapperOrTypeInfo.isDartMultiWrapperInfo()) { | |
| 145 // Remove. | |
| 146 DartMultiWrapperInfo* wrapperInfo = m_wrapperOrTypeInfo.dartMultiWrapper Info(); | |
| 147 size_t len = wrapperInfo->domDatas.size(); | |
| 148 for (size_t i = 0; i < len; i++) { | |
| 149 if (wrapperInfo->domDatas[i] == domData) { | |
| 150 #ifdef DEBUG | |
| 151 DartApiScope scope; | |
| 152 ASSERT(Dart_IdentityEquals((Dart_Handle)wrapper, (Dart_Handle)wr apperInfo->wrapper)); | |
| 153 #endif | |
| 154 wrapperInfo->domDatas.remove(i); | |
| 155 wrapperInfo->wrappers.remove(i); | |
|
siva
2014/06/05 18:05:49
Add a comment here and above too that when the las
| |
| 156 if (len == 1) { | |
| 157 m_wrapperOrTypeInfo = wrapperInfo->v8WrapperOrTypeInfo; | |
| 158 delete wrapperInfo; | |
| 159 } | |
| 160 return; | |
| 161 } | |
| 125 } | 162 } |
| 126 } else if (m_wrapperOrTypeInfo.isDartMultiWrapperInfo()) { | 163 // Could not find wrapper. |
| 127 // Remove or deflate, unimplemented. | |
| 128 ASSERT_NOT_REACHED(); | 164 ASSERT_NOT_REACHED(); |
| 129 } else { | 165 } else { |
| 130 // Already clear. | 166 // No Dart wrappers. |
| 131 // FIXMEDART: Uncomment assert when wrappers for multiple isolates are i mplemented. | 167 ASSERT_NOT_REACHED(); |
| 132 // ASSERT_NOT_REACHED(); | |
| 133 } | 168 } |
| 134 } | 169 } |
| 135 | 170 |
| 136 } // namespace WebCore | 171 } // namespace WebCore |
| 137 | 172 |
| 138 #endif // DartScriptWrappable_h | 173 #endif // DartScriptWrappable_h |
| OLD | NEW |