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

Side by Side Diff: Source/bindings/core/v8/custom/V8PopStateEventCustom.cpp

Issue 1100223003: bindings: Add empty checks for toV8() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 5 years, 7 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 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 // There's no cached value from a previous invocation, nor a state value was provided by the 77 // There's no cached value from a previous invocation, nor a state value was provided by the
78 // event, but there is a history object, so first we need to see if the stat e object has been 78 // event, but there is a history object, so first we need to see if the stat e object has been
79 // deserialized through the history object already. 79 // deserialized through the history object already.
80 // The current history state object might've changed in the meantime, so we need to take care 80 // The current history state object might've changed in the meantime, so we need to take care
81 // of using the correct one, and always share the same deserialization with history.state. 81 // of using the correct one, and always share the same deserialization with history.state.
82 82
83 bool isSameState = history->isSameAsCurrentState(event->serializedState()); 83 bool isSameState = history->isSameAsCurrentState(event->serializedState());
84 84
85 if (isSameState) { 85 if (isSameState) {
86 v8::Local<v8::Object> v8History = toV8(history, info.Holder(), info.GetI solate()).As<v8::Object>(); 86 v8::Local<v8::Value> v8HistoryValue = toV8(history, info.Holder(), info. GetIsolate());
87 if (v8HistoryValue.IsEmpty())
88 return;
89 v8::Local<v8::Object> v8History = v8HistoryValue.As<v8::Object>();
87 if (!history->stateChanged()) { 90 if (!history->stateChanged()) {
88 result = V8HiddenValue::getHiddenValue(info.GetIsolate(), v8History, V8HiddenValue::state(info.GetIsolate())); 91 result = V8HiddenValue::getHiddenValue(info.GetIsolate(), v8History, V8HiddenValue::state(info.GetIsolate()));
89 if (!result.IsEmpty()) { 92 if (!result.IsEmpty()) {
90 v8SetReturnValue(info, cacheState(info.Holder(), result, info.Ge tIsolate())); 93 v8SetReturnValue(info, cacheState(info.Holder(), result, info.Ge tIsolate()));
91 return; 94 return;
92 } 95 }
93 } 96 }
94 result = event->serializedState()->deserialize(info.GetIsolate()); 97 result = event->serializedState()->deserialize(info.GetIsolate());
95 V8HiddenValue::setHiddenValue(info.GetIsolate(), v8History, V8HiddenValu e::state(info.GetIsolate()), result); 98 V8HiddenValue::setHiddenValue(info.GetIsolate(), v8History, V8HiddenValu e::state(info.GetIsolate()), result);
96 } else { 99 } else {
97 result = event->serializedState()->deserialize(info.GetIsolate()); 100 result = event->serializedState()->deserialize(info.GetIsolate());
98 } 101 }
99 102
100 v8SetReturnValue(info, cacheState(info.Holder(), result, info.GetIsolate())) ; 103 v8SetReturnValue(info, cacheState(info.Holder(), result, info.GetIsolate())) ;
101 } 104 }
102 105
103 } // namespace blink 106 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/WindowProxy.cpp ('k') | Source/bindings/modules/v8/ScriptValueSerializerForModules.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698