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

Side by Side Diff: Source/bindings/v8/V8StringResource.h

Issue 232563003: API functions returning Promises should not throw exceptions. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 8 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 192
193 if (LIKELY(m_v8Object->IsString())) 193 if (LIKELY(m_v8Object->IsString()))
194 return true; 194 return true;
195 195
196 if (LIKELY(m_v8Object->IsInt32())) { 196 if (LIKELY(m_v8Object->IsInt32())) {
197 setString(int32ToWebCoreString(m_v8Object->Int32Value())); 197 setString(int32ToWebCoreString(m_v8Object->Int32Value()));
198 return true; 198 return true;
199 } 199 }
200 200
201 m_mode = DoNotExternalize; 201 m_mode = DoNotExternalize;
202 v8::TryCatch block;
203 m_v8Object = m_v8Object->ToString(); 202 m_v8Object = m_v8Object->ToString();
204 // Handle the case where an exception is thrown as part of invoking toSt ring on the object. 203 // Returns false when an exception is thrown from toString.
205 if (block.HasCaught()) { 204 return !m_v8Object.IsEmpty();
haraken 2014/04/11 13:57:13 I double-checked and confirmed that the new code l
yhirano 2014/04/14 06:12:43 Actually, layout tests show that some regressions
206 block.ReThrow();
207 return false;
208 }
209 return true;
210 } 205 }
211 206
212 void setString(const String& string) 207 void setString(const String& string)
213 { 208 {
214 m_string = string; 209 m_string = string;
215 m_v8Object.Clear(); // To signal that String is ready. 210 m_v8Object.Clear(); // To signal that String is ready.
216 } 211 }
217 212
218 template <class StringType> 213 template <class StringType>
219 StringType toString() const 214 StringType toString() const
(...skipping 28 matching lines...) Expand all
248 if (m_v8Object.IsEmpty() || m_v8Object->IsNull() || m_v8Object->IsUndefined( )) { 243 if (m_v8Object.IsEmpty() || m_v8Object->IsNull() || m_v8Object->IsUndefined( )) {
249 setString(String()); 244 setString(String());
250 return true; 245 return true;
251 } 246 }
252 return prepareBase(); 247 return prepareBase();
253 } 248 }
254 249
255 } // namespace WebCore 250 } // namespace WebCore
256 251
257 #endif // V8StringResource_h 252 #endif // V8StringResource_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698