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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 98 |
99 OwnPtr<BlobData> blobData = BlobData::create(); | 99 OwnPtr<BlobData> blobData = BlobData::create(); |
100 blobData->setContentType(options.type().lower()); | 100 blobData->setContentType(options.type().lower()); |
101 | 101 |
102 populateBlobData(blobData.get(), blobParts, normalizeLineEndingsToNative); | 102 populateBlobData(blobData.get(), blobParts, normalizeLineEndingsToNative); |
103 | 103 |
104 long long blobSize = blobData->length(); | 104 long long blobSize = blobData->length(); |
105 return new Blob(BlobDataHandle::create(blobData.release(), blobSize)); | 105 return new Blob(BlobDataHandle::create(blobData.release(), blobSize)); |
106 } | 106 } |
107 | 107 |
| 108 Blob* Blob::create(const unsigned char* data, size_t bytes, const String& conten
tType) |
| 109 { |
| 110 ASSERT(data); |
| 111 |
| 112 OwnPtr<BlobData> blobData = BlobData::create(); |
| 113 blobData->setContentType(contentType); |
| 114 blobData->appendBytes(data, bytes); |
| 115 long long blobSize = blobData->length(); |
| 116 |
| 117 return new Blob(BlobDataHandle::create(blobData.release(), blobSize)); |
| 118 } |
| 119 |
108 void Blob::clampSliceOffsets(long long size, long long& start, long long& end) | 120 void Blob::clampSliceOffsets(long long size, long long& start, long long& end) |
109 { | 121 { |
110 ASSERT(size != -1); | 122 ASSERT(size != -1); |
111 | 123 |
112 // Convert the negative value that is used to select from the end. | 124 // Convert the negative value that is used to select from the end. |
113 if (start < 0) | 125 if (start < 0) |
114 start = start + size; | 126 start = start + size; |
115 if (end < 0) | 127 if (end < 0) |
116 end = end + size; | 128 end = end + size; |
117 | 129 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 { | 185 { |
174 blobData.appendBlob(m_blobDataHandle, 0, m_blobDataHandle->size()); | 186 blobData.appendBlob(m_blobDataHandle, 0, m_blobDataHandle->size()); |
175 } | 187 } |
176 | 188 |
177 URLRegistry& Blob::registry() const | 189 URLRegistry& Blob::registry() const |
178 { | 190 { |
179 return BlobURLRegistry::registry(); | 191 return BlobURLRegistry::registry(); |
180 } | 192 } |
181 | 193 |
182 } // namespace blink | 194 } // namespace blink |
OLD | NEW |