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

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

Issue 265293004: Create fewer local v8::TryCatch objects in generated bindings code (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: avoid some unused v8::TryCatch objects Created 6 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) 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 // or AtomicStrings as appropriate, using multiple typecast operators. 162 // or AtomicStrings as appropriate, using multiple typecast operators.
163 enum V8StringResourceMode { 163 enum V8StringResourceMode {
164 DefaultMode, 164 DefaultMode,
165 WithNullCheck, 165 WithNullCheck,
166 WithUndefinedOrNullCheck 166 WithUndefinedOrNullCheck
167 }; 167 };
168 168
169 template <V8StringResourceMode Mode = DefaultMode> 169 template <V8StringResourceMode Mode = DefaultMode>
170 class V8StringResource { 170 class V8StringResource {
171 public: 171 public:
172 V8StringResource()
173 : m_mode(Externalize)
174 {
175 }
176
172 V8StringResource(v8::Handle<v8::Value> object) 177 V8StringResource(v8::Handle<v8::Value> object)
173 : m_v8Object(object) 178 : m_v8Object(object)
174 , m_mode(Externalize) 179 , m_mode(Externalize)
175 , m_string()
176 { 180 {
177 } 181 }
178 182
183 void operator= (v8::Handle<v8::Value> object)
haraken 2014/05/08 03:45:06 Nit: Unnecessary space after '='.
Jens Widell 2014/05/08 16:38:05 Fixed.
184 {
185 m_v8Object = object;
186 }
187
179 bool prepare(); 188 bool prepare();
180 operator String() const { return toString<String>(); } 189 operator String() const { return toString<String>(); }
181 operator AtomicString() const { return toString<AtomicString>(); } 190 operator AtomicString() const { return toString<AtomicString>(); }
182 191
183 private: 192 private:
184 bool prepareBase() 193 bool prepareBase()
185 { 194 {
186 if (m_v8Object.IsEmpty()) 195 if (m_v8Object.IsEmpty())
187 return true; 196 return true;
188 197
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 if (m_v8Object.IsEmpty() || m_v8Object->IsNull() || m_v8Object->IsUndefined( )) { 253 if (m_v8Object.IsEmpty() || m_v8Object->IsNull() || m_v8Object->IsUndefined( )) {
245 setString(String()); 254 setString(String());
246 return true; 255 return true;
247 } 256 }
248 return prepareBase(); 257 return prepareBase();
249 } 258 }
250 259
251 } // namespace WebCore 260 } // namespace WebCore
252 261
253 #endif // V8StringResource_h 262 #endif // V8StringResource_h
OLDNEW
« Source/bindings/v8/V8BindingMacros.h ('K') | « Source/bindings/v8/V8BindingMacros.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698