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

Side by Side Diff: printing/native_metafile_factory.cc

Issue 6696076: Adding CreateFromData to NativeMetafileFactory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing comments, fixing mac unitests. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "printing/native_metafile_factory.h" 5 #include "printing/native_metafile_factory.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include "printing/emf_win.h" 8 #include "printing/emf_win.h"
9 #elif defined(OS_MACOSX) 9 #elif defined(OS_MACOSX)
10 #include "printing/pdf_metafile_mac.h" 10 #include "printing/pdf_metafile_mac.h"
11 #elif defined(OS_POSIX) 11 #elif defined(OS_POSIX)
12 #include "printing/pdf_ps_metafile_cairo.h" 12 #include "printing/pdf_ps_metafile_cairo.h"
13 #endif 13 #endif
14 14
15 namespace printing { 15 namespace printing {
16 16
17 // static 17 // static
18 printing::NativeMetafile* NativeMetafileFactory::Create() { 18 NativeMetafile* NativeMetafileFactory::Create() {
19 NativeMetafile* metafile = CreateNewMetafile();
20 if (!metafile->Init()) {
21 delete metafile;
22 return NULL;
23 }
24 return metafile;
25 }
26
27 // static
28 NativeMetafile* NativeMetafileFactory::CreateFromData(
29 const void* src_buffer, uint32 src_buffer_size) {
30 NativeMetafile* metafile = CreateNewMetafile();
31 if (!metafile->InitFromData(src_buffer, src_buffer_size)) {
32 delete metafile;
33 return NULL;
34 }
35 return metafile;
36 }
37
38 // static
39 NativeMetafile* NativeMetafileFactory::CreateNewMetafile(){
vandebo (ex-Chrome) 2011/03/24 21:21:58 This doesn't need to be a class member. We prefer
dpapad 2011/03/24 22:02:37 I left it as a class member because this class is
19 #if defined(OS_WIN) 40 #if defined(OS_WIN)
20 return new printing::Emf; 41 return new printing::Emf;
21 #elif defined(OS_MACOSX) 42 #elif defined(OS_MACOSX)
22 return new printing::PdfMetafile; 43 return new printing::PdfMetafile;
23 #elif defined(OS_POSIX) 44 #elif defined(OS_POSIX)
24 return new printing::PdfPsMetafile; 45 return new printing::PdfPsMetafile;
25 #endif 46 #endif
26 } 47 }
27 48
28 } // namespace printing 49 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698