OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/pdf_metafile_cg_mac.h" | 5 #include "printing/pdf_metafile_cg_mac.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 NOTREACHED(); | 73 NOTREACHED(); |
74 break; | 74 break; |
75 } | 75 } |
76 } | 76 } |
77 | 77 |
78 } // namespace | 78 } // namespace |
79 | 79 |
80 namespace printing { | 80 namespace printing { |
81 | 81 |
82 PdfMetafileCg::PdfMetafileCg() | 82 PdfMetafileCg::PdfMetafileCg() |
83 : page_is_open_(false), | 83 : page_is_open_(false), thread_pdf_docs_owned_(false) {} |
84 thread_pdf_docs_owned_(false) { | |
85 if (!thread_pdf_docs.Pointer()->Get() && | |
86 base::mac::IsOSSnowLeopard()) { | |
87 thread_pdf_docs_owned_ = true; | |
88 thread_pdf_docs.Pointer()->Set( | |
89 CFSetCreateMutable(kCFAllocatorDefault, 0, &kCFTypeSetCallBacks)); | |
90 } | |
91 } | |
92 | 84 |
93 PdfMetafileCg::~PdfMetafileCg() { | 85 PdfMetafileCg::~PdfMetafileCg() { |
94 DCHECK(thread_checker_.CalledOnValidThread()); | 86 DCHECK(thread_checker_.CalledOnValidThread()); |
95 if (pdf_doc_ && thread_pdf_docs.Pointer()->Get()) { | 87 if (pdf_doc_ && thread_pdf_docs.Pointer()->Get()) { |
96 // Transfer ownership to the pool. | 88 // Transfer ownership to the pool. |
97 CFSetAddValue(thread_pdf_docs.Pointer()->Get(), pdf_doc_); | 89 CFSetAddValue(thread_pdf_docs.Pointer()->Get(), pdf_doc_); |
98 } | 90 } |
99 | 91 |
100 if (thread_pdf_docs_owned_) { | 92 if (thread_pdf_docs_owned_) { |
101 CFRelease(thread_pdf_docs.Pointer()->Get()); | 93 CFRelease(thread_pdf_docs.Pointer()->Get()); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 | 326 |
335 if (!pdf_doc_.get()) { | 327 if (!pdf_doc_.get()) { |
336 ScopedCFTypeRef<CGDataProviderRef> pdf_data_provider( | 328 ScopedCFTypeRef<CGDataProviderRef> pdf_data_provider( |
337 CGDataProviderCreateWithCFData(pdf_data_)); | 329 CGDataProviderCreateWithCFData(pdf_data_)); |
338 pdf_doc_.reset(CGPDFDocumentCreateWithProvider(pdf_data_provider)); | 330 pdf_doc_.reset(CGPDFDocumentCreateWithProvider(pdf_data_provider)); |
339 } | 331 } |
340 return pdf_doc_.get(); | 332 return pdf_doc_.get(); |
341 } | 333 } |
342 | 334 |
343 } // namespace printing | 335 } // namespace printing |
OLD | NEW |