summaryrefslogtreecommitdiffstats
path: root/printing/printed_document.h
diff options
context:
space:
mode:
authorvitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-12 16:56:55 +0000
committervitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-12 16:56:55 +0000
commitc95198b79bd2e7e9c37bcce2923ffaa51db96aa8 (patch)
treeaf2469a0a94463648f9d6737572c0877a3b1fd19 /printing/printed_document.h
parentd03d2e1c530c0329de57e31e76390defe6cad676 (diff)
downloadchromium_src-c95198b79bd2e7e9c37bcce2923ffaa51db96aa8.zip
chromium_src-c95198b79bd2e7e9c37bcce2923ffaa51db96aa8.tar.gz
chromium_src-c95198b79bd2e7e9c37bcce2923ffaa51db96aa8.tar.bz2
Improvements in --debug-print switch implementation.
* Renamed print_settings_initializer.* into print_settings_conversion.* * Dump on FILE thread. * Added PrintSettingsToJobSettingsDebug to dump PrintSettings. * Added PrintedDocument::CreateDebugDumpPath for consistent dump file naming. * Dump PDFs received from renderer process. * Moved GetCustomMarginsFromJobSettings into print_settings_conversion.cc. * Moved Parsing PageRanges into print_settings_conversion.* BUG=379961 Review URL: https://codereview.chromium.org/329683002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276716 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing/printed_document.h')
-rw-r--r--printing/printed_document.h37
1 files changed, 24 insertions, 13 deletions
diff --git a/printing/printed_document.h b/printing/printed_document.h
index 3341d54..4d0e41e 100644
--- a/printing/printed_document.h
+++ b/printing/printed_document.h
@@ -7,6 +7,7 @@
#include <map>
+#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
#include "base/strings/string16.h"
#include "base/synchronization/lock.h"
@@ -14,8 +15,8 @@
#include "ui/gfx/native_widget_types.h"
namespace base {
-class FilePath;
-class MessageLoop;
+class RefCountedMemory;
+class TaskRunner;
}
namespace printing {
@@ -38,7 +39,8 @@ class PRINTING_EXPORT PrintedDocument
// originating source and settings.
PrintedDocument(const PrintSettings& settings,
PrintedPagesSource* source,
- int cookie);
+ int cookie,
+ base::TaskRunner* blocking_runner);
// Sets a page's data. 0-based. Takes metafile ownership.
// Note: locks for a short amount of time.
@@ -51,9 +53,9 @@ class PRINTING_EXPORT PrintedDocument
const gfx::Rect& page_rect);
// Retrieves a page. If the page is not available right now, it
- // requests to have this page be rendered and returns false.
+ // requests to have this page be rendered and returns NULL.
// Note: locks for a short amount of time.
- bool GetPage(int page_number, scoped_refptr<PrintedPage>* page);
+ scoped_refptr<PrintedPage> GetPage(int page_number);
// Draws the page in the context.
// Note: locks for a short amount of time in debug only.
@@ -102,7 +104,16 @@ class PRINTING_EXPORT PrintedDocument
// no files are generated.
static void set_debug_dump_path(const base::FilePath& debug_dump_path);
- static const base::FilePath& debug_dump_path();
+ // Creates debug file name from given |document_name| and |extension|.
+ // |extension| should include '.', example ".pdf"
+ // Returns empty |base::FilePath| if debug dumps is not enabled.
+ static base::FilePath CreateDebugDumpPath(
+ const base::string16& document_name,
+ const base::FilePath::StringType& extension);
+
+ // Dump data on blocking task runner if debug dumps enabled.
+ void DebugDumpData(const base::RefCountedMemory* data,
+ const base::FilePath::StringType& extension);
private:
friend class base::RefCountedThreadSafe<PrintedDocument>;
@@ -143,16 +154,15 @@ class PRINTING_EXPORT PrintedDocument
// any lock held. This is because it can't be changed after the object's
// construction.
struct Immutable {
- Immutable(const PrintSettings& settings, PrintedPagesSource* source,
- int cookie);
+ Immutable(const PrintSettings& settings,
+ PrintedPagesSource* source,
+ int cookie,
+ base::TaskRunner* blocking_runner);
~Immutable();
// Print settings used to generate this document. Immutable.
PrintSettings settings_;
- // Native thread for the render source.
- base::MessageLoop* source_message_loop_;
-
// Document name. Immutable.
base::string16 name_;
@@ -163,9 +173,10 @@ class PRINTING_EXPORT PrintedDocument
// simpler hash of PrintSettings since a new document is made each time the
// print settings change.
int cookie_;
- };
- void DebugDump(const PrintedPage& page);
+ // Native thread for blocking operations, like file access.
+ scoped_refptr<base::TaskRunner> blocking_runner_;
+ };
// All writable data member access must be guarded by this lock. Needs to be
// mutable since it can be acquired from const member functions.