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

Unified Diff: chrome/browser/printing/print_preview_message_handler.cc

Issue 7397021: Re-land r93365 - add RefCountedString (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 9 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/printing/print_preview_message_handler.cc
diff --git a/chrome/browser/printing/print_preview_message_handler.cc b/chrome/browser/printing/print_preview_message_handler.cc
index 99be3f5e6257255683cb89165809b25d0a072aa6..75aa54c11e7975cf9c52d8d1aa87360201e0774b 100644
--- a/chrome/browser/printing/print_preview_message_handler.cc
+++ b/chrome/browser/printing/print_preview_message_handler.cc
@@ -141,14 +141,15 @@ void PrintPreviewMessageHandler::OnPagesReadyForPreview(
wrapper->print_view_manager()->OverrideTitle(tab_contents());
- char* preview_data = static_cast<char*>(shared_buf->memory());
+ const unsigned char* preview_data =
+ static_cast<unsigned char*>(shared_buf->memory());
uint32 preview_data_size = params.data_size;
+ // TODO(joth): This seems like a good match for using RefCountedStaticMemory
+ // to avoid the memory copy, but the SetPrintPreviewData call chain below
+ // needs updating to accept the RefCountedMemory* base class.
scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes);
- html_bytes->data.resize(preview_data_size);
- std::vector<unsigned char>::iterator it = html_bytes->data.begin();
- for (uint32 i = 0; i < preview_data_size; ++i, ++it)
- *it = *(preview_data + i);
+ html_bytes->data().assign(preview_data, preview_data + preview_data_size);
print_preview_ui->SetPrintPreviewData(html_bytes.get());
print_preview_ui->OnPreviewDataIsAvailable(
« no previous file with comments | « chrome/browser/printing/cloud_print/cloud_print_setup_source.cc ('k') | chrome/browser/ui/login/login_prompt_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698