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

Unified Diff: gin/dictionary.h

Issue 1106393002: gin: Use V8 Maybe APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@maybe-gin-converter
Patch Set: size_t -> uint32_t 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 side-by-side diff with in-line comments
Download patch
Index: gin/dictionary.h
diff --git a/gin/dictionary.h b/gin/dictionary.h
index efebfa85a702666d6efe8fe4285caafc858e49f1..e3fb63c085c6596d8637d052ec202c6e9d0c45ce 100644
--- a/gin/dictionary.h
+++ b/gin/dictionary.h
@@ -32,13 +32,22 @@ class GIN_EXPORT Dictionary {
template<typename T>
bool Get(const std::string& key, T* out) {
- v8::Local<v8::Value> val = object_->Get(StringToV8(isolate_, key));
+ v8::Local<v8::Value> val;
+ if (!object_->Get(isolate_->GetCurrentContext(), StringToV8(isolate_, key))
+ .ToLocal(&val))
jochen (gone - plz use gerrit) 2015/05/27 14:43:26 nit add {}
bashi 2015/05/29 02:04:02 Done.
+ return false;
return ConvertFromV8(isolate_, val, out);
}
template<typename T>
bool Set(const std::string& key, T val) {
- return object_->Set(StringToV8(isolate_, key), ConvertToV8(isolate_, val));
+ v8::Local<v8::Value> v8_value;
+ if (!TryConvertToV8(isolate_, val, &v8_value))
+ return false;
+ v8::Maybe<bool> result =
+ object_->Set(isolate_->GetCurrentContext(), StringToV8(isolate_, key),
+ v8_value);
+ return !result.IsNothing() && result.FromJust();
}
v8::Isolate* isolate() const { return isolate_; }
« no previous file with comments | « gin/converter_unittest.cc ('k') | gin/interceptor_unittest.cc » ('j') | gin/try_catch.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698