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

Unified Diff: ppapi/cpp/dev/printing_dev.cc

Issue 10795051: Implement asynchronous interface/plumbing for GetDefaultPrintSettings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 5 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 | « ppapi/cpp/dev/printing_dev.h ('k') | ppapi/proxy/plugin_dispatcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/cpp/dev/printing_dev.cc
diff --git a/ppapi/cpp/dev/printing_dev.cc b/ppapi/cpp/dev/printing_dev.cc
index 8c307251fbac70261bd2fa8089976449852f8966..05477e83fa85490ee24c9df1108235dc69fa0059 100644
--- a/ppapi/cpp/dev/printing_dev.cc
+++ b/ppapi/cpp/dev/printing_dev.cc
@@ -5,6 +5,7 @@
#include "ppapi/cpp/dev/printing_dev.h"
#include "ppapi/c/dev/ppb_printing_dev.h"
+#include "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/instance_handle.h"
#include "ppapi/cpp/module.h"
@@ -16,6 +17,10 @@ namespace {
static const char kPPPPrintingInterface[] = PPP_PRINTING_DEV_INTERFACE;
+template <> const char* interface_name<PPB_Printing_Dev_0_7>() {
+ return PPB_PRINTING_DEV_INTERFACE_0_7;
+}
+
template <> const char* interface_name<PPB_Printing_Dev_0_6>() {
return PPB_PRINTING_DEV_INTERFACE_0_6;
}
@@ -88,7 +93,8 @@ Printing_Dev::~Printing_Dev() {
// static
bool Printing_Dev::IsAvailable() {
- return has_interface<PPB_Printing_Dev_0_6>();
+ return has_interface<PPB_Printing_Dev_0_7>() ||
+ has_interface<PPB_Printing_Dev_0_6>();
}
bool Printing_Dev::GetDefaultPrintSettings(
@@ -100,4 +106,23 @@ bool Printing_Dev::GetDefaultPrintSettings(
associated_instance_.pp_instance(), print_settings));
}
+int32_t Printing_Dev::GetDefaultPrintSettings(
viettrungluu 2012/07/24 00:44:35 This isn't a very good design, since Printing_Dev
viettrungluu 2012/07/24 01:08:37 (Probably using the callback-with-output solves th
+ PP_PrintSettings_Dev* print_settings,
+ const CompletionCallback& callback) const {
+ if (has_interface<PPB_Printing_Dev_0_6>()) {
viettrungluu 2012/07/24 00:44:35 These interface checks are in the wrong order.
+ bool success =
+ get_interface<PPB_Printing_Dev_0_6>()->GetDefaultPrintSettings(
viettrungluu 2012/07/24 00:44:35 You should convert from a PP_Bool to a bool proper
+ associated_instance_.pp_instance(), print_settings);
+ Module::Get()->core()->CallOnMainThread(0, callback,
+ success ? PP_OK : PP_ERROR);
viettrungluu 2012/07/24 00:44:35 PP_ERROR_FAILED
+ return PP_OK_COMPLETIONPENDING;
+ }
+ if (has_interface<PPB_Printing_Dev_0_7>()) {
+ return get_interface<PPB_Printing_Dev_0_7>()->GetDefaultPrintSettings(
+ associated_instance_.pp_instance(), print_settings,
+ callback.pp_completion_callback());
+ }
+ return PP_ERROR_FAILED;
+}
+
} // namespace pp
« no previous file with comments | « ppapi/cpp/dev/printing_dev.h ('k') | ppapi/proxy/plugin_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698