OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 } | 81 } |
82 | 82 |
83 void WebKitBlobBuilder::append(const String& text, ExceptionCode& ec) | 83 void WebKitBlobBuilder::append(const String& text, ExceptionCode& ec) |
84 { | 84 { |
85 append(text, String(), ec); | 85 append(text, String(), ec); |
86 } | 86 } |
87 | 87 |
88 #if ENABLE(BLOB) | 88 #if ENABLE(BLOB) |
89 void WebKitBlobBuilder::append(ArrayBuffer* arrayBuffer) | 89 void WebKitBlobBuilder::append(ArrayBuffer* arrayBuffer) |
90 { | 90 { |
| 91 if (!arrayBuffer) |
| 92 return; |
91 Vector<char>& buffer = getBuffer(); | 93 Vector<char>& buffer = getBuffer(); |
92 size_t oldSize = buffer.size(); | 94 size_t oldSize = buffer.size(); |
93 buffer.append(static_cast<const char*>(arrayBuffer->data()), arrayBuffer->by
teLength()); | 95 buffer.append(static_cast<const char*>(arrayBuffer->data()), arrayBuffer->by
teLength()); |
94 m_size += buffer.size() - oldSize; | 96 m_size += buffer.size() - oldSize; |
95 } | 97 } |
96 #endif | 98 #endif |
97 | 99 |
98 void WebKitBlobBuilder::append(Blob* blob) | 100 void WebKitBlobBuilder::append(Blob* blob) |
99 { | 101 { |
| 102 if (!blob) |
| 103 return; |
100 if (blob->isFile()) { | 104 if (blob->isFile()) { |
101 // If the blob is file that is not snapshoted, capture the snapshot now. | 105 // If the blob is file that is not snapshoted, capture the snapshot now. |
102 // FIXME: This involves synchronous file operation. We need to figure ou
t how to make it asynchronous. | 106 // FIXME: This involves synchronous file operation. We need to figure ou
t how to make it asynchronous. |
103 File* file = static_cast<File*>(blob); | 107 File* file = static_cast<File*>(blob); |
104 long long snapshotSize; | 108 long long snapshotSize; |
105 double snapshotModificationTime; | 109 double snapshotModificationTime; |
106 file->captureSnapshot(snapshotSize, snapshotModificationTime); | 110 file->captureSnapshot(snapshotSize, snapshotModificationTime); |
107 | 111 |
108 m_size += snapshotSize; | 112 m_size += snapshotSize; |
109 m_items.append(BlobDataItem(file->path(), 0, snapshotSize, snapshotModif
icationTime)); | 113 m_items.append(BlobDataItem(file->path(), 0, snapshotSize, snapshotModif
icationTime)); |
(...skipping 13 matching lines...) Expand all Loading... |
123 RefPtr<Blob> blob = Blob::create(blobData.release(), m_size); | 127 RefPtr<Blob> blob = Blob::create(blobData.release(), m_size); |
124 | 128 |
125 // After creating a blob from the current blob data, we do not need to keep
the data around any more. Instead, we only | 129 // After creating a blob from the current blob data, we do not need to keep
the data around any more. Instead, we only |
126 // need to keep a reference to the URL of the blob just created. | 130 // need to keep a reference to the URL of the blob just created. |
127 m_items.append(BlobDataItem(blob->url(), 0, m_size)); | 131 m_items.append(BlobDataItem(blob->url(), 0, m_size)); |
128 | 132 |
129 return blob; | 133 return blob; |
130 } | 134 } |
131 | 135 |
132 } // namespace WebCore | 136 } // namespace WebCore |
OLD | NEW |