| OLD | NEW |
| 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/printed_document.h" | 5 #include "printing/printed_document.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 void DebugDumpSettings(const base::string16& doc_name, | 74 void DebugDumpSettings(const base::string16& doc_name, |
| 75 const PrintSettings& settings, | 75 const PrintSettings& settings, |
| 76 base::TaskRunner* blocking_runner) { | 76 base::TaskRunner* blocking_runner) { |
| 77 base::DictionaryValue job_settings; | 77 base::DictionaryValue job_settings; |
| 78 PrintSettingsToJobSettingsDebug(settings, &job_settings); | 78 PrintSettingsToJobSettingsDebug(settings, &job_settings); |
| 79 std::string settings_str; | 79 std::string settings_str; |
| 80 base::JSONWriter::WriteWithOptions( | 80 base::JSONWriter::WriteWithOptions( |
| 81 job_settings, base::JSONWriter::OPTIONS_PRETTY_PRINT, &settings_str); | 81 job_settings, base::JSONWriter::OPTIONS_PRETTY_PRINT, &settings_str); |
| 82 scoped_refptr<base::RefCountedMemory> data = | 82 scoped_refptr<base::RefCountedMemory> data = |
| 83 base::RefCountedString::TakeString(&settings_str); | 83 base::RefCountedString::TakeString(&settings_str); |
| 84 blocking_runner->PostTask( | 84 blocking_runner->PostTask(FROM_HERE, base::Bind(&DebugDumpDataTask, doc_name, |
| 85 FROM_HERE, | 85 FILE_PATH_LITERAL(".json"), |
| 86 base::Bind( | 86 base::RetainedRef(data))); |
| 87 &DebugDumpDataTask, doc_name, FILE_PATH_LITERAL(".json"), data)); | |
| 88 } | 87 } |
| 89 | 88 |
| 90 } // namespace | 89 } // namespace |
| 91 | 90 |
| 92 PrintedDocument::PrintedDocument(const PrintSettings& settings, | 91 PrintedDocument::PrintedDocument(const PrintSettings& settings, |
| 93 PrintedPagesSource* source, | 92 PrintedPagesSource* source, |
| 94 int cookie, | 93 int cookie, |
| 95 base::TaskRunner* blocking_runner) | 94 base::TaskRunner* blocking_runner) |
| 96 : mutable_(source), immutable_(settings, source, cookie, blocking_runner) { | 95 : mutable_(source), immutable_(settings, source, cookie, blocking_runner) { |
| 97 // Records the expected page count if a range is setup. | 96 // Records the expected page count if a range is setup. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 mutable_.pages_[page_number] = page; | 128 mutable_.pages_[page_number] = page; |
| 130 | 129 |
| 131 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 130 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 132 if (page_number < mutable_.first_page) | 131 if (page_number < mutable_.first_page) |
| 133 mutable_.first_page = page_number; | 132 mutable_.first_page = page_number; |
| 134 #endif | 133 #endif |
| 135 } | 134 } |
| 136 | 135 |
| 137 if (!g_debug_dump_info.Get().empty()) { | 136 if (!g_debug_dump_info.Get().empty()) { |
| 138 immutable_.blocking_runner_->PostTask( | 137 immutable_.blocking_runner_->PostTask( |
| 139 FROM_HERE, base::Bind(&DebugDumpPageTask, name(), page)); | 138 FROM_HERE, |
| 139 base::Bind(&DebugDumpPageTask, name(), base::RetainedRef(page))); |
| 140 } | 140 } |
| 141 } | 141 } |
| 142 | 142 |
| 143 scoped_refptr<PrintedPage> PrintedDocument::GetPage(int page_number) { | 143 scoped_refptr<PrintedPage> PrintedDocument::GetPage(int page_number) { |
| 144 scoped_refptr<PrintedPage> page; | 144 scoped_refptr<PrintedPage> page; |
| 145 { | 145 { |
| 146 base::AutoLock lock(lock_); | 146 base::AutoLock lock(lock_); |
| 147 PrintedPages::const_iterator itr = mutable_.pages_.find(page_number); | 147 PrintedPages::const_iterator itr = mutable_.pages_.find(page_number); |
| 148 if (itr != mutable_.pages_.end()) | 148 if (itr != mutable_.pages_.end()) |
| 149 page = itr->second; | 149 page = itr->second; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 } | 264 } |
| 265 | 265 |
| 266 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) | 266 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) |
| 267 // This function is not used on aura linux/chromeos or android. | 267 // This function is not used on aura linux/chromeos or android. |
| 268 void PrintedDocument::RenderPrintedPage(const PrintedPage& page, | 268 void PrintedDocument::RenderPrintedPage(const PrintedPage& page, |
| 269 PrintingContext* context) const { | 269 PrintingContext* context) const { |
| 270 } | 270 } |
| 271 #endif | 271 #endif |
| 272 | 272 |
| 273 } // namespace printing | 273 } // namespace printing |
| OLD | NEW |