[go: nahoru, domu]

blob: c0d23c8f4e22a889e1e733f275f8120c754df13f [file] [log] [blame]
Avi Drissman468e51b62022-09-13 20:47:011// Copyright 2013 The Chromium Authors
abarth@chromium.org97f21ca2013-11-17 17:46:072// 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
jochen@chromium.org36e374082013-12-06 01:51:177#include "gin/public/context_holder.h"
jochen@chromium.orgc07006b2013-11-20 03:01:448#include "gin/public/wrapper_info.h"
abarth@chromium.org97f21ca2013-11-17 17:46:079
10namespace gin {
11
sky@chromium.org7f12ca72014-02-28 22:11:5312PerContextData::PerContextData(ContextHolder* context_holder,
deepak.sfaaa1b62015-04-30 07:30:4813 v8::Local<v8::Context> context)
Lukasz Anforowiczc695e532020-06-09 02:09:4514 : context_holder_(context_holder), runner_(nullptr) {
jochen@chromium.org36e374082013-12-06 01:51:1715 context->SetAlignedPointerInEmbedderData(
Peter Kastinga3a482932022-05-09 19:49:5016 int{kPerContextDataStartIndex} + kEmbedderNativeGin, this);
abarth@chromium.org97f21ca2013-11-17 17:46:0717}
18
19PerContextData::~PerContextData() {
sky@chromium.org6d73d2a62014-03-01 06:45:1020 v8::HandleScope handle_scope(context_holder_->isolate());
21 context_holder_->context()->SetAlignedPointerInEmbedderData(
Peter Kastinga3a482932022-05-09 19:49:5022 int{kPerContextDataStartIndex} + kEmbedderNativeGin, NULL);
abarth@chromium.org97f21ca2013-11-17 17:46:0723}
24
sky@chromium.org1771610d2014-02-27 06:08:2425// static
deepak.sfaaa1b62015-04-30 07:30:4826PerContextData* PerContextData::From(v8::Local<v8::Context> context) {
abarth@chromium.org97f21ca2013-11-17 17:46:0727 return static_cast<PerContextData*>(
28 context->GetAlignedPointerFromEmbedderData(kEncodedValueIndex));
29}
30
abarth@chromium.org97f21ca2013-11-17 17:46:0731} // namespace gin