| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/shared_memory.h" | 14 #include "base/memory/shared_memory.h" |
| 15 #include "ppapi/c/pp_instance.h" | 15 #include "ppapi/c/pp_instance.h" |
| 16 #include "ppapi/c/pp_var.h" | 16 #include "ppapi/c/pp_var.h" |
| 17 #include "ppapi/proxy/ppapi_proxy_export.h" | 17 #include "ppapi/proxy/ppapi_proxy_export.h" |
| 18 #include "ppapi/proxy/raw_var_data.h" | 18 #include "ppapi/proxy/raw_var_data.h" |
| 19 #include "ppapi/proxy/serialized_handle.h" | 19 #include "ppapi/proxy/serialized_handle.h" |
| 20 #include "ppapi/proxy/serialized_structs.h" | 20 #include "ppapi/proxy/serialized_structs.h" |
| 21 #include "ppapi/proxy/var_serialization_rules.h" | 21 #include "ppapi/proxy/var_serialization_rules.h" |
| 22 | 22 |
| 23 namespace base { |
| 23 class PickleIterator; | 24 class PickleIterator; |
| 25 } |
| 24 | 26 |
| 25 namespace IPC { | 27 namespace IPC { |
| 26 class Message; | 28 class Message; |
| 27 } | 29 } |
| 28 | 30 |
| 29 namespace ppapi { | 31 namespace ppapi { |
| 30 namespace proxy { | 32 namespace proxy { |
| 31 | 33 |
| 32 class Dispatcher; | 34 class Dispatcher; |
| 33 class VarSerializationRules; | 35 class VarSerializationRules; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 void WriteToMessage(IPC::Message* m) const { | 82 void WriteToMessage(IPC::Message* m) const { |
| 81 inner_->WriteToMessage(m); | 83 inner_->WriteToMessage(m); |
| 82 } | 84 } |
| 83 // If ReadFromMessage has been called, WriteDataToMessage will write the var | 85 // If ReadFromMessage has been called, WriteDataToMessage will write the var |
| 84 // 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 |
| 85 // when converting handles for use in NaCl. | 87 // when converting handles for use in NaCl. |
| 86 void WriteDataToMessage(IPC::Message* m, | 88 void WriteDataToMessage(IPC::Message* m, |
| 87 const HandleWriter& handle_writer) const { | 89 const HandleWriter& handle_writer) const { |
| 88 inner_->WriteDataToMessage(m, handle_writer); | 90 inner_->WriteDataToMessage(m, handle_writer); |
| 89 } | 91 } |
| 90 bool ReadFromMessage(const IPC::Message* m, PickleIterator* iter) { | 92 bool ReadFromMessage(const IPC::Message* m, base::PickleIterator* iter) { |
| 91 return inner_->ReadFromMessage(m, iter); | 93 return inner_->ReadFromMessage(m, iter); |
| 92 } | 94 } |
| 93 | 95 |
| 94 bool is_valid_var() const { | 96 bool is_valid_var() const { |
| 95 return inner_->is_valid_var(); | 97 return inner_->is_valid_var(); |
| 96 } | 98 } |
| 97 | 99 |
| 98 // Returns the shared memory handles associated with this SerializedVar. | 100 // Returns the shared memory handles associated with this SerializedVar. |
| 99 std::vector<SerializedHandle*> GetHandles() const { | 101 std::vector<SerializedHandle*> GetHandles() const { |
| 100 return inner_->GetHandles(); | 102 return inner_->GetHandles(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 void SetVar(PP_Var var); | 138 void SetVar(PP_Var var); |
| 137 void SetInstance(PP_Instance instance); | 139 void SetInstance(PP_Instance instance); |
| 138 | 140 |
| 139 // For the SerializedVarTestConstructor, this writes the Var value as if | 141 // For the SerializedVarTestConstructor, this writes the Var value as if |
| 140 // it was just received off the wire, without any serialization rules. | 142 // it was just received off the wire, without any serialization rules. |
| 141 void ForceSetVarValueForTest(PP_Var value); | 143 void ForceSetVarValueForTest(PP_Var value); |
| 142 | 144 |
| 143 void WriteToMessage(IPC::Message* m) const; | 145 void WriteToMessage(IPC::Message* m) const; |
| 144 void WriteDataToMessage(IPC::Message* m, | 146 void WriteDataToMessage(IPC::Message* m, |
| 145 const HandleWriter& handle_writer) const; | 147 const HandleWriter& handle_writer) const; |
| 146 bool ReadFromMessage(const IPC::Message* m, PickleIterator* iter); | 148 bool ReadFromMessage(const IPC::Message* m, base::PickleIterator* iter); |
| 147 | 149 |
| 148 // Sets the cleanup mode. See the CleanupMode enum below. | 150 // Sets the cleanup mode. See the CleanupMode enum below. |
| 149 void SetCleanupModeToEndSendPassRef(); | 151 void SetCleanupModeToEndSendPassRef(); |
| 150 void SetCleanupModeToEndReceiveCallerOwned(); | 152 void SetCleanupModeToEndReceiveCallerOwned(); |
| 151 | 153 |
| 152 private: | 154 private: |
| 153 enum CleanupMode { | 155 enum CleanupMode { |
| 154 // The serialized var won't do anything special in the destructor | 156 // The serialized var won't do anything special in the destructor |
| 155 // (default). | 157 // (default). |
| 156 CLEANUP_NONE, | 158 CLEANUP_NONE, |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 public: | 495 public: |
| 494 explicit SerializedVarTestReader(const SerializedVar& var); | 496 explicit SerializedVarTestReader(const SerializedVar& var); |
| 495 | 497 |
| 496 PP_Var GetVar() const { return inner_->GetVar(); } | 498 PP_Var GetVar() const { return inner_->GetVar(); } |
| 497 }; | 499 }; |
| 498 | 500 |
| 499 } // namespace proxy | 501 } // namespace proxy |
| 500 } // namespace ppapi | 502 } // namespace ppapi |
| 501 | 503 |
| 502 #endif // PPAPI_PROXY_SERIALIZED_VAR_H_ | 504 #endif // PPAPI_PROXY_SERIALIZED_VAR_H_ |
| OLD | NEW |