| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/proxy/plugin_var_serialization_rules.h" | 5 #include "ppapi/proxy/plugin_var_serialization_rules.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ppapi/proxy/plugin_dispatcher.h" | 8 #include "ppapi/proxy/plugin_dispatcher.h" |
| 9 #include "ppapi/proxy/plugin_globals.h" | 9 #include "ppapi/proxy/plugin_globals.h" |
| 10 #include "ppapi/proxy/plugin_resource_tracker.h" | 10 #include "ppapi/proxy/plugin_resource_tracker.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 NOTREACHED() << "Trying to send unknown string over IPC."; | 37 NOTREACHED() << "Trying to send unknown string over IPC."; |
| 38 } | 38 } |
| 39 return var; | 39 return var; |
| 40 } | 40 } |
| 41 | 41 |
| 42 PP_Var PluginVarSerializationRules::BeginReceiveCallerOwned( | 42 PP_Var PluginVarSerializationRules::BeginReceiveCallerOwned( |
| 43 const PP_Var& var, | 43 const PP_Var& var, |
| 44 const std::string* str_val, | 44 const std::string* str_val, |
| 45 Dispatcher* dispatcher) { | 45 Dispatcher* dispatcher) { |
| 46 if (var.type == PP_VARTYPE_STRING) | 46 if (var.type == PP_VARTYPE_STRING) |
| 47 return StringVar::StringToPPVar(0, *str_val); | 47 return StringVar::StringToPPVar(*str_val); |
| 48 | 48 |
| 49 if (var.type == PP_VARTYPE_OBJECT) { | 49 if (var.type == PP_VARTYPE_OBJECT) { |
| 50 DCHECK(dispatcher->IsPlugin()); | 50 DCHECK(dispatcher->IsPlugin()); |
| 51 return var_tracker_->TrackObjectWithNoReference( | 51 return var_tracker_->TrackObjectWithNoReference( |
| 52 var, static_cast<PluginDispatcher*>(dispatcher)); | 52 var, static_cast<PluginDispatcher*>(dispatcher)); |
| 53 } | 53 } |
| 54 | 54 |
| 55 return var; | 55 return var; |
| 56 } | 56 } |
| 57 | 57 |
| 58 void PluginVarSerializationRules::EndReceiveCallerOwned(const PP_Var& var) { | 58 void PluginVarSerializationRules::EndReceiveCallerOwned(const PP_Var& var) { |
| 59 if (var.type == PP_VARTYPE_STRING) { | 59 if (var.type == PP_VARTYPE_STRING) { |
| 60 // Destroy the string BeginReceiveCallerOwned created above. | 60 // Destroy the string BeginReceiveCallerOwned created above. |
| 61 var_tracker_->ReleaseVar(var); | 61 var_tracker_->ReleaseVar(var); |
| 62 } else if (var.type == PP_VARTYPE_OBJECT) { | 62 } else if (var.type == PP_VARTYPE_OBJECT) { |
| 63 var_tracker_->StopTrackingObjectWithNoReference(var); | 63 var_tracker_->StopTrackingObjectWithNoReference(var); |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 PP_Var PluginVarSerializationRules::ReceivePassRef(const PP_Var& var, | 67 PP_Var PluginVarSerializationRules::ReceivePassRef(const PP_Var& var, |
| 68 const std::string& str_val, | 68 const std::string& str_val, |
| 69 Dispatcher* dispatcher) { | 69 Dispatcher* dispatcher) { |
| 70 if (var.type == PP_VARTYPE_STRING) | 70 if (var.type == PP_VARTYPE_STRING) |
| 71 return StringVar::StringToPPVar(0, str_val); | 71 return StringVar::StringToPPVar(str_val); |
| 72 | 72 |
| 73 // Overview of sending an object with "pass ref" from the browser to the | 73 // Overview of sending an object with "pass ref" from the browser to the |
| 74 // plugin: | 74 // plugin: |
| 75 // Example 1 Example 2 | 75 // Example 1 Example 2 |
| 76 // Plugin Browser Plugin Browser | 76 // Plugin Browser Plugin Browser |
| 77 // Before send 3 2 0 1 | 77 // Before send 3 2 0 1 |
| 78 // Browser calls BeginSendPassRef 3 2 0 1 | 78 // Browser calls BeginSendPassRef 3 2 0 1 |
| 79 // Plugin calls ReceivePassRef 4 1 1 1 | 79 // Plugin calls ReceivePassRef 4 1 1 1 |
| 80 // Browser calls EndSendPassRef 4 1 1 1 | 80 // Browser calls EndSendPassRef 4 1 1 1 |
| 81 // | 81 // |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 static_cast<PluginDispatcher*>(dispatcher), var); | 138 static_cast<PluginDispatcher*>(dispatcher), var); |
| 139 } | 139 } |
| 140 } | 140 } |
| 141 | 141 |
| 142 void PluginVarSerializationRules::ReleaseObjectRef(const PP_Var& var) { | 142 void PluginVarSerializationRules::ReleaseObjectRef(const PP_Var& var) { |
| 143 var_tracker_->ReleaseVar(var); | 143 var_tracker_->ReleaseVar(var); |
| 144 } | 144 } |
| 145 | 145 |
| 146 } // namespace proxy | 146 } // namespace proxy |
| 147 } // namespace ppapi | 147 } // namespace ppapi |
| OLD | NEW |