cc: Added inline to Tile::IsReadyToDraw
[chromium-blink-merge.git] / ppapi / proxy / printing_resource.cc
blobd9be3b7430194e8866d401f3e5f093ce1b23b67d
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ppapi/proxy/printing_resource.h"
7 #include "base/bind.h"
8 #include "ipc/ipc_message.h"
9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/proxy/dispatch_reply_message.h"
11 #include "ppapi/proxy/ppapi_messages.h"
13 namespace ppapi {
14 namespace proxy {
16 PrintingResource::PrintingResource(Connection connection, PP_Instance instance)
17 : PluginResource(connection, instance) {
20 PrintingResource::~PrintingResource() {
23 thunk::PPB_Printing_API* PrintingResource::AsPPB_Printing_API() {
24 return this;
27 int32_t PrintingResource::GetDefaultPrintSettings(
28 PP_PrintSettings_Dev* print_settings,
29 scoped_refptr<TrackedCallback> callback) {
30 if (!print_settings)
31 return PP_ERROR_BADARGUMENT;
33 if (!sent_create_to_browser())
34 SendCreate(BROWSER, PpapiHostMsg_Printing_Create());
36 Call<PpapiPluginMsg_Printing_GetDefaultPrintSettingsReply>(
37 BROWSER,
38 PpapiHostMsg_Printing_GetDefaultPrintSettings(),
39 base::Bind(&PrintingResource::OnPluginMsgGetDefaultPrintSettingsReply,
40 this, print_settings, callback));
41 return PP_OK_COMPLETIONPENDING;
44 void PrintingResource::OnPluginMsgGetDefaultPrintSettingsReply(
45 PP_PrintSettings_Dev* settings_out,
46 scoped_refptr<TrackedCallback> callback,
47 const ResourceMessageReplyParams& params,
48 const PP_PrintSettings_Dev& settings) {
49 if (params.result() == PP_OK)
50 *settings_out = settings;
52 // Notify the plugin of the new data.
53 callback->Run(params.result());
54 // DANGER: May delete |this|!
57 } // namespace proxy
58 } // namespace ppapi