[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, |
14 | v8::Handle<v8::Context> context) | ||||
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] | 97f21ca | 2013-11-17 17:46:07 | [diff] [blame] | 22 | } |
23 | |||||
[email protected] | 1771610d | 2014-02-27 06:08:24 | [diff] [blame] | 24 | // static |
[email protected] | 97f21ca | 2013-11-17 17:46:07 | [diff] [blame] | 25 | PerContextData* PerContextData::From(v8::Handle<v8::Context> context) { |
26 | return static_cast<PerContextData*>( | ||||
27 | context->GetAlignedPointerFromEmbedderData(kEncodedValueIndex)); | ||||
28 | } | ||||
29 | |||||
[email protected] | 97f21ca | 2013-11-17 17:46:07 | [diff] [blame] | 30 | } // namespace gin |