| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 if (info[0]->IsArray()) { | 48 if (info[0]->IsArray()) { |
| 49 length = v8::Local<v8::Array>::Cast(info[0])->Length(); | 49 length = v8::Local<v8::Array>::Cast(info[0])->Length(); |
| 50 } else { | 50 } else { |
| 51 const int sequenceArgumentIndex = 0; | 51 const int sequenceArgumentIndex = 0; |
| 52 if (toV8Sequence(info[sequenceArgumentIndex], length, info.GetIsolate())
.IsEmpty()) { | 52 if (toV8Sequence(info[sequenceArgumentIndex], length, info.GetIsolate())
.IsEmpty()) { |
| 53 throwTypeError(ExceptionMessages::failedToConstruct("Blob", Exceptio
nMessages::notAnArrayTypeArgumentOrValue(sequenceArgumentIndex + 1)), info.GetIs
olate()); | 53 throwTypeError(ExceptionMessages::failedToConstruct("Blob", Exceptio
nMessages::notAnArrayTypeArgumentOrValue(sequenceArgumentIndex + 1)), info.GetIs
olate()); |
| 54 return; | 54 return; |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 | 57 |
| 58 String contentType; | 58 V8BlobCustomHelpers::ParsedProperties properties(false); |
| 59 String endings = "transparent"; // default if no BlobPropertyBag is passed | |
| 60 if (info.Length() > 1) { | 59 if (info.Length() > 1) { |
| 61 if (!info[1]->IsObject()) { | 60 if (!info[1]->IsObject()) { |
| 62 throwTypeError(ExceptionMessages::failedToConstruct("Blob", "The 2nd
argument is not of type Object."), info.GetIsolate()); | 61 throwTypeError(ExceptionMessages::failedToConstruct("Blob", "The 2nd
argument is not of type Object."), info.GetIsolate()); |
| 63 return; | 62 return; |
| 64 } | 63 } |
| 65 | 64 |
| 66 if (!V8BlobCustomHelpers::processBlobPropertyBag(info[1], "Blob", conten
tType, endings, info.GetIsolate())) | 65 if (!V8BlobCustomHelpers::processBlobPropertyBag(info[1], "Blob", proper
ties, info.GetIsolate())) |
| 67 return; | 66 return; |
| 68 } | 67 } |
| 69 | 68 |
| 70 BlobBuilder blobBuilder; | 69 BlobBuilder blobBuilder; |
| 71 v8::Local<v8::Object> blobParts = v8::Local<v8::Object>::Cast(info[0]); | 70 v8::Local<v8::Object> blobParts = v8::Local<v8::Object>::Cast(info[0]); |
| 72 if (!V8BlobCustomHelpers::processBlobParts(blobParts, length, endings, blobB
uilder, info.GetIsolate())) | 71 if (!V8BlobCustomHelpers::processBlobParts(blobParts, length, properties.end
ings, blobBuilder, info.GetIsolate())) |
| 73 return; | 72 return; |
| 74 | 73 |
| 75 RefPtr<Blob> blob = blobBuilder.createBlob(contentType); | 74 RefPtr<Blob> blob = blobBuilder.createBlob(properties.contentType); |
| 76 v8SetReturnValue(info, blob.release()); | 75 v8SetReturnValue(info, blob.release()); |
| 77 } | 76 } |
| 78 | 77 |
| 79 } // namespace WebCore | 78 } // namespace WebCore |
| OLD | NEW |