Do all the font UMA work in PdfMetafileSkia::FinishDocument.
BUG=80918 TEST=NONE Review URL: http://codereview.chromium.org/7057041 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87624 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
@@ -22,18 +22,12 @@
|
|||||||
#include "ui/gfx/rect.h"
|
#include "ui/gfx/rect.h"
|
||||||
#include "ui/gfx/size.h"
|
#include "ui/gfx/size.h"
|
||||||
|
|
||||||
namespace {
|
|
||||||
typedef base::hash_map<SkFontID, SkAdvancedTypefaceMetrics::FontType>
|
|
||||||
FontTypeMap;
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace printing {
|
namespace printing {
|
||||||
|
|
||||||
struct PdfMetafileSkiaData {
|
struct PdfMetafileSkiaData {
|
||||||
SkRefPtr<SkPDFDevice> current_page_;
|
SkRefPtr<SkPDFDevice> current_page_;
|
||||||
SkPDFDocument pdf_doc_;
|
SkPDFDocument pdf_doc_;
|
||||||
SkDynamicMemoryWStream pdf_stream_;
|
SkDynamicMemoryWStream pdf_stream_;
|
||||||
FontTypeMap font_type_stats_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
PdfMetafileSkia::~PdfMetafileSkia() {}
|
PdfMetafileSkia::~PdfMetafileSkia() {}
|
||||||
@@ -81,13 +75,6 @@ bool PdfMetafileSkia::StartPage(const gfx::Size& page_size,
|
|||||||
bool PdfMetafileSkia::FinishPage() {
|
bool PdfMetafileSkia::FinishPage() {
|
||||||
DCHECK(data_->current_page_.get());
|
DCHECK(data_->current_page_.get());
|
||||||
|
|
||||||
const SkTDArray<SkPDFFont*>& font_resources =
|
|
||||||
data_->current_page_->getFontResources();
|
|
||||||
for (int i = 0; i < font_resources.count(); i++) {
|
|
||||||
SkFontID key = font_resources[i]->typeface()->uniqueID();
|
|
||||||
data_->font_type_stats_[key] = font_resources[i]->getType();
|
|
||||||
}
|
|
||||||
|
|
||||||
data_->pdf_doc_.appendPage(data_->current_page_);
|
data_->pdf_doc_.appendPage(data_->current_page_);
|
||||||
data_->current_page_ = NULL;
|
data_->current_page_ = NULL;
|
||||||
return true;
|
return true;
|
||||||
@@ -101,13 +88,22 @@ bool PdfMetafileSkia::FinishDocument() {
|
|||||||
if (data_->current_page_.get())
|
if (data_->current_page_.get())
|
||||||
FinishPage();
|
FinishPage();
|
||||||
|
|
||||||
for (FontTypeMap::const_iterator it = data_->font_type_stats_.begin();
|
base::hash_set<SkFontID> font_set;
|
||||||
it != data_->font_type_stats_.end();
|
|
||||||
it++) {
|
const SkTDArray<SkPDFPage*>& pages = data_->pdf_doc_.getPages();
|
||||||
UMA_HISTOGRAM_ENUMERATION(
|
for (int page_number = 0; page_number < pages.count(); page_number++) {
|
||||||
"PrintPreview.FontType",
|
const SkTDArray<SkPDFFont*>& font_resources =
|
||||||
it->second,
|
pages[page_number]->getFontResources();
|
||||||
SkAdvancedTypefaceMetrics::kNotEmbeddable_Font + 1);
|
for (int font = 0; font < font_resources.count(); font++) {
|
||||||
|
SkFontID font_id = font_resources[font]->typeface()->uniqueID();
|
||||||
|
if (font_set.find(font_id) == font_set.end()) {
|
||||||
|
font_set.insert(font_id);
|
||||||
|
UMA_HISTOGRAM_ENUMERATION(
|
||||||
|
"PrintPreview.FontType",
|
||||||
|
font_resources[font]->getType(),
|
||||||
|
SkAdvancedTypefaceMetrics::kNotEmbeddable_Font + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return data_->pdf_doc_.emitPDF(&data_->pdf_stream_);
|
return data_->pdf_doc_.emitPDF(&data_->pdf_stream_);
|
||||||
|
Reference in New Issue
Block a user