diff options
author | kmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-21 22:30:10 +0000 |
---|---|---|
committer | kmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-21 22:30:10 +0000 |
commit | 15c2bb32e4b2a436e404695ee7b5ea564cc9c60b (patch) | |
tree | 3b5208034639c45ba114eb2d8b7c729ee38eeeef /chrome/common | |
parent | 6e74a3bcc45e25f4a249649953b5120324facf16 (diff) | |
download | chromium_src-15c2bb32e4b2a436e404695ee7b5ea564cc9c60b.zip chromium_src-15c2bb32e4b2a436e404695ee7b5ea564cc9c60b.tar.gz chromium_src-15c2bb32e4b2a436e404695ee7b5ea564cc9c60b.tar.bz2 |
Refactor mac printing workflow.
To support print preview, made code changes to create a single metafile for the entire printing document.
BUG=64121
TEST=printing works after code changes.
Review URL: http://codereview.chromium.org/5892002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69885 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r-- | chrome/common/render_messages.h | 1 | ||||
-rw-r--r-- | chrome/common/render_messages_internal.h | 11 | ||||
-rw-r--r-- | chrome/common/render_messages_params.cc | 35 | ||||
-rw-r--r-- | chrome/common/render_messages_params.h | 23 |
4 files changed, 64 insertions, 6 deletions
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index 06e597c..e06a667 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -100,6 +100,7 @@ struct ViewHostMsg_Resource_Request; struct ViewMsg_Print_Params; struct ViewMsg_PrintPage_Params; struct ViewMsg_PrintPages_Params; +struct ViewHostMsg_DidPreviewDocument_Params; struct ViewHostMsg_DidPrintPage_Params; struct ViewHostMsg_Audio_CreateStream_Params; struct ViewHostMsg_ShowPopup_Params; diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index 01fc555..f94f1ed 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -170,12 +170,11 @@ IPC_MESSAGE_ROUTED2(ViewMsg_PrintingDone, // requested pages for print preview. IPC_MESSAGE_ROUTED0(ViewMsg_PrintPreview) -// Sends back to the browser the rendered "printed page" for preview that was -// requested by a ViewMsg_PrintPage message or from scripted printing. The -// memory handle in this message is already valid in the browser process. -IPC_MESSAGE_ROUTED2(ViewHostMsg_PagesReadyForPreview, - int /* document cookie */, - int /* fd in browser */) +// Sends back to the browser the rendered "printed document" for preview that +// was requested by a ViewMsg_PrintPreview message. The memory handle in this +// message is already valid in the browser process. +IPC_MESSAGE_ROUTED1(ViewHostMsg_PagesReadyForPreview, + ViewHostMsg_DidPreviewDocument_Params /* params */) // Tells the renderer to dump as much memory as it can, perhaps because we // have memory pressure or the renderer is (or will be) paged out. This diff --git a/chrome/common/render_messages_params.cc b/chrome/common/render_messages_params.cc index 618ca8e..7fab193 100644 --- a/chrome/common/render_messages_params.cc +++ b/chrome/common/render_messages_params.cc @@ -118,6 +118,21 @@ ViewMsg_PrintPages_Params::ViewMsg_PrintPages_Params() { ViewMsg_PrintPages_Params::~ViewMsg_PrintPages_Params() { } +ViewHostMsg_DidPreviewDocument_Params::ViewHostMsg_DidPreviewDocument_Params() + : data_size(0) { +#if defined(OS_WIN) + // Initialize |metafile_data_handle| only on Windows because it maps + // base::SharedMemoryHandle to HANDLE. We do not need to initialize this + // variable on Posix because it maps base::SharedMemoryHandle to + // FileDescriptior, which has the default constructor. + metafile_data_handle = INVALID_HANDLE_VALUE; +#endif +} + +ViewHostMsg_DidPreviewDocument_Params:: + ~ViewHostMsg_DidPreviewDocument_Params() { +} + ViewHostMsg_DidPrintPage_Params::ViewHostMsg_DidPrintPage_Params() : data_size(0), document_cookie(0), @@ -995,6 +1010,26 @@ void ParamTraits<ViewMsg_PrintPages_Params>::Log(const param_type& p, l->append("<ViewMsg_PrintPages_Params>"); } +void ParamTraits<ViewHostMsg_DidPreviewDocument_Params>::Write(Message* m, + const param_type& p) { + WriteParam(m, p.metafile_data_handle); + WriteParam(m, p.data_size); + WriteParam(m, p.document_cookie); +} + +bool ParamTraits<ViewHostMsg_DidPreviewDocument_Params>::Read(const Message* m, + void** iter, + param_type* p) { + return ReadParam(m, iter, &p->metafile_data_handle) && + ReadParam(m, iter, &p->data_size) && + ReadParam(m, iter, &p->document_cookie); +} + +void ParamTraits<ViewHostMsg_DidPreviewDocument_Params>::Log( + const param_type& p, std::string* l) { + l->append("<ViewHostMsg_DidPreviewDocument_Params>"); +} + void ParamTraits<ViewHostMsg_DidPrintPage_Params>::Write(Message* m, const param_type& p) { WriteParam(m, p.metafile_data_handle); diff --git a/chrome/common/render_messages_params.h b/chrome/common/render_messages_params.h index 911e3ae..97817d2 100644 --- a/chrome/common/render_messages_params.h +++ b/chrome/common/render_messages_params.h @@ -552,6 +552,21 @@ struct ViewMsg_PrintPages_Params { std::vector<int> pages; }; +//Parameters to describe a rendered document. +struct ViewHostMsg_DidPreviewDocument_Params { + ViewHostMsg_DidPreviewDocument_Params(); + ~ViewHostMsg_DidPreviewDocument_Params(); + + // A shared memory handle to metafile data. + base::SharedMemoryHandle metafile_data_handle; + + // Size of metafile data. + uint32 data_size; + + // Cookie for the document to ensure correctness. + int document_cookie; +}; + // Parameters to describe a rendered page. struct ViewHostMsg_DidPrintPage_Params { ViewHostMsg_DidPrintPage_Params(); @@ -986,6 +1001,14 @@ struct ParamTraits<ViewMsg_PrintPages_Params> { }; template <> +struct ParamTraits<ViewHostMsg_DidPreviewDocument_Params> { + typedef ViewHostMsg_DidPreviewDocument_Params param_type; + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, void** iter, param_type* p); + static void Log(const param_type& p, std::string* l); +}; + +template <> struct ParamTraits<ViewHostMsg_DidPrintPage_Params> { typedef ViewHostMsg_DidPrintPage_Params param_type; static void Write(Message* m, const param_type& p); |