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

Side by Side Diff: third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp

Issue 2858963002: Replace ASSERT with DCHECK in core/ (Closed)
Patch Set: WorkerBackingThread Created 3 years, 7 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
OLDNEW
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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 } 184 }
185 185
186 const char* ImageBitmapFactories::SupplementName() { 186 const char* ImageBitmapFactories::SupplementName() {
187 return "ImageBitmapFactories"; 187 return "ImageBitmapFactories";
188 } 188 }
189 189
190 ImageBitmapFactories& ImageBitmapFactories::From(EventTarget& event_target) { 190 ImageBitmapFactories& ImageBitmapFactories::From(EventTarget& event_target) {
191 if (LocalDOMWindow* window = event_target.ToLocalDOMWindow()) 191 if (LocalDOMWindow* window = event_target.ToLocalDOMWindow())
192 return FromInternal(*window); 192 return FromInternal(*window);
193 193
194 ASSERT(event_target.GetExecutionContext()->IsWorkerGlobalScope()); 194 DCHECK(event_target.GetExecutionContext()->IsWorkerGlobalScope());
195 return ImageBitmapFactories::FromInternal( 195 return ImageBitmapFactories::FromInternal(
196 *ToWorkerGlobalScope(event_target.GetExecutionContext())); 196 *ToWorkerGlobalScope(event_target.GetExecutionContext()));
197 } 197 }
198 198
199 template <class GlobalObject> 199 template <class GlobalObject>
200 ImageBitmapFactories& ImageBitmapFactories::FromInternal(GlobalObject& object) { 200 ImageBitmapFactories& ImageBitmapFactories::FromInternal(GlobalObject& object) {
201 ImageBitmapFactories* supplement = static_cast<ImageBitmapFactories*>( 201 ImageBitmapFactories* supplement = static_cast<ImageBitmapFactories*>(
202 Supplement<GlobalObject>::From(object, SupplementName())); 202 Supplement<GlobalObject>::From(object, SupplementName()));
203 if (!supplement) { 203 if (!supplement) {
204 supplement = new ImageBitmapFactories; 204 supplement = new ImageBitmapFactories;
205 Supplement<GlobalObject>::ProvideTo(object, SupplementName(), supplement); 205 Supplement<GlobalObject>::ProvideTo(object, SupplementName(), supplement);
206 } 206 }
207 return *supplement; 207 return *supplement;
208 } 208 }
209 209
210 void ImageBitmapFactories::AddLoader(ImageBitmapLoader* loader) { 210 void ImageBitmapFactories::AddLoader(ImageBitmapLoader* loader) {
211 pending_loaders_.insert(loader); 211 pending_loaders_.insert(loader);
212 } 212 }
213 213
214 void ImageBitmapFactories::DidFinishLoading(ImageBitmapLoader* loader) { 214 void ImageBitmapFactories::DidFinishLoading(ImageBitmapLoader* loader) {
215 ASSERT(pending_loaders_.Contains(loader)); 215 DCHECK(pending_loaders_.Contains(loader));
216 pending_loaders_.erase(loader); 216 pending_loaders_.erase(loader);
217 } 217 }
218 218
219 ImageBitmapFactories::ImageBitmapLoader::ImageBitmapLoader( 219 ImageBitmapFactories::ImageBitmapLoader::ImageBitmapLoader(
220 ImageBitmapFactories& factory, 220 ImageBitmapFactories& factory,
221 Optional<IntRect> crop_rect, 221 Optional<IntRect> crop_rect,
222 ScriptState* script_state, 222 ScriptState* script_state,
223 const ImageBitmapOptions& options) 223 const ImageBitmapOptions& options)
224 : loader_( 224 : loader_(
225 FileReaderLoader::Create(FileReaderLoader::kReadAsArrayBuffer, this)), 225 FileReaderLoader::Create(FileReaderLoader::kReadAsArrayBuffer, this)),
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 WrapCrossThreadPersistent(this), std::move(task_runner), 270 WrapCrossThreadPersistent(this), std::move(task_runner),
271 WrapCrossThreadPersistent(array_buffer), options_.premultiplyAlpha(), 271 WrapCrossThreadPersistent(array_buffer), options_.premultiplyAlpha(),
272 options_.colorSpaceConversion())); 272 options_.colorSpaceConversion()));
273 } 273 }
274 274
275 void ImageBitmapFactories::ImageBitmapLoader::DecodeImageOnDecoderThread( 275 void ImageBitmapFactories::ImageBitmapLoader::DecodeImageOnDecoderThread(
276 RefPtr<WebTaskRunner> task_runner, 276 RefPtr<WebTaskRunner> task_runner,
277 DOMArrayBuffer* array_buffer, 277 DOMArrayBuffer* array_buffer,
278 const String& premultiply_alpha_option, 278 const String& premultiply_alpha_option,
279 const String& color_space_conversion_option) { 279 const String& color_space_conversion_option) {
280 ASSERT(!IsMainThread()); 280 DCHECK(!IsMainThread());
281 281
282 ImageDecoder::AlphaOption alpha_op = ImageDecoder::kAlphaPremultiplied; 282 ImageDecoder::AlphaOption alpha_op = ImageDecoder::kAlphaPremultiplied;
283 if (premultiply_alpha_option == "none") 283 if (premultiply_alpha_option == "none")
284 alpha_op = ImageDecoder::kAlphaNotPremultiplied; 284 alpha_op = ImageDecoder::kAlphaNotPremultiplied;
285 bool ignore_color_space = false; 285 bool ignore_color_space = false;
286 if (color_space_conversion_option == "none") 286 if (color_space_conversion_option == "none")
287 ignore_color_space = true; 287 ignore_color_space = true;
288 std::unique_ptr<ImageDecoder> decoder(ImageDecoder::Create( 288 std::unique_ptr<ImageDecoder> decoder(ImageDecoder::Create(
289 SegmentReader::CreateFromSkData(SkData::MakeWithoutCopy( 289 SegmentReader::CreateFromSkData(SkData::MakeWithoutCopy(
290 array_buffer->Data(), array_buffer->ByteLength())), 290 array_buffer->Data(), array_buffer->ByteLength())),
(...skipping 30 matching lines...) Expand all
321 } 321 }
322 factory_->DidFinishLoading(this); 322 factory_->DidFinishLoading(this);
323 } 323 }
324 324
325 DEFINE_TRACE(ImageBitmapFactories::ImageBitmapLoader) { 325 DEFINE_TRACE(ImageBitmapFactories::ImageBitmapLoader) {
326 visitor->Trace(factory_); 326 visitor->Trace(factory_);
327 visitor->Trace(resolver_); 327 visitor->Trace(resolver_);
328 } 328 }
329 329
330 } // namespace blink 330 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/canvas/CanvasFontCache.cpp ('k') | third_party/WebKit/Source/core/input/EventHandler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698