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

Side by Side Diff: chrome/renderer/pepper/pepper_extensions_common_host.cc

Issue 231883002: Refactor some ResourceMessageReply usages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase after great git cl format event. Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/pepper/pepper_extensions_common_host.h" 5 #include "chrome/renderer/pepper/pepper_extensions_common_host.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/renderer/extensions/chrome_v8_context.h" 10 #include "chrome/renderer/extensions/chrome_v8_context.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 const IPC::Message& msg, 77 const IPC::Message& msg,
78 ppapi::host::HostMessageContext* context) { 78 ppapi::host::HostMessageContext* context) {
79 IPC_BEGIN_MESSAGE_MAP(PepperExtensionsCommonHost, msg) 79 IPC_BEGIN_MESSAGE_MAP(PepperExtensionsCommonHost, msg)
80 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_ExtensionsCommon_Post, OnPost) 80 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_ExtensionsCommon_Post, OnPost)
81 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_ExtensionsCommon_Call, OnCall) 81 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_ExtensionsCommon_Call, OnCall)
82 IPC_END_MESSAGE_MAP() 82 IPC_END_MESSAGE_MAP()
83 return PP_ERROR_FAILED; 83 return PP_ERROR_FAILED;
84 } 84 }
85 85
86 void PepperExtensionsCommonHost::OnResponseReceived( 86 void PepperExtensionsCommonHost::OnResponseReceived(
87 scoped_ptr<ppapi::host::ReplyMessageContext> context, 87 ppapi::host::ReplyMessageContext reply_context,
88 bool success, 88 bool success,
89 const base::ListValue& response, 89 const base::ListValue& response,
90 const std::string& /* error */) { 90 const std::string& /* error */) {
91 context->params.set_result(success ? PP_OK : PP_ERROR_FAILED); 91 reply_context.params.set_result(success ? PP_OK : PP_ERROR_FAILED);
92 SendReply(*context, PpapiPluginMsg_ExtensionsCommon_CallReply(response)); 92 SendReply(reply_context, PpapiPluginMsg_ExtensionsCommon_CallReply(response));
93 } 93 }
94 94
95 int32_t PepperExtensionsCommonHost::OnPost( 95 int32_t PepperExtensionsCommonHost::OnPost(
96 ppapi::host::HostMessageContext* context, 96 ppapi::host::HostMessageContext* context,
97 const std::string& request_name, 97 const std::string& request_name,
98 const base::ListValue& args) { 98 const base::ListValue& args) {
99 std::string error; 99 std::string error;
100 bool success = pepper_request_proxy_->StartRequest( 100 bool success = pepper_request_proxy_->StartRequest(
101 base::Bind(&DoNothing), request_name, args, &error); 101 base::Bind(&DoNothing), request_name, args, &error);
102 return success ? PP_OK : PP_ERROR_FAILED; 102 return success ? PP_OK : PP_ERROR_FAILED;
103 } 103 }
104 104
105 int32_t PepperExtensionsCommonHost::OnCall( 105 int32_t PepperExtensionsCommonHost::OnCall(
106 ppapi::host::HostMessageContext* context, 106 ppapi::host::HostMessageContext* context,
107 const std::string& request_name, 107 const std::string& request_name,
108 const base::ListValue& args) { 108 const base::ListValue& args) {
109 std::string error; 109 std::string error;
110 scoped_ptr<ppapi::host::ReplyMessageContext> message_context(
111 new ppapi::host::ReplyMessageContext(context->MakeReplyMessageContext()));
112 bool success = pepper_request_proxy_->StartRequest( 110 bool success = pepper_request_proxy_->StartRequest(
113 base::Bind(&PepperExtensionsCommonHost::OnResponseReceived, 111 base::Bind(&PepperExtensionsCommonHost::OnResponseReceived,
114 weak_factory_.GetWeakPtr(), 112 weak_factory_.GetWeakPtr(),
115 base::Passed(&message_context)), 113 context->MakeReplyMessageContext()),
116 request_name, 114 request_name,
117 args, 115 args,
118 &error); 116 &error);
119 return success ? PP_OK_COMPLETIONPENDING : PP_ERROR_FAILED; 117 return success ? PP_OK_COMPLETIONPENDING : PP_ERROR_FAILED;
120 } 118 }
OLDNEW
« no previous file with comments | « chrome/renderer/pepper/pepper_extensions_common_host.h ('k') | content/renderer/pepper/pepper_audio_input_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698