| 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_skia.h" | 5 #include "printing/pdf_metafile_skia.h" |
| 6 | 6 |
| 7 #include "base/containers/hash_tables.h" | 7 #include "base/containers/hash_tables.h" |
| 8 #include "base/file_descriptor_posix.h" | 8 #include "base/file_descriptor_posix.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 bool PdfMetafileSkia::FinishDocument() { | 89 bool PdfMetafileSkia::FinishDocument() { |
| 90 // Don't do anything if we've already set the data in InitFromData. | 90 // Don't do anything if we've already set the data in InitFromData. |
| 91 if (data_->pdf_stream_.getOffset()) | 91 if (data_->pdf_stream_.getOffset()) |
| 92 return true; | 92 return true; |
| 93 | 93 |
| 94 if (page_outstanding_) | 94 if (page_outstanding_) |
| 95 FinishPage(); | 95 FinishPage(); |
| 96 | 96 |
| 97 data_->current_page_.clear(); | 97 data_->current_page_.clear(); |
| 98 | 98 |
| 99 int font_counts[SkAdvancedTypefaceMetrics::kNotEmbeddable_Font + 1]; | 99 int font_counts[SkAdvancedTypefaceMetrics::kOther_Font + 2]; |
| 100 data_->pdf_doc_.getCountOfFontTypes(font_counts); | 100 data_->pdf_doc_.getCountOfFontTypes(font_counts); |
| 101 for (int type = 0; | 101 for (int type = 0; |
| 102 type <= SkAdvancedTypefaceMetrics::kNotEmbeddable_Font; | 102 type <= SkAdvancedTypefaceMetrics::kOther_Font + 1; |
| 103 type++) { | 103 type++) { |
| 104 for (int count = 0; count < font_counts[type]; count++) { | 104 for (int count = 0; count < font_counts[type]; count++) { |
| 105 UMA_HISTOGRAM_ENUMERATION( | 105 UMA_HISTOGRAM_ENUMERATION( |
| 106 "PrintPreview.FontType", type, | 106 "PrintPreview.FontType", type, |
| 107 SkAdvancedTypefaceMetrics::kNotEmbeddable_Font + 1); | 107 SkAdvancedTypefaceMetrics::kOther_Font + 2); |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 | 110 |
| 111 return data_->pdf_doc_.emitPDF(&data_->pdf_stream_); | 111 return data_->pdf_doc_.emitPDF(&data_->pdf_stream_); |
| 112 } | 112 } |
| 113 | 113 |
| 114 uint32 PdfMetafileSkia::GetDataSize() const { | 114 uint32 PdfMetafileSkia::GetDataSize() const { |
| 115 return base::checked_numeric_cast<uint32>(data_->pdf_stream_.getOffset()); | 115 return base::checked_numeric_cast<uint32>(data_->pdf_stream_.getOffset()); |
| 116 } | 116 } |
| 117 | 117 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 if (data->size() == 0) | 239 if (data->size() == 0) |
| 240 return NULL; | 240 return NULL; |
| 241 | 241 |
| 242 PdfMetafileSkia* metafile = new PdfMetafileSkia; | 242 PdfMetafileSkia* metafile = new PdfMetafileSkia; |
| 243 metafile->InitFromData(data->bytes(), | 243 metafile->InitFromData(data->bytes(), |
| 244 base::checked_numeric_cast<uint32>(data->size())); | 244 base::checked_numeric_cast<uint32>(data->size())); |
| 245 return metafile; | 245 return metafile; |
| 246 } | 246 } |
| 247 | 247 |
| 248 } // namespace printing | 248 } // namespace printing |
| OLD | NEW |