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

Side by Side Diff: printing/pdf_metafile_cg_mac.cc

Issue 8491043: Allow linker initialization of lazy instance (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: willchan comments + rebase Created 9 years, 1 month 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
« no previous file with comments | « printing/backend/print_backend_cups.cc ('k') | printing/printed_document.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/pdf_metafile_cg_mac.h" 5 #include "printing/pdf_metafile_cg_mac.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/mac_util.h" 10 #include "base/mac/mac_util.h"
(...skipping 20 matching lines...) Expand all
31 // the destination PDF context will crash. So the outermost instantiation of 31 // the destination PDF context will crash. So the outermost instantiation of
32 // PdfMetafileCg creates a pool for deeper instantiations to dump their used 32 // PdfMetafileCg creates a pool for deeper instantiations to dump their used
33 // PDFs into rather than releasing them. When the top-level PDF is closed, then 33 // PDFs into rather than releasing them. When the top-level PDF is closed, then
34 // it's safe to clear the pool. A thread local is used to allow this to work in 34 // it's safe to clear the pool. A thread local is used to allow this to work in
35 // single-process mode. TODO(avi): This Apple bug appears fixed in 10.7; when 35 // single-process mode. TODO(avi): This Apple bug appears fixed in 10.7; when
36 // 10.7 is the minimum required version for Chromium, remove this hack. 36 // 10.7 is the minimum required version for Chromium, remove this hack.
37 37
38 base::LazyInstance< 38 base::LazyInstance<
39 base::ThreadLocalPointer<struct __CFSet>, 39 base::ThreadLocalPointer<struct __CFSet>,
40 base::LeakyLazyInstanceTraits<base::ThreadLocalPointer<struct __CFSet> > > 40 base::LeakyLazyInstanceTraits<base::ThreadLocalPointer<struct __CFSet> > >
41 thread_pdf_docs(base::LINKER_INITIALIZED); 41 thread_pdf_docs = LAZY_INSTANCE_INITIALIZER;
42 42
43 } // namespace 43 } // namespace
44 44
45 namespace printing { 45 namespace printing {
46 46
47 PdfMetafileCg::PdfMetafileCg() 47 PdfMetafileCg::PdfMetafileCg()
48 : page_is_open_(false), 48 : page_is_open_(false),
49 thread_pdf_docs_owned_(false) { 49 thread_pdf_docs_owned_(false) {
50 if (!thread_pdf_docs.Pointer()->Get() && 50 if (!thread_pdf_docs.Pointer()->Get() &&
51 base::mac::IsOSSnowLeopardOrEarlier()) { 51 base::mac::IsOSSnowLeopardOrEarlier()) {
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 295
296 if (!pdf_doc_.get()) { 296 if (!pdf_doc_.get()) {
297 ScopedCFTypeRef<CGDataProviderRef> pdf_data_provider( 297 ScopedCFTypeRef<CGDataProviderRef> pdf_data_provider(
298 CGDataProviderCreateWithCFData(pdf_data_)); 298 CGDataProviderCreateWithCFData(pdf_data_));
299 pdf_doc_.reset(CGPDFDocumentCreateWithProvider(pdf_data_provider)); 299 pdf_doc_.reset(CGPDFDocumentCreateWithProvider(pdf_data_provider));
300 } 300 }
301 return pdf_doc_.get(); 301 return pdf_doc_.get();
302 } 302 }
303 303
304 } // namespace printing 304 } // namespace printing
OLDNEW
« no previous file with comments | « printing/backend/print_backend_cups.cc ('k') | printing/printed_document.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698