blob: 569ce0981588f20872fd61432db97bfefce8fa9c [file] [log] [blame]
Avi Drissman468e51b62022-09-13 20:47:011// Copyright 2013 The Chromium Authors
[email protected]97f21ca2013-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
[email protected]36e374082013-12-06 01:51:177#include "gin/public/context_holder.h"
[email protected]c07006b2013-11-20 03:01:448#include "gin/public/wrapper_info.h"
[email protected]97f21ca2013-11-17 17:46:079
10namespace gin {
11
[email protected]7f12ca72014-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) {
[email protected]36e374082013-12-06 01:51:1715 context->SetAlignedPointerInEmbedderData(
Peter Kastinga3a482932022-05-09 19:49:5016 int{kPerContextDataStartIndex} + kEmbedderNativeGin, this);
[email protected]97f21ca2013-11-17 17:46:0717}
18
19PerContextData::~PerContextData() {
[email protected]6d73d2a62014-03-01 06:45:1020 context_holder_->context()->SetAlignedPointerInEmbedderData(
Peter Kastinga3a482932022-05-09 19:49:5021 int{kPerContextDataStartIndex} + kEmbedderNativeGin, NULL);
[email protected]97f21ca2013-11-17 17:46:0722}
23
[email protected]1771610d2014-02-27 06:08:2424// static
deepak.sfaaa1b62015-04-30 07:30:4825PerContextData* PerContextData::From(v8::Local<v8::Context> context) {
[email protected]97f21ca2013-11-17 17:46:0726 return static_cast<PerContextData*>(
27 context->GetAlignedPointerFromEmbedderData(kEncodedValueIndex));
28}
29
[email protected]97f21ca2013-11-17 17:46:0730} // namespace gin