OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "ppapi/host/ppapi_host.h" | 5 #include "ppapi/host/ppapi_host.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
9 #include "ppapi/host/host_factory.h" | 9 #include "ppapi/host/host_factory.h" |
10 #include "ppapi/host/host_message_context.h" | 10 #include "ppapi/host/host_message_context.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 HostMessageContext context(params, reply_msg); | 127 HostMessageContext context(params, reply_msg); |
128 HandleResourceCall(params, nested_msg, &context); | 128 HandleResourceCall(params, nested_msg, &context); |
129 } | 129 } |
130 | 130 |
131 void PpapiHost::HandleResourceCall( | 131 void PpapiHost::HandleResourceCall( |
132 const proxy::ResourceMessageCallParams& params, | 132 const proxy::ResourceMessageCallParams& params, |
133 const IPC::Message& nested_msg, | 133 const IPC::Message& nested_msg, |
134 HostMessageContext* context) { | 134 HostMessageContext* context) { |
135 ResourceHost* resource_host = GetResourceHost(params.pp_resource()); | 135 ResourceHost* resource_host = GetResourceHost(params.pp_resource()); |
136 if (resource_host) { | 136 if (resource_host) { |
| 137 // CAUTION: Handling the message may cause the destruction of this object. |
137 resource_host->HandleMessage(nested_msg, context); | 138 resource_host->HandleMessage(nested_msg, context); |
138 } else { | 139 } else { |
139 if (context->params.has_callback()) { | 140 if (context->params.has_callback()) { |
140 ReplyMessageContext reply_context = context->MakeReplyMessageContext(); | 141 ReplyMessageContext reply_context = context->MakeReplyMessageContext(); |
141 reply_context.params.set_result(PP_ERROR_BADRESOURCE); | 142 reply_context.params.set_result(PP_ERROR_BADRESOURCE); |
142 SendReply(reply_context, context->reply_msg); | 143 SendReply(reply_context, context->reply_msg); |
143 } | 144 } |
144 } | 145 } |
145 } | 146 } |
146 | 147 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 resources_.erase(found); | 196 resources_.erase(found); |
196 } | 197 } |
197 | 198 |
198 ResourceHost* PpapiHost::GetResourceHost(PP_Resource resource) const { | 199 ResourceHost* PpapiHost::GetResourceHost(PP_Resource resource) const { |
199 ResourceMap::const_iterator found = resources_.find(resource); | 200 ResourceMap::const_iterator found = resources_.find(resource); |
200 return found == resources_.end() ? NULL : found->second.get(); | 201 return found == resources_.end() ? NULL : found->second.get(); |
201 } | 202 } |
202 | 203 |
203 } // namespace host | 204 } // namespace host |
204 } // namespace ppapi | 205 } // namespace ppapi |
OLD | NEW |