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

Unified Diff: printing/pdf_metafile_mac.cc

Issue 6611032: Unifying NativeMetafile class interface (as much as possible) for Linux, Mac, Win (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changed DCHECK to count partial writes as failures. 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/pdf_metafile_mac.cc
diff --git a/printing/pdf_metafile_mac.cc b/printing/pdf_metafile_mac.cc
index ffd80e8f8d7c765119a5e669e30da4c20fb0a545..86327b4209f5d958b1b310f72bd08096e972ad7a 100644
--- a/printing/pdf_metafile_mac.cc
+++ b/printing/pdf_metafile_mac.cc
@@ -9,6 +9,7 @@
#include "base/mac/scoped_cftyperef.h"
#include "base/sys_string_conversions.h"
#include "ui/gfx/rect.h"
+#include "ui/gfx/size.h"
using base::mac::ScopedCFTypeRef;
@@ -20,7 +21,7 @@ PdfMetafile::PdfMetafile()
PdfMetafile::~PdfMetafile() {}
-CGContextRef PdfMetafile::Init() {
+bool PdfMetafile::Init() {
// Ensure that Init hasn't already been called.
DCHECK(!context_.get());
DCHECK(!pdf_data_.get());
@@ -28,14 +29,14 @@ CGContextRef PdfMetafile::Init() {
pdf_data_.reset(CFDataCreateMutable(kCFAllocatorDefault, 0));
if (!pdf_data_.get()) {
LOG(ERROR) << "Failed to create pdf data for metafile";
- return NULL;
+ return false;
}
ScopedCFTypeRef<CGDataConsumerRef> pdf_consumer(
CGDataConsumerCreateWithCFData(pdf_data_));
if (!pdf_consumer.get()) {
LOG(ERROR) << "Failed to create data consumer for metafile";
pdf_data_.reset(NULL);
- return NULL;
+ return false;
}
context_.reset(CGPDFContextCreate(pdf_consumer, NULL, NULL));
if (!context_.get()) {
@@ -43,7 +44,7 @@ CGContextRef PdfMetafile::Init() {
pdf_data_.reset(NULL);
}
- return context_.get();
+ return true;
}
bool PdfMetafile::Init(const void* src_buffer, uint32 src_buffer_size) {
@@ -84,16 +85,17 @@ CGContextRef PdfMetafile::StartPage(const gfx::Size& page_size,
return context_.get();
}
-void PdfMetafile::FinishPage() {
+bool PdfMetafile::FinishPage() {
DCHECK(context_.get());
DCHECK(page_is_open_);
CGContextRestoreGState(context_);
CGContextEndPage(context_);
page_is_open_ = false;
+ return true;
}
-void PdfMetafile::Close() {
+bool PdfMetafile::Close() {
DCHECK(context_.get());
DCHECK(!page_is_open_);
@@ -110,6 +112,7 @@ void PdfMetafile::Close() {
#endif
CGPDFContextClose(context_.get());
context_.reset(NULL);
+ return true;
}
bool PdfMetafile::RenderPage(unsigned int page_number, CGContextRef context,

Powered by Google App Engine
This is Rietveld 408576698