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

Side by Side Diff: Source/bindings/v8/custom/V8BlobCustom.cpp

Issue 111373003: Migrate bindings constructors to the new ExceptionState model. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Ugh. Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « Source/bindings/v8/Dictionary.cpp ('k') | Source/bindings/v8/custom/V8BlobCustomHelpers.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "V8Blob.h" 32 #include "V8Blob.h"
33 33
34 #include "bindings/v8/ExceptionState.h"
34 #include "bindings/v8/custom/V8BlobCustomHelpers.h" 35 #include "bindings/v8/custom/V8BlobCustomHelpers.h"
35 #include "core/fileapi/BlobBuilder.h" 36 #include "core/fileapi/BlobBuilder.h"
36 37
37 namespace WebCore { 38 namespace WebCore {
38 39
39 void V8Blob::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& info) 40 void V8Blob::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
40 { 41 {
42 ExceptionState exceptionState(ExceptionState::ConstructionContext, "Blob", i nfo.Holder(), info.GetIsolate());
41 if (!info.Length()) { 43 if (!info.Length()) {
42 RefPtr<Blob> blob = Blob::create(); 44 RefPtr<Blob> blob = Blob::create();
43 v8SetReturnValue(info, blob.release()); 45 v8SetReturnValue(info, blob.release());
44 return; 46 return;
45 } 47 }
46 48
47 uint32_t length = 0; 49 uint32_t length = 0;
48 if (info[0]->IsArray()) { 50 if (info[0]->IsArray()) {
49 length = v8::Local<v8::Array>::Cast(info[0])->Length(); 51 length = v8::Local<v8::Array>::Cast(info[0])->Length();
50 } else { 52 } else {
51 const int sequenceArgumentIndex = 0; 53 const int sequenceArgumentIndex = 0;
52 if (toV8Sequence(info[sequenceArgumentIndex], length, info.GetIsolate()) .IsEmpty()) { 54 if (toV8Sequence(info[sequenceArgumentIndex], length, info.GetIsolate()) .IsEmpty()) {
53 throwTypeError(ExceptionMessages::failedToConstruct("Blob", Exceptio nMessages::notAnArrayTypeArgumentOrValue(sequenceArgumentIndex + 1)), info.GetIs olate()); 55 exceptionState.throwTypeError(ExceptionMessages::notAnArrayTypeArgum entOrValue(sequenceArgumentIndex + 1));
56 exceptionState.throwIfNeeded();
54 return; 57 return;
55 } 58 }
56 } 59 }
57 60
58 V8BlobCustomHelpers::ParsedProperties properties(false); 61 V8BlobCustomHelpers::ParsedProperties properties(false);
59 if (info.Length() > 1) { 62 if (info.Length() > 1) {
60 if (!info[1]->IsObject()) { 63 if (!info[1]->IsObject()) {
61 throwTypeError(ExceptionMessages::failedToConstruct("Blob", "The 2nd argument is not of type Object."), info.GetIsolate()); 64 exceptionState.throwTypeError("The 2nd argument is not of type Objec t.");
65 exceptionState.throwIfNeeded();
62 return; 66 return;
63 } 67 }
64 68
65 if (!properties.parseBlobPropertyBag(info[1], "Blob", info.GetIsolate()) ) 69 if (!properties.parseBlobPropertyBag(info[1], "Blob", exceptionState, in fo.GetIsolate())) {
70 exceptionState.throwIfNeeded();
66 return; 71 return;
72 }
67 } 73 }
68 74
69 BlobBuilder blobBuilder; 75 BlobBuilder blobBuilder;
70 v8::Local<v8::Object> blobParts = v8::Local<v8::Object>::Cast(info[0]); 76 v8::Local<v8::Object> blobParts = v8::Local<v8::Object>::Cast(info[0]);
71 if (!V8BlobCustomHelpers::processBlobParts(blobParts, length, properties.end ings(), blobBuilder, info.GetIsolate())) 77 if (!V8BlobCustomHelpers::processBlobParts(blobParts, length, properties.end ings(), blobBuilder, info.GetIsolate()))
72 return; 78 return;
73 79
74 RefPtr<Blob> blob = blobBuilder.createBlob(properties.contentType()); 80 RefPtr<Blob> blob = blobBuilder.createBlob(properties.contentType());
75 v8SetReturnValue(info, blob.release()); 81 v8SetReturnValue(info, blob.release());
76 } 82 }
77 83
78 } // namespace WebCore 84 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/Dictionary.cpp ('k') | Source/bindings/v8/custom/V8BlobCustomHelpers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698