| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef V8BlobCustomHelpers_h | 31 #ifndef V8BlobCustomHelpers_h |
| 32 #define V8BlobCustomHelpers_h | 32 #define V8BlobCustomHelpers_h |
| 33 | 33 |
| 34 #include "bindings/v8/V8Binding.h" | 34 #include "bindings/v8/V8Binding.h" |
| 35 | 35 |
| 36 namespace WebCore { | 36 namespace WebCore { |
| 37 | 37 |
| 38 class BlobBuilder; | 38 class BlobBuilder; |
| 39 class ExceptionState; |
| 39 | 40 |
| 40 // Shared code between the custom constructor bindings for Blob and File. | 41 // Shared code between the custom constructor bindings for Blob and File. |
| 41 namespace V8BlobCustomHelpers { | 42 namespace V8BlobCustomHelpers { |
| 42 | 43 |
| 43 // Parsed properties from a BlobPropertyBag or a FilePropertyBag. | 44 // Parsed properties from a BlobPropertyBag or a FilePropertyBag. |
| 44 // | 45 // |
| 45 // Instances are stack-allocated by the File and Blob constructor. | 46 // Instances are stack-allocated by the File and Blob constructor. |
| 46 // | 47 // |
| 47 // parseBlobPropertyBag is only called when constructors receive a value for | 48 // parseBlobPropertyBag is only called when constructors receive a value for |
| 48 // the optional BlobPropertyBag / FilePropertyBag argument. The defaults set in | 49 // the optional BlobPropertyBag / FilePropertyBag argument. The defaults set in |
| 49 // the constructor are used otherwise. | 50 // the constructor are used otherwise. |
| 50 class ParsedProperties { | 51 class ParsedProperties { |
| 51 public: | 52 public: |
| 52 explicit ParsedProperties(bool hasFileProperties); | 53 explicit ParsedProperties(bool hasFileProperties); |
| 53 | 54 |
| 54 const String& contentType() const { return m_contentType; } | 55 const String& contentType() const { return m_contentType; } |
| 55 const String& endings() const { return m_endings; } | 56 const String& endings() const { return m_endings; } |
| 56 void setLastModified(double); | 57 void setLastModified(double); |
| 57 void setDefaultLastModified(); | 58 void setDefaultLastModified(); |
| 58 double lastModified() const | 59 double lastModified() const |
| 59 { | 60 { |
| 60 ASSERT(m_hasFileProperties); | 61 ASSERT(m_hasFileProperties); |
| 61 ASSERT(m_hasLastModified); | 62 ASSERT(m_hasLastModified); |
| 62 return m_lastModified; | 63 return m_lastModified; |
| 63 } | 64 } |
| 64 | 65 |
| 65 // Extracts the "type" and "endings" properties out of the BlobPropertyBag p
assed to a Blob constructor. | 66 // Extracts the "type" and "endings" properties out of the BlobPropertyBag p
assed to a Blob constructor. |
| 66 // http://www.w3.org/TR/FileAPI/#constructorParams | 67 // http://www.w3.org/TR/FileAPI/#constructorParams |
| 67 // Returns true if everything went well, false if a JS exception was thrown. | 68 // Returns true if everything went well, false if a JS exception was thrown. |
| 68 bool parseBlobPropertyBag(v8::Local<v8::Value> propertyBag, const char* blob
ClassName, v8::Isolate*); | 69 bool parseBlobPropertyBag(v8::Local<v8::Value> propertyBag, const char* blob
ClassName, ExceptionState&, v8::Isolate*); |
| 69 | 70 |
| 70 private: | 71 private: |
| 71 String m_contentType; | 72 String m_contentType; |
| 72 String m_endings; | 73 String m_endings; |
| 73 | 74 |
| 74 // False if this contains the properties of a BlobPropertyBag. | 75 // False if this contains the properties of a BlobPropertyBag. |
| 75 bool m_hasFileProperties; | 76 bool m_hasFileProperties; |
| 76 | 77 |
| 77 double m_lastModified; | 78 double m_lastModified; |
| 78 #ifndef NDEBUG | 79 #ifndef NDEBUG |
| 79 bool m_hasLastModified; | 80 bool m_hasLastModified; |
| 80 #endif // NDEBUG | 81 #endif // NDEBUG |
| 81 }; | 82 }; |
| 82 | 83 |
| 83 // Appends the blobParts passed to a Blob or File constructor into a BlobBuilder
. | 84 // Appends the blobParts passed to a Blob or File constructor into a BlobBuilder
. |
| 84 // http://www.w3.org/TR/FileAPI/#constructorParams | 85 // http://www.w3.org/TR/FileAPI/#constructorParams |
| 85 // Returns true if everything went well, false if a JS exception was thrown. | 86 // Returns true if everything went well, false if a JS exception was thrown. |
| 86 bool processBlobParts(v8::Local<v8::Object> blobParts, uint32_t blobPartsLength,
const String& endings, BlobBuilder&, v8::Isolate*); | 87 bool processBlobParts(v8::Local<v8::Object> blobParts, uint32_t blobPartsLength,
const String& endings, BlobBuilder&, v8::Isolate*); |
| 87 | 88 |
| 88 } // namespace V8BlobCustomHelpers | 89 } // namespace V8BlobCustomHelpers |
| 89 | 90 |
| 90 } // namespace WebCore | 91 } // namespace WebCore |
| 91 | 92 |
| 92 #endif // V8BlobCustomHelpers_h | 93 #endif // V8BlobCustomHelpers_h |
| OLD | NEW |