[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 | |||||
5 | #include "gin/per_context_data.h" | ||||
6 | |||||
[email protected] | 855ab43 | 2013-11-18 17:09:36 | [diff] [blame] | 7 | #include "base/logging.h" |
[email protected] | 36e37408 | 2013-12-06 01:51:17 | [diff] [blame] | 8 | #include "gin/public/context_holder.h" |
[email protected] | c07006b | 2013-11-20 03:01:44 | [diff] [blame] | 9 | #include "gin/public/wrapper_info.h" |
[email protected] | 97f21ca | 2013-11-17 17:46:07 | [diff] [blame] | 10 | |
11 | namespace gin { | ||||
12 | |||||
[email protected] | 7f12ca7 | 2014-02-28 22:11:53 | [diff] [blame] | 13 | PerContextData::PerContextData(ContextHolder* context_holder, |
deepak.s | faaa1b6 | 2015-04-30 07:30:48 | [diff] [blame] | 14 | v8::Local<v8::Context> context) |
[email protected] | 7f12ca7 | 2014-02-28 22:11:53 | [diff] [blame] | 15 | : context_holder_(context_holder), |
16 | runner_(NULL) { | ||||
[email protected] | 36e37408 | 2013-12-06 01:51:17 | [diff] [blame] | 17 | context->SetAlignedPointerInEmbedderData( |
18 | kPerContextDataStartIndex + kEmbedderNativeGin, this); | ||||
[email protected] | 97f21ca | 2013-11-17 17:46:07 | [diff] [blame] | 19 | } |
20 | |||||
21 | PerContextData::~PerContextData() { | ||||
[email protected] | 6d73d2a6 | 2014-03-01 06:45:10 | [diff] [blame] | 22 | v8::HandleScope handle_scope(context_holder_->isolate()); |
23 | context_holder_->context()->SetAlignedPointerInEmbedderData( | ||||
24 | kPerContextDataStartIndex + kEmbedderNativeGin, NULL); | ||||
[email protected] | 97f21ca | 2013-11-17 17:46:07 | [diff] [blame] | 25 | } |
26 | |||||
[email protected] | 1771610d | 2014-02-27 06:08:24 | [diff] [blame] | 27 | // static |
deepak.s | faaa1b6 | 2015-04-30 07:30:48 | [diff] [blame] | 28 | PerContextData* PerContextData::From(v8::Local<v8::Context> context) { |
[email protected] | 97f21ca | 2013-11-17 17:46:07 | [diff] [blame] | 29 | return static_cast<PerContextData*>( |
30 | context->GetAlignedPointerFromEmbedderData(kEncodedValueIndex)); | ||||
31 | } | ||||
32 | |||||
[email protected] | 97f21ca | 2013-11-17 17:46:07 | [diff] [blame] | 33 | } // namespace gin |