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

Side by Side Diff: third_party/WebKit/Source/core/fileapi/Blob.cpp

Issue 2804403003: Replace ASSERT, ASSERT_NOT_REACHED, and RELEASE_ASSERT in core/fileapi (Closed)
Patch Set: fix Created 3 years, 8 months 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/fileapi/File.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) 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
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(&registrable_object->Registry() == this); 62 DCHECK_EQ(&registrable_object->Registry(), this);
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
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
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_NE(size, -1);
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
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
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/fileapi/File.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698