summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authorsanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-22 00:01:55 +0000
committersanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-22 00:01:55 +0000
commit574c7bb72cdc18bc52b69a10aad1287c85a57c70 (patch)
treeb52524b1ad81c3311603d421af4b3587a22320c8 /chrome/common
parent3ab6796d3645a13a56a2fc311fc36c66d31089d6 (diff)
downloadchromium_src-574c7bb72cdc18bc52b69a10aad1287c85a57c70.zip
chromium_src-574c7bb72cdc18bc52b69a10aad1287c85a57c70.tar.gz
chromium_src-574c7bb72cdc18bc52b69a10aad1287c85a57c70.tar.bz2
As the first step in an effort to improve robustness of the cloud print proxy, we fetch printer capabilities and defaults in a child process so that printer driver crashes do not crash the entire proxy.
BUG=None TEST=Registration of printers, printer update in Cloud Print Proxy. Review URL: http://codereview.chromium.org/5947002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69899 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/common_param_traits.cc31
-rw-r--r--chrome/common/common_param_traits.h9
-rw-r--r--chrome/common/common_param_traits_unittest.cc22
-rw-r--r--chrome/common/utility_messages_internal.h20
4 files changed, 82 insertions, 0 deletions
diff --git a/chrome/common/common_param_traits.cc b/chrome/common/common_param_traits.cc
index 3564780..40417fc 100644
--- a/chrome/common/common_param_traits.cc
+++ b/chrome/common/common_param_traits.cc
@@ -13,6 +13,7 @@
#include "gfx/rect.h"
#include "googleurl/src/gurl.h"
#include "net/base/upload_data.h"
+#include "printing/backend/print_backend.h"
#include "printing/native_metafile.h"
#include "printing/page_range.h"
@@ -646,4 +647,34 @@ void ParamTraits<base::PlatformFileInfo>::Log(
l->append(")");
}
+void ParamTraits<printing::PrinterCapsAndDefaults>::Write(
+ Message* m, const param_type& p) {
+ WriteParam(m, p.printer_capabilities);
+ WriteParam(m, p.caps_mime_type);
+ WriteParam(m, p.printer_defaults);
+ WriteParam(m, p.defaults_mime_type);
+}
+
+bool ParamTraits<printing::PrinterCapsAndDefaults>::Read(
+ const Message* m, void** iter, param_type* p) {
+ return
+ ReadParam(m, iter, &p->printer_capabilities) &&
+ ReadParam(m, iter, &p->caps_mime_type) &&
+ ReadParam(m, iter, &p->printer_defaults) &&
+ ReadParam(m, iter, &p->defaults_mime_type);
+}
+
+void ParamTraits<printing::PrinterCapsAndDefaults>::Log(
+ const param_type& p, std::string* l) {
+ l->append("(");
+ LogParam(p.printer_capabilities, l);
+ l->append(",");
+ LogParam(p.caps_mime_type, l);
+ l->append(",");
+ LogParam(p.printer_defaults, l);
+ l->append(",");
+ LogParam(p.defaults_mime_type, l);
+ l->append(")");
+}
+
} // namespace IPC
diff --git a/chrome/common/common_param_traits.h b/chrome/common/common_param_traits.h
index 5b0c07e..3638443 100644
--- a/chrome/common/common_param_traits.h
+++ b/chrome/common/common_param_traits.h
@@ -56,6 +56,7 @@ class UploadData;
namespace printing {
struct PageRange;
+struct PrinterCapsAndDefaults;
} // namespace printing
namespace webkit_glue {
@@ -334,6 +335,14 @@ struct SimilarTypeTraits<base::PlatformFileError> {
typedef int Type;
};
+template <>
+struct ParamTraits<printing::PrinterCapsAndDefaults> {
+ typedef printing::PrinterCapsAndDefaults param_type;
+ static void Write(Message* m, const param_type& p);
+ static bool Read(const Message* m, void** iter, param_type* r);
+ static void Log(const param_type& p, std::string* l);
+};
+
} // namespace IPC
#endif // CHROME_COMMON_COMMON_PARAM_TRAITS_H_
diff --git a/chrome/common/common_param_traits_unittest.cc b/chrome/common/common_param_traits_unittest.cc
index 6086c12..8446158 100644
--- a/chrome/common/common_param_traits_unittest.cc
+++ b/chrome/common/common_param_traits_unittest.cc
@@ -13,6 +13,7 @@
#include "googleurl/src/gurl.h"
#include "ipc/ipc_message.h"
#include "ipc/ipc_message_utils.h"
+#include "printing/backend/print_backend.h"
#include "printing/native_metafile.h"
#include "printing/page_range.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -264,3 +265,24 @@ TEST(IPCMessageTest, Metafile) {
}
#endif // defined(OS_WIN)
+// Tests printing::PrinterCapsAndDefaults serialization
+TEST(IPCMessageTest, PrinterCapsAndDefaults) {
+ printing::PrinterCapsAndDefaults input;
+ input.printer_capabilities = "Test Capabilities";
+ input.caps_mime_type = "text/plain";
+ input.printer_defaults = "Test Defaults";
+ input.defaults_mime_type = "text/plain";
+
+ IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
+ IPC::ParamTraits<printing::PrinterCapsAndDefaults>::Write(&msg, input);
+
+ printing::PrinterCapsAndDefaults output;
+ void* iter = NULL;
+ EXPECT_TRUE(IPC::ParamTraits<printing::PrinterCapsAndDefaults>::Read(
+ &msg, &iter, &output));
+ EXPECT_TRUE(input.printer_capabilities == output.printer_capabilities);
+ EXPECT_TRUE(input.caps_mime_type == output.caps_mime_type);
+ EXPECT_TRUE(input.printer_defaults == output.printer_defaults);
+ EXPECT_TRUE(input.defaults_mime_type == output.defaults_mime_type);
+}
+
diff --git a/chrome/common/utility_messages_internal.h b/chrome/common/utility_messages_internal.h
index 62d329a..5381155 100644
--- a/chrome/common/utility_messages_internal.h
+++ b/chrome/common/utility_messages_internal.h
@@ -8,6 +8,7 @@
#include "base/platform_file.h"
#include "gfx/rect.h"
#include "ipc/ipc_message_macros.h"
+#include "printing/backend/print_backend.h"
#include "printing/page_range.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -60,6 +61,13 @@ IPC_MESSAGE_CONTROL0(UtilityMsg_BatchMode_Started)
// Tells the utility process that it can shutdown.
IPC_MESSAGE_CONTROL0(UtilityMsg_BatchMode_Finished)
+// Tells the utility process to get capabilities and defaults for the specified
+// printer. Used on Windows to isolate the service process from printer driver
+// crashes by executing this in a separate process. This does not run in a
+// sandbox.
+IPC_MESSAGE_CONTROL1(UtilityMsg_GetPrinterCapsAndDefaults,
+ std::string /* printer name */)
+
//------------------------------------------------------------------------------
// Utility process host messages:
// These are messages from the utility process to the browser.
@@ -128,3 +136,15 @@ IPC_MESSAGE_CONTROL2(UtilityHostMsg_IDBKeysFromValuesAndKeyPath_Succeeded,
// IDBKeyPath.
IPC_MESSAGE_CONTROL1(UtilityHostMsg_IDBKeysFromValuesAndKeyPath_Failed,
int /* id */)
+
+// Reply when the utility process has succeeded in obtaining the printer
+// capabilities and defaults.
+IPC_MESSAGE_CONTROL2(UtilityHostMsg_GetPrinterCapsAndDefaults_Succeeded,
+ std::string /* printer name */,
+ printing::PrinterCapsAndDefaults)
+
+// Reply when the utility process has failed to obtain the printer
+// capabilities and defaults.
+IPC_MESSAGE_CONTROL1(UtilityHostMsg_GetPrinterCapsAndDefaults_Failed,
+ std::string /* printer name */)
+