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

Unified Diff: src/api.cc

Issue 11087020: Add an API to let the embedder associate arbitrary data with a v8::Context. (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Add an API to let the embedder associate arbitrary data with a v8::Context. Created 8 years, 2 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
« no previous file with comments | « include/v8.h ('k') | src/contexts.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
===================================================================
--- src/api.cc (revision 12669)
+++ src/api.cc (working copy)
@@ -792,6 +792,29 @@
}
+void Context::SetEmbedderData(void* ptr) {
+ i::Handle<i::Context> env = Utils::OpenHandle(this);
+ i::Isolate* isolate = env->GetIsolate();
+ if (IsDeadCheck(isolate, "v8::Context::SetEmbedderData()")) return;
+ Local<Value> data = External::Wrap(ptr);
+ i::Handle<i::Object> raw_data = Utils::OpenHandle(*data);
+ ASSERT(env->IsNativeContext());
+ env->set_embedder_data(*raw_data);
+}
+
+
+void* Context::GetEmbedderData() {
+ i::Handle<i::Context> env = Utils::OpenHandle(this);
+ i::Isolate* isolate = env->GetIsolate();
+ if (IsDeadCheck(isolate, "v8::Context::GetEmbedderData()")) {
+ return 0;
+ }
+ i::Handle<i::Object> result(env->embedder_data(), isolate);
+ Local<Value> data = Utils::ToLocal(result);
+ return External::Unwrap(data);
+}
+
+
i::Object** v8::HandleScope::RawClose(i::Object** value) {
if (!ApiCheck(!is_closed_,
"v8::HandleScope::Close()",
« no previous file with comments | « include/v8.h ('k') | src/contexts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698