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

Side by Side Diff: third_party/WebKit/Source/core/frame/FrameSerializer.cpp

Issue 2220543002: Make Resource::resourceBuffer() to return PassRefPtr<const SharedBuffer> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@WTF_UseIsConvertibleInEnsure
Patch Set: Rebase Created 4 years, 3 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 break; 379 break;
380 } 380 }
381 } 381 }
382 382
383 bool FrameSerializer::shouldAddURL(const KURL& url) 383 bool FrameSerializer::shouldAddURL(const KURL& url)
384 { 384 {
385 return url.isValid() && !m_resourceURLs.contains(url) && !url.protocolIsData () 385 return url.isValid() && !m_resourceURLs.contains(url) && !url.protocolIsData ()
386 && !m_delegate.shouldSkipResourceWithURL(url); 386 && !m_delegate.shouldSkipResourceWithURL(url);
387 } 387 }
388 388
389 void FrameSerializer::addToResources(const Resource& resource, PassRefPtr<Shared Buffer> data, const KURL& url) 389 void FrameSerializer::addToResources(const Resource& resource, PassRefPtr<const SharedBuffer> data, const KURL& url)
390 { 390 {
391 if (m_delegate.shouldSkipResource(resource)) 391 if (m_delegate.shouldSkipResource(resource))
392 return; 392 return;
393 393
394 if (!data) { 394 if (!data) {
395 DLOG(ERROR) << "No data for resource " << url.getString(); 395 DLOG(ERROR) << "No data for resource " << url.getString();
396 return; 396 return;
397 } 397 }
398 398
399 String mimeType = resource.response().mimeType(); 399 String mimeType = resource.response().mimeType();
400 m_resources->append(SerializedResource(url, mimeType, std::move(data))); 400 m_resources->append(SerializedResource(url, mimeType, std::move(data)));
401 m_resourceURLs.add(url); 401 m_resourceURLs.add(url);
402 } 402 }
403 403
404 void FrameSerializer::addImageToResources(ImageResource* image, const KURL& url) 404 void FrameSerializer::addImageToResources(ImageResource* image, const KURL& url)
405 { 405 {
406 if (!image || !image->hasImage() || image->errorOccurred() || !shouldAddURL( url)) 406 if (!image || !image->hasImage() || image->errorOccurred() || !shouldAddURL( url))
407 return; 407 return;
408 408
409 RefPtr<SharedBuffer> data = image->getImage()->data(); 409 RefPtr<const SharedBuffer> data = image->getImage()->data();
410 addToResources(*image, data, url); 410 addToResources(*image, data, url);
411 } 411 }
412 412
413 void FrameSerializer::addFontToResources(FontResource* font) 413 void FrameSerializer::addFontToResources(FontResource* font)
414 { 414 {
415 if (!font || !font->isLoaded() || !font->resourceBuffer() || !shouldAddURL(f ont->url())) 415 if (!font || !font->isLoaded() || !font->resourceBuffer() || !shouldAddURL(f ont->url()))
416 return; 416 return;
417 417
418 RefPtr<SharedBuffer> data(font->resourceBuffer()); 418 RefPtr<const SharedBuffer> data(font->resourceBuffer());
419 419
420 addToResources(*font, data, font->url()); 420 addToResources(*font, data, font->url());
421 } 421 }
422 422
423 void FrameSerializer::retrieveResourcesForProperties(const StylePropertySet* sty leDeclaration, Document& document) 423 void FrameSerializer::retrieveResourcesForProperties(const StylePropertySet* sty leDeclaration, Document& document)
424 { 424 {
425 if (!styleDeclaration) 425 if (!styleDeclaration)
426 return; 426 return;
427 427
428 // The background-image and list-style-image (for ul or ol) are the CSS prop erties 428 // The background-image and list-style-image (for ul or ol) are the CSS prop erties
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 continue; 476 continue;
477 } 477 }
478 emitsMinus = ch == '-'; 478 emitsMinus = ch == '-';
479 builder.append(ch); 479 builder.append(ch);
480 } 480 }
481 CString escapedUrl = builder.toString().ascii(); 481 CString escapedUrl = builder.toString().ascii();
482 return String::format("saved from url=(%04d)%s", static_cast<int>(escapedUrl .length()), escapedUrl.data()); 482 return String::format("saved from url=(%04d)%s", static_cast<int>(escapedUrl .length()), escapedUrl.data());
483 } 483 }
484 484
485 } // namespace blink 485 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameSerializer.h ('k') | third_party/WebKit/Source/core/inspector/InspectorPageAgent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698