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

Side by Side Diff: third_party/WebKit/Source/core/testing/Internals.cpp

Issue 1414553002: Fix out-of-memory crashes related to ArrayBuffer allocation Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase+more tweaks Created 5 years, 1 month 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2013 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 2109 matching lines...) Expand 10 before | Expand all | Expand 10 after
2120 } 2120 }
2121 2121
2122 return result.toString(); 2122 return result.toString();
2123 } 2123 }
2124 2124
2125 bool Internals::cursorUpdatePending() const 2125 bool Internals::cursorUpdatePending() const
2126 { 2126 {
2127 return frame()->eventHandler().cursorUpdatePending(); 2127 return frame()->eventHandler().cursorUpdatePending();
2128 } 2128 }
2129 2129
2130 void Internals::fakeOutOfMemoryForNextArrayBufferAllocation() const
2131 {
2132 WTF::ArrayBufferContents::fakeOutOfMemoryForNextArrayBufferAllocationForTest ing();
2133 }
2134
2130 PassRefPtr<DOMArrayBuffer> Internals::serializeObject(PassRefPtr<SerializedScrip tValue> value) const 2135 PassRefPtr<DOMArrayBuffer> Internals::serializeObject(PassRefPtr<SerializedScrip tValue> value) const
2131 { 2136 {
2132 String stringValue = value->toWireString(); 2137 String stringValue = value->toWireString();
2133 RefPtr<DOMArrayBuffer> buffer = DOMArrayBuffer::createUninitialized(stringVa lue.length(), sizeof(UChar)); 2138 RefPtr<DOMArrayBuffer> buffer = DOMArrayBuffer::createUninitializedOrNull(st ringValue.length(), sizeof(UChar));
2139 RELEASE_ASSERT(buffer); // Crash here means out of memory.
2134 stringValue.copyTo(static_cast<UChar*>(buffer->data()), 0, stringValue.lengt h()); 2140 stringValue.copyTo(static_cast<UChar*>(buffer->data()), 0, stringValue.lengt h());
2135 return buffer.release(); 2141 return buffer.release();
2136 } 2142 }
2137 2143
2138 PassRefPtr<SerializedScriptValue> Internals::deserializeBuffer(PassRefPtr<DOMArr ayBuffer> buffer) const 2144 PassRefPtr<SerializedScriptValue> Internals::deserializeBuffer(PassRefPtr<DOMArr ayBuffer> buffer) const
2139 { 2145 {
2140 String value(static_cast<const UChar*>(buffer->data()), buffer->byteLength() / sizeof(UChar)); 2146 String value(static_cast<const UChar*>(buffer->data()), buffer->byteLength() / sizeof(UChar));
2141 return SerializedScriptValueFactory::instance().createFromWire(value); 2147 return SerializedScriptValueFactory::instance().createFromWire(value);
2142 } 2148 }
2143 2149
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
2563 2569
2564 void Internals::setMediaElementNetworkState(HTMLMediaElement* mediaElement, int state) 2570 void Internals::setMediaElementNetworkState(HTMLMediaElement* mediaElement, int state)
2565 { 2571 {
2566 ASSERT(mediaElement); 2572 ASSERT(mediaElement);
2567 ASSERT(state >= HTMLMediaElement::NetworkState::NETWORK_EMPTY); 2573 ASSERT(state >= HTMLMediaElement::NetworkState::NETWORK_EMPTY);
2568 ASSERT(state <= HTMLMediaElement::NetworkState::NETWORK_NO_SOURCE); 2574 ASSERT(state <= HTMLMediaElement::NetworkState::NETWORK_NO_SOURCE);
2569 mediaElement->setNetworkState(static_cast<WebMediaPlayer::NetworkState>(stat e)); 2575 mediaElement->setNetworkState(static_cast<WebMediaPlayer::NetworkState>(stat e));
2570 } 2576 }
2571 2577
2572 } // namespace blink 2578 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/testing/Internals.h ('k') | third_party/WebKit/Source/core/testing/Internals.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698