OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 } | 94 } |
95 | 95 |
96 ASSERT(endings == "transparent" || endings == "native"); | 96 ASSERT(endings == "transparent" || endings == "native"); |
97 | 97 |
98 BlobBuilder blobBuilder; | 98 BlobBuilder blobBuilder; |
99 | 99 |
100 V8TRYCATCH_VOID(v8::Local<v8::Array>, blobParts, v8::Local<v8::Array>::Cast(
firstArg)); | 100 V8TRYCATCH_VOID(v8::Local<v8::Array>, blobParts, v8::Local<v8::Array>::Cast(
firstArg)); |
101 uint32_t length = blobParts->Length(); | 101 uint32_t length = blobParts->Length(); |
102 | 102 |
103 for (uint32_t i = 0; i < length; ++i) { | 103 for (uint32_t i = 0; i < length; ++i) { |
104 v8::Local<v8::Value> item = blobParts->Get(v8::Uint32::New(i)); | 104 v8::Local<v8::Value> item = blobParts->Get(v8::Uint32::New(i, args.GetIs
olate())); |
105 ASSERT(!item.IsEmpty()); | 105 ASSERT(!item.IsEmpty()); |
106 if (V8ArrayBuffer::HasInstance(item, args.GetIsolate(), worldType(args.G
etIsolate()))) { | 106 if (V8ArrayBuffer::HasInstance(item, args.GetIsolate(), worldType(args.G
etIsolate()))) { |
107 ArrayBuffer* arrayBuffer = V8ArrayBuffer::toNative(v8::Handle<v8::Ob
ject>::Cast(item)); | 107 ArrayBuffer* arrayBuffer = V8ArrayBuffer::toNative(v8::Handle<v8::Ob
ject>::Cast(item)); |
108 ASSERT(arrayBuffer); | 108 ASSERT(arrayBuffer); |
109 blobBuilder.append(arrayBuffer); | 109 blobBuilder.append(arrayBuffer); |
110 } else if (V8ArrayBufferView::HasInstance(item, args.GetIsolate(), world
Type(args.GetIsolate()))) { | 110 } else if (V8ArrayBufferView::HasInstance(item, args.GetIsolate(), world
Type(args.GetIsolate()))) { |
111 ArrayBufferView* arrayBufferView = V8ArrayBufferView::toNative(v8::H
andle<v8::Object>::Cast(item)); | 111 ArrayBufferView* arrayBufferView = V8ArrayBufferView::toNative(v8::H
andle<v8::Object>::Cast(item)); |
112 ASSERT(arrayBufferView); | 112 ASSERT(arrayBufferView); |
113 blobBuilder.append(arrayBufferView); | 113 blobBuilder.append(arrayBufferView); |
114 } else | 114 } else |
115 if (V8Blob::HasInstance(item, args.GetIsolate(), worldType(args.GetIsola
te()))) { | 115 if (V8Blob::HasInstance(item, args.GetIsolate(), worldType(args.GetIsola
te()))) { |
116 Blob* blob = V8Blob::toNative(v8::Handle<v8::Object>::Cast(item)); | 116 Blob* blob = V8Blob::toNative(v8::Handle<v8::Object>::Cast(item)); |
117 ASSERT(blob); | 117 ASSERT(blob); |
118 blobBuilder.append(blob); | 118 blobBuilder.append(blob); |
119 } else { | 119 } else { |
120 V8TRYCATCH_VOID(String, stringValue, toWebCoreString(item)); | 120 V8TRYCATCH_VOID(String, stringValue, toWebCoreString(item)); |
121 blobBuilder.append(stringValue, endings); | 121 blobBuilder.append(stringValue, endings); |
122 } | 122 } |
123 } | 123 } |
124 | 124 |
125 RefPtr<Blob> blob = blobBuilder.getBlob(type); | 125 RefPtr<Blob> blob = blobBuilder.getBlob(type); |
126 args.GetReturnValue().Set(toV8(blob.get(), args.Holder(), args.GetIsolate())
); | 126 args.GetReturnValue().Set(toV8(blob.get(), args.Holder(), args.GetIsolate())
); |
127 } | 127 } |
128 | 128 |
129 } // namespace WebCore | 129 } // namespace WebCore |
OLD | NEW |