Chromium Code Reviews| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 // using BlobURL::getOrigin(). | 52 // using BlobURL::getOrigin(). |
| 53 void RegisterURL(SecurityOrigin*, const KURL&, URLRegistrable*) override; | 53 void RegisterURL(SecurityOrigin*, const KURL&, URLRegistrable*) override; |
| 54 void UnregisterURL(const KURL&) override; | 54 void UnregisterURL(const KURL&) override; |
| 55 | 55 |
| 56 static URLRegistry& Registry(); | 56 static URLRegistry& Registry(); |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 void BlobURLRegistry::RegisterURL(SecurityOrigin* origin, | 59 void BlobURLRegistry::RegisterURL(SecurityOrigin* origin, |
| 60 const KURL& public_url, | 60 const KURL& public_url, |
| 61 URLRegistrable* registrable_object) { | 61 URLRegistrable* registrable_object) { |
| 62 ASSERT(®istrable_object->Registry() == this); | 62 DCHECK(®istrable_object->Registry(), this); |
|
alancutter (OOO until 2018)
2017/04/10 00:23:41
DCHECK_EQ?
Hwanseung Lee
2017/04/10 15:01:31
Done.
| |
| 63 Blob* blob = static_cast<Blob*>(registrable_object); | 63 Blob* blob = static_cast<Blob*>(registrable_object); |
| 64 BlobRegistry::RegisterPublicBlobURL(origin, public_url, | 64 BlobRegistry::RegisterPublicBlobURL(origin, public_url, |
| 65 blob->GetBlobDataHandle()); | 65 blob->GetBlobDataHandle()); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void BlobURLRegistry::UnregisterURL(const KURL& public_url) { | 68 void BlobURLRegistry::UnregisterURL(const KURL& public_url) { |
| 69 BlobRegistry::RevokePublicBlobURL(public_url); | 69 BlobRegistry::RevokePublicBlobURL(public_url); |
| 70 } | 70 } |
| 71 | 71 |
| 72 URLRegistry& BlobURLRegistry::Registry() { | 72 URLRegistry& BlobURLRegistry::Registry() { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 85 : blob_data_handle_(std::move(data_handle)), is_closed_(false) {} | 85 : blob_data_handle_(std::move(data_handle)), is_closed_(false) {} |
| 86 | 86 |
| 87 Blob::~Blob() {} | 87 Blob::~Blob() {} |
| 88 | 88 |
| 89 // static | 89 // static |
| 90 Blob* Blob::Create( | 90 Blob* Blob::Create( |
| 91 ExecutionContext* context, | 91 ExecutionContext* context, |
| 92 const HeapVector<ArrayBufferOrArrayBufferViewOrBlobOrUSVString>& blob_parts, | 92 const HeapVector<ArrayBufferOrArrayBufferViewOrBlobOrUSVString>& blob_parts, |
| 93 const BlobPropertyBag& options, | 93 const BlobPropertyBag& options, |
| 94 ExceptionState& exception_state) { | 94 ExceptionState& exception_state) { |
| 95 ASSERT(options.hasType()); | 95 DCHECK(options.hasType()); |
| 96 | 96 |
| 97 ASSERT(options.hasEndings()); | 97 DCHECK(options.hasEndings()); |
| 98 bool normalize_line_endings_to_native = options.endings() == "native"; | 98 bool normalize_line_endings_to_native = options.endings() == "native"; |
| 99 if (normalize_line_endings_to_native) | 99 if (normalize_line_endings_to_native) |
| 100 UseCounter::Count(context, UseCounter::kFileAPINativeLineEndings); | 100 UseCounter::Count(context, UseCounter::kFileAPINativeLineEndings); |
| 101 | 101 |
| 102 std::unique_ptr<BlobData> blob_data = BlobData::Create(); | 102 std::unique_ptr<BlobData> blob_data = BlobData::Create(); |
| 103 blob_data->SetContentType(NormalizeType(options.type())); | 103 blob_data->SetContentType(NormalizeType(options.type())); |
| 104 | 104 |
| 105 PopulateBlobData(blob_data.get(), blob_parts, | 105 PopulateBlobData(blob_data.get(), blob_parts, |
| 106 normalize_line_endings_to_native); | 106 normalize_line_endings_to_native); |
| 107 | 107 |
| 108 long long blob_size = blob_data->length(); | 108 long long blob_size = blob_data->length(); |
| 109 return new Blob(BlobDataHandle::Create(std::move(blob_data), blob_size)); | 109 return new Blob(BlobDataHandle::Create(std::move(blob_data), blob_size)); |
| 110 } | 110 } |
| 111 | 111 |
| 112 Blob* Blob::Create(const unsigned char* data, | 112 Blob* Blob::Create(const unsigned char* data, |
| 113 size_t bytes, | 113 size_t bytes, |
| 114 const String& content_type) { | 114 const String& content_type) { |
| 115 ASSERT(data); | 115 DCHECK(data); |
| 116 | 116 |
| 117 std::unique_ptr<BlobData> blob_data = BlobData::Create(); | 117 std::unique_ptr<BlobData> blob_data = BlobData::Create(); |
| 118 blob_data->SetContentType(content_type); | 118 blob_data->SetContentType(content_type); |
| 119 blob_data->AppendBytes(data, bytes); | 119 blob_data->AppendBytes(data, bytes); |
| 120 long long blob_size = blob_data->length(); | 120 long long blob_size = blob_data->length(); |
| 121 | 121 |
| 122 return new Blob(BlobDataHandle::Create(std::move(blob_data), blob_size)); | 122 return new Blob(BlobDataHandle::Create(std::move(blob_data), blob_size)); |
| 123 } | 123 } |
| 124 | 124 |
| 125 // static | 125 // static |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 141 blob_data->AppendText(item.getAsUSVString(), | 141 blob_data->AppendText(item.getAsUSVString(), |
| 142 normalize_line_endings_to_native); | 142 normalize_line_endings_to_native); |
| 143 } else { | 143 } else { |
| 144 NOTREACHED(); | 144 NOTREACHED(); |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 | 148 |
| 149 // static | 149 // static |
| 150 void Blob::ClampSliceOffsets(long long size, long long& start, long long& end) { | 150 void Blob::ClampSliceOffsets(long long size, long long& start, long long& end) { |
| 151 ASSERT(size != -1); | 151 DCHECK(size, -1); |
|
alancutter (OOO until 2018)
2017/04/10 00:23:41
DCHECK_NE?
Hwanseung Lee
2017/04/10 15:01:31
Done.
| |
| 152 | 152 |
| 153 // Convert the negative value that is used to select from the end. | 153 // Convert the negative value that is used to select from the end. |
| 154 if (start < 0) | 154 if (start < 0) |
| 155 start = start + size; | 155 start = start + size; |
| 156 if (end < 0) | 156 if (end < 0) |
| 157 end = end + size; | 157 end = end + size; |
| 158 | 158 |
| 159 // Clamp the range if it exceeds the size limit. | 159 // Clamp the range if it exceeds the size limit. |
| 160 if (start < 0) | 160 if (start < 0) |
| 161 start = 0; | 161 start = 0; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 236 const UChar* chars = type.Characters16(); | 236 const UChar* chars = type.Characters16(); |
| 237 for (size_t i = 0; i < length; ++i) { | 237 for (size_t i = 0; i < length; ++i) { |
| 238 if (chars[i] < 0x0020 || chars[i] > 0x007e) | 238 if (chars[i] < 0x0020 || chars[i] > 0x007e) |
| 239 return g_empty_string; | 239 return g_empty_string; |
| 240 } | 240 } |
| 241 } | 241 } |
| 242 return type.Lower(); | 242 return type.Lower(); |
| 243 } | 243 } |
| 244 | 244 |
| 245 } // namespace blink | 245 } // namespace blink |
| OLD | NEW |