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

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 and applied senorblanco+haraken feedbac 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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
2555 Document* document = contextDocument(); 2561 Document* document = contextDocument();
2556 if (!document) { 2562 if (!document) {
2557 exceptionState.throwDOMException(InvalidAccessError, "No context documen t is available."); 2563 exceptionState.throwDOMException(InvalidAccessError, "No context documen t is available.");
2558 return 0; 2564 return 0;
2559 } 2565 }
2560 2566
2561 return document->loader()->timing().monotonicTimeToZeroBasedDocumentTime(pla tformTime); 2567 return document->loader()->timing().monotonicTimeToZeroBasedDocumentTime(pla tformTime);
2562 } 2568 }
2563 2569
2564 } // namespace blink 2570 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698