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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/SerializedScriptValue.cpp

Issue 2684593006: Remove ScriptValueSerializer::serializeNullValue. (Closed)
Patch Set: Created 3 years, 10 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) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 // likely used in a context other than Worker's onmessage environment and the 125 // likely used in a context other than Worker's onmessage environment and the
126 // presence of current v8 context is not guaranteed. Avoid calling v8 then. 126 // presence of current v8 context is not guaranteed. Avoid calling v8 then.
127 if (m_externallyAllocatedMemory) { 127 if (m_externallyAllocatedMemory) {
128 ASSERT(v8::Isolate::GetCurrent()); 128 ASSERT(v8::Isolate::GetCurrent());
129 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory( 129 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(
130 -m_externallyAllocatedMemory); 130 -m_externallyAllocatedMemory);
131 } 131 }
132 } 132 }
133 133
134 PassRefPtr<SerializedScriptValue> SerializedScriptValue::nullValue() { 134 PassRefPtr<SerializedScriptValue> SerializedScriptValue::nullValue() {
135 return create(ScriptValueSerializer::serializeNullValue()); 135 // UChar rather than uint8_t here to get host endian behavior.
136 static const UChar kNullData[] = {0xff09, 0x3000};
137 return create(reinterpret_cast<const char*>(kNullData), sizeof(kNullData));
136 } 138 }
137 139
138 String SerializedScriptValue::toWireString() const { 140 String SerializedScriptValue::toWireString() const {
139 if (!m_dataString.isNull()) 141 if (!m_dataString.isNull())
140 return m_dataString; 142 return m_dataString;
141 143
142 // Add the padding '\0', but don't put it in |m_dataBuffer|. 144 // Add the padding '\0', but don't put it in |m_dataBuffer|.
143 // This requires direct use of uninitialized strings, though. 145 // This requires direct use of uninitialized strings, though.
144 UChar* destination; 146 UChar* destination;
145 size_t stringSizeBytes = (m_dataBufferSize + 1) & ~1; 147 size_t stringSizeBytes = (m_dataBufferSize + 1) & ~1;
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 void SerializedScriptValue::registerMemoryAllocatedWithCurrentScriptContext() { 467 void SerializedScriptValue::registerMemoryAllocatedWithCurrentScriptContext() {
466 if (m_externallyAllocatedMemory) 468 if (m_externallyAllocatedMemory)
467 return; 469 return;
468 470
469 m_externallyAllocatedMemory = static_cast<intptr_t>(dataLengthInBytes()); 471 m_externallyAllocatedMemory = static_cast<intptr_t>(dataLengthInBytes());
470 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory( 472 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(
471 m_externallyAllocatedMemory); 473 m_externallyAllocatedMemory);
472 } 474 }
473 475
474 } // namespace blink 476 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698