[email protected] | 97f21ca | 2013-11-17 17:46:07 | [diff] [blame] | 1 | // 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] | 36e37408 | 2013-12-06 01:51:17 | [diff] [blame] | 5 | #include "gin/public/context_holder.h" |
[email protected] | 97f21ca | 2013-11-17 17:46:07 | [diff] [blame] | 6 | |
[email protected] | 855ab43 | 2013-11-18 17:09:36 | [diff] [blame] | 7 | #include "base/logging.h" |
[email protected] | 97f21ca | 2013-11-17 17:46:07 | [diff] [blame] | 8 | #include "gin/per_context_data.h" |
9 | |||||
10 | namespace gin { | ||||
11 | |||||
12 | ContextHolder::ContextHolder(v8::Isolate* isolate) | ||||
13 | : isolate_(isolate) { | ||||
14 | } | ||||
15 | |||||
16 | ContextHolder::~ContextHolder() { | ||||
[email protected] | f2eec2ec | 2014-02-28 15:26:49 | [diff] [blame] | 17 | // PerContextData needs to be destroyed before the context. |
[email protected] | 855ab43 | 2013-11-18 17:09:36 | [diff] [blame] | 18 | data_.reset(); |
[email protected] | 97f21ca | 2013-11-17 17:46:07 | [diff] [blame] | 19 | } |
20 | |||||
deepak.s | faaa1b6 | 2015-04-30 07:30:48 | [diff] [blame] | 21 | void ContextHolder::SetContext(v8::Local<v8::Context> context) { |
[email protected] | 855ab43 | 2013-11-18 17:09:36 | [diff] [blame] | 22 | DCHECK(context_.IsEmpty()); |
[email protected] | 97f21ca | 2013-11-17 17:46:07 | [diff] [blame] | 23 | context_.Reset(isolate_, context); |
Michael Lippautz | 1ab087d | 2018-03-16 13:43:39 | [diff] [blame] | 24 | context_.AnnotateStrongRetainer("gin::ContextHolder::context_"); |
[email protected] | 7f12ca7 | 2014-02-28 22:11:53 | [diff] [blame] | 25 | data_.reset(new PerContextData(this, context)); |
[email protected] | 97f21ca | 2013-11-17 17:46:07 | [diff] [blame] | 26 | } |
27 | |||||
28 | } // namespace gin |