[M120 Migration][VD] Enable direct rendering for TVPlus
[platform/framework/web/chromium-efl.git] / gin / per_context_data.cc
1 // Copyright 2013 The Chromium Authors
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
7 #include "gin/public/context_holder.h"
8 #include "gin/public/wrapper_info.h"
9
10 namespace gin {
11
12 PerContextData::PerContextData(ContextHolder* context_holder,
13                                v8::Local<v8::Context> context)
14     : context_holder_(context_holder), runner_(nullptr) {
15   context->SetAlignedPointerInEmbedderData(
16       int{kPerContextDataStartIndex} + kEmbedderNativeGin, this);
17 }
18
19 PerContextData::~PerContextData() {
20   v8::HandleScope handle_scope(context_holder_->isolate());
21   context_holder_->context()->SetAlignedPointerInEmbedderData(
22       int{kPerContextDataStartIndex} + kEmbedderNativeGin, NULL);
23 }
24
25 // static
26 PerContextData* PerContextData::From(v8::Local<v8::Context> context) {
27   return static_cast<PerContextData*>(
28       context->GetAlignedPointerFromEmbedderData(kEncodedValueIndex));
29 }
30
31 }  // namespace gin