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/resource_message_handler.h" | 5 #include "ppapi/host/resource_message_handler.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ipc/ipc_message.h" | 8 #include "ipc/ipc_message.h" |
9 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
10 #include "ppapi/host/host_message_context.h" | 10 #include "ppapi/host/host_message_context.h" |
11 | 11 |
12 namespace ppapi { | 12 namespace ppapi { |
13 namespace host { | 13 namespace host { |
14 | 14 |
15 ResourceMessageHandler::ResourceMessageHandler() { | 15 ResourceMessageHandler::ResourceMessageHandler() { |
16 } | 16 } |
17 | 17 |
18 ResourceMessageHandler::~ResourceMessageHandler() { | 18 ResourceMessageHandler::~ResourceMessageHandler() { |
19 } | 19 } |
20 | 20 |
21 void ResourceMessageHandler::RunMessageHandlerAndReply( | 21 void ResourceMessageHandler::RunMessageHandlerAndReply( |
22 const IPC::Message& msg, | 22 const IPC::Message& msg, |
23 HostMessageContext* context) { | 23 HostMessageContext* context) { |
24 ReplyMessageContext reply_context = context->MakeReplyMessageContext(); | 24 ReplyMessageContext reply_context = context->MakeReplyMessageContext(); |
25 // CAUTION: Handling the message may cause the destruction of this object. If | |
26 // PP_OK_COMPLETIONPENDING is returned, we should assume that we might have | |
yzshen1
2012/12/14 19:13:14
Why PP_OK_COMPLETIONPENDING is the only possible o
raymes
2012/12/17 04:07:57
Right now I'm making the assumption that if the me
yzshen1
2012/12/17 05:02:23
This assumption doesn't look very intuitive. Can i
raymes
2012/12/17 05:11:00
I tried to make it clear in the comment above but
yzshen1
2012/12/17 05:19:37
If my understanding is correct, it is not that it
| |
27 // been destroyed after this. | |
25 reply_context.params.set_result(OnResourceMessageReceived(msg, context)); | 28 reply_context.params.set_result(OnResourceMessageReceived(msg, context)); |
26 | 29 |
27 // Sanity check the resource handler. Note if the result was | 30 // Sanity check the resource handler. Note if the result was |
28 // "completion pending" the resource host may have already sent the reply. | 31 // "completion pending" the resource host may have already sent the reply. |
29 if (reply_context.params.result() == PP_OK_COMPLETIONPENDING) { | 32 if (reply_context.params.result() == PP_OK_COMPLETIONPENDING) { |
30 // Message handler should have only returned a pending result if a | 33 // Message handler should have only returned a pending result if a |
31 // response will be sent to the plugin. | 34 // response will be sent to the plugin. |
32 DCHECK(context->params.has_callback()); | 35 DCHECK(context->params.has_callback()); |
33 | 36 |
34 // Message handler should not have written a message to be returned if | 37 // Message handler should not have written a message to be returned if |
(...skipping 16 matching lines...) Expand all Loading... | |
51 } | 54 } |
52 | 55 |
53 int32_t ResourceMessageHandler::OnResourceMessageReceived( | 56 int32_t ResourceMessageHandler::OnResourceMessageReceived( |
54 const IPC::Message& msg, | 57 const IPC::Message& msg, |
55 HostMessageContext* context) { | 58 HostMessageContext* context) { |
56 return PP_ERROR_NOTSUPPORTED; | 59 return PP_ERROR_NOTSUPPORTED; |
57 } | 60 } |
58 | 61 |
59 } // namespace host | 62 } // namespace host |
60 } // namespace ppapi | 63 } // namespace ppapi |
OLD | NEW |