Chromium Code Reviews| 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 #ifndef PPAPI_PROXY_PLUGIN_VAR_SERIALIZATION_RULES_H_ | 5 #ifndef PPAPI_PROXY_PLUGIN_VAR_SERIALIZATION_RULES_H_ |
| 6 #define PPAPI_PROXY_PLUGIN_VAR_SERIALIZATION_RULES_H_ | 6 #define PPAPI_PROXY_PLUGIN_VAR_SERIALIZATION_RULES_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/weak_ptr.h" | |
| 9 #include "ppapi/proxy/var_serialization_rules.h" | 10 #include "ppapi/proxy/var_serialization_rules.h" |
| 10 | 11 |
| 11 namespace ppapi { | 12 namespace ppapi { |
| 12 namespace proxy { | 13 namespace proxy { |
| 13 | 14 |
| 15 class PluginDispatcher; | |
| 14 class PluginVarTracker; | 16 class PluginVarTracker; |
| 15 | 17 |
| 16 // Implementation of the VarSerialization interface for the plugin. | 18 // Implementation of the VarSerializationRules interface for the plugin. |
| 17 class PluginVarSerializationRules : public VarSerializationRules { | 19 class PluginVarSerializationRules : public VarSerializationRules { |
| 18 public: | 20 public: |
| 19 // This class will use the given non-owning pointer to the var tracker to | 21 // This class will use the given non-owning pointer to the var tracker to |
| 20 // handle object refcounting and string conversion. | 22 // handle object refcounting and string conversion. |
| 21 PluginVarSerializationRules(); | 23 explicit PluginVarSerializationRules( |
| 24 const base::WeakPtr<PluginDispatcher>& dispatcher); | |
| 22 ~PluginVarSerializationRules(); | 25 ~PluginVarSerializationRules(); |
| 23 | 26 |
| 24 // VarSerialization implementation. | 27 // VarSerialization implementation. |
| 25 virtual PP_Var SendCallerOwned(const PP_Var& var); | 28 virtual PP_Var SendCallerOwned(const PP_Var& var); |
| 26 virtual PP_Var BeginReceiveCallerOwned(const PP_Var& var, | 29 virtual PP_Var BeginReceiveCallerOwned(const PP_Var& var); |
| 27 Dispatcher* dispatcher); | |
| 28 virtual void EndReceiveCallerOwned(const PP_Var& var); | 30 virtual void EndReceiveCallerOwned(const PP_Var& var); |
| 29 virtual PP_Var ReceivePassRef(const PP_Var& var, Dispatcher* dispatcher); | 31 virtual PP_Var ReceivePassRef(const PP_Var& var); |
| 30 virtual PP_Var BeginSendPassRef(const PP_Var& var); | 32 virtual PP_Var BeginSendPassRef(const PP_Var& var); |
| 31 virtual void EndSendPassRef(const PP_Var& var, Dispatcher* dispatcher); | 33 virtual void EndSendPassRef(const PP_Var& var); |
| 32 virtual void ReleaseObjectRef(const PP_Var& var); | 34 virtual void ReleaseObjectRef(const PP_Var& var); |
| 33 | 35 |
| 34 private: | 36 private: |
| 35 PluginVarTracker* var_tracker_; | 37 PluginVarTracker* var_tracker_; |
| 36 | 38 |
| 39 // In most cases, |dispatcher_| won't be NULL. | |
|
brettw
2012/03/09 21:57:22
Can you make it clear here the you should check th
yzshen1
2012/03/09 22:05:48
Done.
| |
| 40 // One scenario that it becomes NULL: A SerializedVar holds a ref to this | |
| 41 // object, and a sync message is issued. While waiting for the reply to the | |
| 42 // sync message, some incoming message causes the dispatcher to be destroyed. | |
| 43 // If that happens, we may leak references to object vars. Considering that | |
| 44 // scripting has been deprecated, this may not be a big issue. | |
| 45 base::WeakPtr<PluginDispatcher> dispatcher_; | |
| 46 | |
| 37 DISALLOW_COPY_AND_ASSIGN(PluginVarSerializationRules); | 47 DISALLOW_COPY_AND_ASSIGN(PluginVarSerializationRules); |
| 38 }; | 48 }; |
| 39 | 49 |
| 40 } // namespace proxy | 50 } // namespace proxy |
| 41 } // namespace ppapi | 51 } // namespace ppapi |
| 42 | 52 |
| 43 #endif // PPAPI_PROXY_PLUGIN_VAR_SERIALIZATION_RULES_H_ | 53 #endif // PPAPI_PROXY_PLUGIN_VAR_SERIALIZATION_RULES_H_ |
| OLD | NEW |