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

Unified Diff: gin/context_holder.cc

Issue 62333018: Implement Asynchronous Module Definition API for Mojo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moar testing Created 7 years, 1 month 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/context_holder.cc
diff --git a/gin/context_holder.cc b/gin/context_holder.cc
new file mode 100644
index 0000000000000000000000000000000000000000..077feb70d0719e4612c57e933be74271022a76e2
--- /dev/null
+++ b/gin/context_holder.cc
@@ -0,0 +1,34 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "gin/context_holder.h"
+
+#include <assert.h>
+#include "gin/per_context_data.h"
+
+namespace gin {
+
+ContextHolder::ContextHolder(v8::Isolate* isolate)
+ : isolate_(isolate) {
+}
+
+ContextHolder::~ContextHolder() {
+ v8::HandleScope handle_scope(isolate());
+ v8::Handle<v8::Context> context = this->context();
+
+ PerContextData* data = PerContextData::From(context);
+ data->Detach(context);
+ delete data;
+
+ // TODO(abarth): Figure out how to set kResetInDestructor to true.
+ context_.Reset();
+}
+
+void ContextHolder::SetContext(v8::Handle<v8::Context> context) {
+ assert(context_.IsEmpty());
+ context_.Reset(isolate_, context);
+ new PerContextData(context); // Deleted in ~ContextHolder.
+}
+
+} // namespace gin
« no previous file with comments | « gin/context_holder.h ('k') | gin/converter.h » ('j') | gin/modules/module_registry.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698