| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 const IPC::Message& nested_msg) { | 84 const IPC::Message& nested_msg) { |
| 85 HostMessageContext context(params); | 85 HostMessageContext context(params); |
| 86 proxy::ResourceMessageReplyParams reply_params(params.pp_resource(), | 86 proxy::ResourceMessageReplyParams reply_params(params.pp_resource(), |
| 87 params.sequence()); | 87 params.sequence()); |
| 88 | 88 |
| 89 ResourceHost* resource_host = GetResourceHost(params.pp_resource()); | 89 ResourceHost* resource_host = GetResourceHost(params.pp_resource()); |
| 90 if (resource_host) { | 90 if (resource_host) { |
| 91 reply_params.set_result(resource_host->OnResourceMessageReceived( | 91 reply_params.set_result(resource_host->OnResourceMessageReceived( |
| 92 nested_msg, &context)); | 92 nested_msg, &context)); |
| 93 | 93 |
| 94 // Sanity check the resource handler. | 94 // Sanity check the resource handler. Note if the result was |
| 95 // "completion pending" the resource host may have already sent the reply. |
| 95 if (reply_params.result() == PP_OK_COMPLETIONPENDING) { | 96 if (reply_params.result() == PP_OK_COMPLETIONPENDING) { |
| 96 // Message handler should have only returned a pending result if a | 97 // Message handler should have only returned a pending result if a |
| 97 // response will be sent to the plugin. | 98 // response will be sent to the plugin. |
| 98 DCHECK(params.has_callback()); | 99 DCHECK(params.has_callback()); |
| 99 | 100 |
| 100 // Message handler should not have written a message to be returned if | 101 // Message handler should not have written a message to be returned if |
| 101 // completion is pending. | 102 // completion is pending. |
| 102 DCHECK(context.reply_msg.type() == 0); | 103 DCHECK(context.reply_msg.type() == 0); |
| 103 } else if (!params.has_callback()) { | 104 } else if (!params.has_callback()) { |
| 104 // When no response is required, the message handler should not have | 105 // When no response is required, the message handler should not have |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 resources_.erase(found); | 141 resources_.erase(found); |
| 141 } | 142 } |
| 142 | 143 |
| 143 ResourceHost* PpapiHost::GetResourceHost(PP_Resource resource) { | 144 ResourceHost* PpapiHost::GetResourceHost(PP_Resource resource) { |
| 144 ResourceMap::iterator found = resources_.find(resource); | 145 ResourceMap::iterator found = resources_.find(resource); |
| 145 return found == resources_.end() ? NULL : found->second.get(); | 146 return found == resources_.end() ? NULL : found->second.get(); |
| 146 } | 147 } |
| 147 | 148 |
| 148 } // namespace host | 149 } // namespace host |
| 149 } // namespace ppapi | 150 } // namespace ppapi |
| OLD | NEW |