| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #ifndef SerializedScriptValue_h | 31 #ifndef SerializedScriptValue_h |
| 32 #define SerializedScriptValue_h | 32 #define SerializedScriptValue_h |
| 33 | 33 |
| 34 #include "ScriptValue.h" | 34 #include "ScriptValue.h" |
| 35 #include <v8.h> | 35 #include <v8.h> |
| 36 #include <wtf/Threading.h> | 36 #include <wtf/Threading.h> |
| 37 | 37 |
| 38 namespace WebCore { | 38 namespace WebCore { |
| 39 | 39 |
| 40 class MessagePort; | 40 class MessagePort; |
| 41 class ScriptValueDeserializer; |
| 42 class ScriptValueSerializer; |
| 41 | 43 |
| 42 typedef Vector<RefPtr<MessagePort>, 1> MessagePortArray; | 44 typedef Vector<RefPtr<MessagePort>, 1> MessagePortArray; |
| 43 | 45 |
| 44 class SerializedScriptValue : public ThreadSafeRefCounted<SerializedScriptValue>
{ | 46 class SerializedScriptValue : public ThreadSafeRefCounted<SerializedScriptValue>
{ |
| 45 public: | 47 public: |
| 46 static void deserializeAndSetProperty(v8::Handle<v8::Object>, const char* pr
opertyName, | 48 static void deserializeAndSetProperty(v8::Handle<v8::Object>, const char* pr
opertyName, |
| 47 v8::PropertyAttribute, SerializedScrip
tValue*); | 49 v8::PropertyAttribute, SerializedScrip
tValue*); |
| 48 static void deserializeAndSetProperty(v8::Handle<v8::Object>, const char* pr
opertyName, | 50 static void deserializeAndSetProperty(v8::Handle<v8::Object>, const char* pr
opertyName, |
| 49 v8::PropertyAttribute, PassRefPtr<Seri
alizedScriptValue>); | 51 v8::PropertyAttribute, PassRefPtr<Seri
alizedScriptValue>); |
| 50 | 52 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 63 static SerializedScriptValue* undefinedValue(); | 65 static SerializedScriptValue* undefinedValue(); |
| 64 | 66 |
| 65 PassRefPtr<SerializedScriptValue> release(); | 67 PassRefPtr<SerializedScriptValue> release(); |
| 66 | 68 |
| 67 String toWireString() const { return m_data; } | 69 String toWireString() const { return m_data; } |
| 68 | 70 |
| 69 // Deserializes the value (in the current context). Returns a null value in | 71 // Deserializes the value (in the current context). Returns a null value in |
| 70 // case of failure. | 72 // case of failure. |
| 71 v8::Handle<v8::Value> deserialize(MessagePortArray* = 0); | 73 v8::Handle<v8::Value> deserialize(MessagePortArray* = 0); |
| 72 | 74 |
| 75 static PassRefPtr<SerializedScriptValue> create(ScriptValueSerializer*); |
| 76 bool deserialize(ScriptValueDeserializer*); |
| 77 |
| 73 private: | 78 private: |
| 74 enum StringDataMode { | 79 enum StringDataMode { |
| 75 StringValue, | 80 StringValue, |
| 76 WireData | 81 WireData |
| 77 }; | 82 }; |
| 78 | 83 |
| 79 SerializedScriptValue(); | 84 SerializedScriptValue(); |
| 80 SerializedScriptValue(v8::Handle<v8::Value>, MessagePortArray*, bool& didThr
ow); | 85 SerializedScriptValue(v8::Handle<v8::Value>, MessagePortArray*, bool& didThr
ow); |
| 81 explicit SerializedScriptValue(const String& wireData); | 86 explicit SerializedScriptValue(const String& wireData); |
| 82 | 87 |
| 83 String m_data; | 88 String m_data; |
| 84 }; | 89 }; |
| 85 | 90 |
| 86 } // namespace WebCore | 91 } // namespace WebCore |
| 87 | 92 |
| 88 #endif // SerializedScriptValue_h | 93 #endif // SerializedScriptValue_h |
| OLD | NEW |