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

Side by Side Diff: third_party/WebKit/Source/wtf/Int8Array.h

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) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Google Inc. All rights reserved. 3 * Copyright (C) 2009 Google 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 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 17 matching lines...) Expand all
28 #define Int8Array_h 28 #define Int8Array_h
29 29
30 #include "wtf/IntegralTypedArrayBase.h" 30 #include "wtf/IntegralTypedArrayBase.h"
31 31
32 namespace WTF { 32 namespace WTF {
33 33
34 class ArrayBuffer; 34 class ArrayBuffer;
35 35
36 class Int8Array final : public IntegralTypedArrayBase<signed char> { 36 class Int8Array final : public IntegralTypedArrayBase<signed char> {
37 public: 37 public:
38 static inline PassRefPtr<Int8Array> create(unsigned length); 38 static inline PassRefPtr<Int8Array> createOrNull(unsigned length);
39 static inline PassRefPtr<Int8Array> create(const signed char* array, unsigne d length); 39 static inline PassRefPtr<Int8Array> createOrNull(const signed char* array, u nsigned length);
40 static inline PassRefPtr<Int8Array> deprecatedCreateOrCrash(const signed cha r* array, unsigned length);
40 static inline PassRefPtr<Int8Array> create(PassRefPtr<ArrayBuffer>, unsigned byteOffset, unsigned length); 41 static inline PassRefPtr<Int8Array> create(PassRefPtr<ArrayBuffer>, unsigned byteOffset, unsigned length);
41 42
42 using TypedArrayBase<signed char>::set; 43 using TypedArrayBase<signed char>::set;
43 using IntegralTypedArrayBase<signed char>::set; 44 using IntegralTypedArrayBase<signed char>::set;
44 45
45 ViewType type() const override 46 ViewType type() const override
46 { 47 {
47 return TypeInt8; 48 return TypeInt8;
48 } 49 }
49 50
50 private: 51 private:
51 inline Int8Array(PassRefPtr<ArrayBuffer>, unsigned byteOffset, unsigned leng th); 52 inline Int8Array(PassRefPtr<ArrayBuffer>, unsigned byteOffset, unsigned leng th);
52 // Make constructor visible to superclass. 53 // Make constructor visible to superclass.
53 friend class TypedArrayBase<signed char>; 54 friend class TypedArrayBase<signed char>;
54 }; 55 };
55 56
56 PassRefPtr<Int8Array> Int8Array::create(unsigned length) 57 PassRefPtr<Int8Array> Int8Array::createOrNull(unsigned length)
57 { 58 {
58 return TypedArrayBase<signed char>::create<Int8Array>(length); 59 return TypedArrayBase<signed char>::createOrNull<Int8Array>(length);
59 } 60 }
60 61
61 PassRefPtr<Int8Array> Int8Array::create(const signed char* array, unsigned lengt h) 62 PassRefPtr<Int8Array> Int8Array::createOrNull(const signed char* array, unsigned length)
62 { 63 {
63 return TypedArrayBase<signed char>::create<Int8Array>(array, length); 64 return TypedArrayBase<signed char>::createOrNull<Int8Array>(array, length);
65 }
66
67 PassRefPtr<Int8Array> Int8Array::deprecatedCreateOrCrash(const signed char* arra y, unsigned length)
68 {
69 return TypedArrayBase<signed char>::deprecatedCreateOrCrash<Int8Array>(array , length);
64 } 70 }
65 71
66 PassRefPtr<Int8Array> Int8Array::create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length) 72 PassRefPtr<Int8Array> Int8Array::create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
67 { 73 {
68 return TypedArrayBase<signed char>::create<Int8Array>(buffer, byteOffset, le ngth); 74 return TypedArrayBase<signed char>::create<Int8Array>(buffer, byteOffset, le ngth);
69 } 75 }
70 76
71 Int8Array::Int8Array(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsign ed length) 77 Int8Array::Int8Array(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsign ed length)
72 : IntegralTypedArrayBase<signed char>(buffer, byteOffset, length) 78 : IntegralTypedArrayBase<signed char>(buffer, byteOffset, length)
73 { 79 {
74 } 80 }
75 81
76 } // namespace WTF 82 } // namespace WTF
77 83
78 using WTF::Int8Array; 84 using WTF::Int8Array;
79 85
80 #endif // Int8Array_h 86 #endif // Int8Array_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/Int32Array.h ('k') | third_party/WebKit/Source/wtf/TypedArrayBase.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698