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

Unified Diff: printing/native_metafile_factory.cc

Issue 6696076: Adding CreateFromData to NativeMetafileFactory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebasing Created 9 years, 9 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: printing/native_metafile_factory.cc
diff --git a/printing/native_metafile_factory.cc b/printing/native_metafile_factory.cc
index f97145252702b7c834b805bf5bd0663d3e184ad6..670e99fd34aa425b4cb7a6f54b19474dae957e9b 100644
--- a/printing/native_metafile_factory.cc
+++ b/printing/native_metafile_factory.cc
@@ -16,13 +16,37 @@ namespace printing {
// static
printing::NativeMetafile* NativeMetafileFactory::Create() {
+ NativeMetafile* metafile;
#if defined(OS_WIN)
- return new printing::Emf;
+ metafile = new printing::Emf;
vandebo (ex-Chrome) 2011/03/24 20:11:55 This code is duplicated. You should pull it out i
dpapad 2011/03/24 21:08:14 Done.
#elif defined(OS_MACOSX)
- return new printing::PdfMetafile;
+ metafile = new printing::PdfMetafile;
#elif defined(OS_POSIX)
- return new printing::PdfPsMetafile;
+ metafile = new printing::PdfPsMetafile;
#endif
+ if (!metafile->Init()) {
+ delete metafile;
+ return NULL;
+ }
+ return metafile;
+}
+
+// static
+printing::NativeMetafile* NativeMetafileFactory::CreateFromData(
+ const void* src_buffer, uint32 src_buffer_size) {
+ NativeMetafile* metafile;
+#if defined(OS_WIN)
+ metafile = new printing::Emf;
+#elif defined(OS_MACOSX)
+ metafile = new printing::PdfMetafile;
+#elif defined(OS_POSIX)
+ metafile = new printing::PdfPsMetafile;
+#endif
+ if (!metafile->InitFromData(src_buffer, src_buffer_size)) {
+ delete metafile;
+ return NULL;
+ }
+ return metafile;
}
} // namespace printing

Powered by Google App Engine
This is Rietveld 408576698