| 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_SERIALIZED_VAR_H_ | 5 #ifndef PPAPI_PROXY_SERIALIZED_VAR_H_ |
| 6 #define PPAPI_PROXY_SERIALIZED_VAR_H_ | 6 #define PPAPI_PROXY_SERIALIZED_VAR_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 // want to modify that to convert strings and do refcounting. | 74 // want to modify that to convert strings and do refcounting. |
| 75 // | 75 // |
| 76 // The helper classes used for accessing the SerializedVar have more reasonable | 76 // The helper classes used for accessing the SerializedVar have more reasonable |
| 77 // behavior and will enforce that you don't do stupid things. | 77 // behavior and will enforce that you don't do stupid things. |
| 78 class PPAPI_PROXY_EXPORT SerializedVar { | 78 class PPAPI_PROXY_EXPORT SerializedVar { |
| 79 public: | 79 public: |
| 80 SerializedVar(); | 80 SerializedVar(); |
| 81 ~SerializedVar(); | 81 ~SerializedVar(); |
| 82 | 82 |
| 83 // Backend implementation for IPC::ParamTraits<SerializedVar>. | 83 // Backend implementation for IPC::ParamTraits<SerializedVar>. |
| 84 void WriteToMessage(IPC::Message* m) const { | 84 void WriteToMessage(base::Pickle* m) const { inner_->WriteToMessage(m); } |
| 85 inner_->WriteToMessage(m); | |
| 86 } | |
| 87 // If ReadFromMessage has been called, WriteDataToMessage will write the var | 85 // If ReadFromMessage has been called, WriteDataToMessage will write the var |
| 88 // that has been read from ReadFromMessage back to a message. This is used | 86 // that has been read from ReadFromMessage back to a message. This is used |
| 89 // when converting handles for use in NaCl. | 87 // when converting handles for use in NaCl. |
| 90 void WriteDataToMessage(IPC::Message* m, | 88 void WriteDataToMessage(base::Pickle* m, |
| 91 const HandleWriter& handle_writer) const { | 89 const HandleWriter& handle_writer) const { |
| 92 inner_->WriteDataToMessage(m, handle_writer); | 90 inner_->WriteDataToMessage(m, handle_writer); |
| 93 } | 91 } |
| 94 bool ReadFromMessage(const IPC::Message* m, base::PickleIterator* iter) { | 92 bool ReadFromMessage(const base::Pickle* m, base::PickleIterator* iter) { |
| 95 return inner_->ReadFromMessage(m, iter); | 93 return inner_->ReadFromMessage(m, iter); |
| 96 } | 94 } |
| 97 | 95 |
| 98 bool is_valid_var() const { | 96 bool is_valid_var() const { |
| 99 return inner_->is_valid_var(); | 97 return inner_->is_valid_var(); |
| 100 } | 98 } |
| 101 | 99 |
| 102 // Returns the shared memory handles associated with this SerializedVar. | 100 // Returns the shared memory handles associated with this SerializedVar. |
| 103 std::vector<SerializedHandle*> GetHandles() const { | 101 std::vector<SerializedHandle*> GetHandles() const { |
| 104 return inner_->GetHandles(); | 102 return inner_->GetHandles(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 135 |
| 138 // See outer class's declarations above. | 136 // See outer class's declarations above. |
| 139 PP_Var GetVar(); | 137 PP_Var GetVar(); |
| 140 void SetVar(PP_Var var); | 138 void SetVar(PP_Var var); |
| 141 void SetInstance(PP_Instance instance); | 139 void SetInstance(PP_Instance instance); |
| 142 | 140 |
| 143 // For the SerializedVarTestConstructor, this writes the Var value as if | 141 // For the SerializedVarTestConstructor, this writes the Var value as if |
| 144 // it was just received off the wire, without any serialization rules. | 142 // it was just received off the wire, without any serialization rules. |
| 145 void ForceSetVarValueForTest(PP_Var value); | 143 void ForceSetVarValueForTest(PP_Var value); |
| 146 | 144 |
| 147 void WriteToMessage(IPC::Message* m) const; | 145 void WriteToMessage(base::Pickle* m) const; |
| 148 void WriteDataToMessage(IPC::Message* m, | 146 void WriteDataToMessage(base::Pickle* m, |
| 149 const HandleWriter& handle_writer) const; | 147 const HandleWriter& handle_writer) const; |
| 150 bool ReadFromMessage(const IPC::Message* m, base::PickleIterator* iter); | 148 bool ReadFromMessage(const base::Pickle* m, base::PickleIterator* iter); |
| 151 | 149 |
| 152 // Sets the cleanup mode. See the CleanupMode enum below. | 150 // Sets the cleanup mode. See the CleanupMode enum below. |
| 153 void SetCleanupModeToEndSendPassRef(); | 151 void SetCleanupModeToEndSendPassRef(); |
| 154 void SetCleanupModeToEndReceiveCallerOwned(); | 152 void SetCleanupModeToEndReceiveCallerOwned(); |
| 155 | 153 |
| 156 private: | 154 private: |
| 157 enum CleanupMode { | 155 enum CleanupMode { |
| 158 // The serialized var won't do anything special in the destructor | 156 // The serialized var won't do anything special in the destructor |
| 159 // (default). | 157 // (default). |
| 160 CLEANUP_NONE, | 158 CLEANUP_NONE, |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 public: | 495 public: |
| 498 explicit SerializedVarTestReader(const SerializedVar& var); | 496 explicit SerializedVarTestReader(const SerializedVar& var); |
| 499 | 497 |
| 500 PP_Var GetVar() const { return inner_->GetVar(); } | 498 PP_Var GetVar() const { return inner_->GetVar(); } |
| 501 }; | 499 }; |
| 502 | 500 |
| 503 } // namespace proxy | 501 } // namespace proxy |
| 504 } // namespace ppapi | 502 } // namespace ppapi |
| 505 | 503 |
| 506 #endif // PPAPI_PROXY_SERIALIZED_VAR_H_ | 504 #endif // PPAPI_PROXY_SERIALIZED_VAR_H_ |
| OLD | NEW |