Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: third_party/WebKit/Source/bindings/modules/v8/V8ServiceWorkerMessageEventInternal.h

Issue 2755383004: Encapsulate optional SerializedScriptValue serialize/deserialize parameters. (Closed)
Patch Set: fuzzer Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 V8ServiceWorkerMessageEventInternal_h 5 #ifndef V8ServiceWorkerMessageEventInternal_h
6 #define V8ServiceWorkerMessageEventInternal_h 6 #define V8ServiceWorkerMessageEventInternal_h
7 7
8 #include "bindings/core/v8/SerializedScriptValue.h" 8 #include "bindings/core/v8/SerializedScriptValue.h"
9 #include "bindings/core/v8/SerializedScriptValueFactory.h" 9 #include "bindings/core/v8/SerializedScriptValueFactory.h"
10 #include "bindings/core/v8/V8PrivateProperty.h" 10 #include "bindings/core/v8/V8PrivateProperty.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 v8::Local<v8::Value> result = 80 v8::Local<v8::Value> result =
81 privateCachedData.get(scriptState->context(), info.Holder()); 81 privateCachedData.get(scriptState->context(), info.Holder());
82 if (!result.IsEmpty()) { 82 if (!result.IsEmpty()) {
83 v8SetReturnValue(info, result); 83 v8SetReturnValue(info, result);
84 return; 84 return;
85 } 85 }
86 86
87 v8::Local<v8::Value> data; 87 v8::Local<v8::Value> data;
88 if (SerializedScriptValue* serializedValue = event->serializedData()) { 88 if (SerializedScriptValue* serializedValue = event->serializedData()) {
89 MessagePortArray ports = event->ports(); 89 MessagePortArray ports = event->ports();
90 data = serializedValue->deserialize(isolate, &ports); 90 SerializedScriptValue::DeserializeOptions options;
91 options.messagePorts = &ports;
92 data = serializedValue->deserialize(isolate, options);
91 } else if (DOMWrapperWorld::current(isolate).isIsolatedWorld()) { 93 } else if (DOMWrapperWorld::current(isolate).isIsolatedWorld()) {
92 v8::Local<v8::Value> mainWorldData = 94 v8::Local<v8::Value> mainWorldData =
93 privateCachedData.getFromMainWorld(scriptState, event); 95 privateCachedData.getFromMainWorld(scriptState, event);
94 if (!mainWorldData.IsEmpty()) { 96 if (!mainWorldData.IsEmpty()) {
95 // TODO(bashi): Enter the main world's ScriptState::Scope while 97 // TODO(bashi): Enter the main world's ScriptState::Scope while
96 // serializing the main world's value. 98 // serializing the main world's value.
97 event->setSerializedData( 99 event->setSerializedData(
98 SerializedScriptValue::serializeAndSwallowExceptions( 100 SerializedScriptValue::serializeAndSwallowExceptions(
99 info.GetIsolate(), mainWorldData)); 101 info.GetIsolate(), mainWorldData));
100 data = event->serializedData()->deserialize(isolate); 102 data = event->serializedData()->deserialize(isolate);
101 } 103 }
102 } 104 }
103 if (data.IsEmpty()) 105 if (data.IsEmpty())
104 data = v8::Null(isolate); 106 data = v8::Null(isolate);
105 privateCachedData.set(scriptState->context(), info.Holder(), data); 107 privateCachedData.set(scriptState->context(), info.Holder(), data);
106 v8SetReturnValue(info, data); 108 v8SetReturnValue(info, data);
107 } 109 }
108 110
109 } // namespace blink 111 } // namespace blink
110 112
111 #endif // V8ServiceWorkerMessageEventInternal_h 113 #endif // V8ServiceWorkerMessageEventInternal_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698