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

Unified Diff: printing/printed_document.cc

Issue 568633002: Extracted MetafilePlayer interface from printing::MetafilePlayer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@no_expose
Patch Set: Thu Sep 11 22:54:16 PDT 2014 Created 6 years, 3 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
« no previous file with comments | « printing/printed_document.h ('k') | printing/printed_document_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: printing/printed_document.cc
diff --git a/printing/printed_document.cc b/printing/printed_document.cc
index f1b507dc415c5b5e65dafca8c6a49eff7f1a16ee..63fce8f0d97c34b7d58de7d690c6e1d6ebb7bbab 100644
--- a/printing/printed_document.cc
+++ b/printing/printed_document.cc
@@ -48,13 +48,15 @@ void DebugDumpPageTask(const base::string16& doc_name,
base::string16 filename = doc_name;
filename +=
base::ASCIIToUTF16(base::StringPrintf("_%04d", page->page_number()));
+ base::FilePath file_path =
#if defined(OS_WIN)
- page->metafile()->SaveTo(PrintedDocument::CreateDebugDumpPath(
- filename, FILE_PATH_LITERAL(".emf")));
+ PrintedDocument::CreateDebugDumpPath(filename, FILE_PATH_LITERAL(".emf"));
#else // OS_WIN
- page->metafile()->SaveTo(PrintedDocument::CreateDebugDumpPath(
- filename, FILE_PATH_LITERAL(".pdf")));
+ PrintedDocument::CreateDebugDumpPath(filename, FILE_PATH_LITERAL(".pdf"));
#endif // OS_WIN
+ base::File file(file_path,
+ base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE);
+ page->metafile()->SaveTo(&file);
}
void DebugDumpDataTask(const base::string16& doc_name,
@@ -109,7 +111,7 @@ PrintedDocument::~PrintedDocument() {
}
void PrintedDocument::SetPage(int page_number,
- Metafile* metafile,
+ scoped_ptr<MetafilePlayer> metafile,
#if defined(OS_WIN)
double shrink,
#endif // OS_WIN
@@ -118,7 +120,7 @@ void PrintedDocument::SetPage(int page_number,
// Notice the page_number + 1, the reason is that this is the value that will
// be shown. Users dislike 0-based counting.
scoped_refptr<PrintedPage> page(
- new PrintedPage(page_number + 1, metafile, paper_size, page_rect));
+ new PrintedPage(page_number + 1, metafile.Pass(), paper_size, page_rect));
#if defined(OS_WIN)
page->set_shrink_factor(shrink);
#endif // OS_WIN
@@ -177,26 +179,6 @@ void PrintedDocument::DisconnectSource() {
mutable_.source_ = NULL;
}
-uint32 PrintedDocument::MemoryUsage() const {
- std::vector< scoped_refptr<PrintedPage> > pages_copy;
- {
- base::AutoLock lock(lock_);
- pages_copy.reserve(mutable_.pages_.size());
- PrintedPages::const_iterator end = mutable_.pages_.end();
- for (PrintedPages::const_iterator itr = mutable_.pages_.begin();
- itr != end; ++itr) {
- if (itr->second.get()) {
- pages_copy.push_back(itr->second);
- }
- }
- }
- uint32 total = 0;
- for (size_t i = 0; i < pages_copy.size(); ++i) {
- total += pages_copy[i]->metafile()->GetDataSize();
- }
- return total;
-}
-
void PrintedDocument::set_page_count(int max_page) {
base::AutoLock lock(lock_);
DCHECK_EQ(0, mutable_.page_count_);
« no previous file with comments | « printing/printed_document.h ('k') | printing/printed_document_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698