blob: a72250c865b4ba5b80bd015c270917f2ccdfe4ac [file] [log] [blame]
[email protected]97f21ca2013-11-17 17:46:071// Copyright 2013 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]36e374082013-12-06 01:51:175#include "gin/public/context_holder.h"
[email protected]97f21ca2013-11-17 17:46:076
[email protected]855ab432013-11-18 17:09:367#include "base/logging.h"
[email protected]97f21ca2013-11-17 17:46:078#include "gin/per_context_data.h"
9
10namespace gin {
11
12ContextHolder::ContextHolder(v8::Isolate* isolate)
13 : isolate_(isolate) {
14}
15
16ContextHolder::~ContextHolder() {
[email protected]f2eec2ec2014-02-28 15:26:4917 // PerContextData needs to be destroyed before the context.
[email protected]855ab432013-11-18 17:09:3618 data_.reset();
[email protected]97f21ca2013-11-17 17:46:0719}
20
deepak.sfaaa1b62015-04-30 07:30:4821void ContextHolder::SetContext(v8::Local<v8::Context> context) {
[email protected]855ab432013-11-18 17:09:3622 DCHECK(context_.IsEmpty());
[email protected]97f21ca2013-11-17 17:46:0723 context_.Reset(isolate_, context);
[email protected]7f12ca72014-02-28 22:11:5324 data_.reset(new PerContextData(this, context));
[email protected]97f21ca2013-11-17 17:46:0725}
26
27} // namespace gin