Enable icu_use_data_file_flag on Android
[chromium-blink-merge.git] / gin / per_context_data.cc
blob5fedf52a522fb52499b19ed08118cc86d951f393
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.
5 #include "gin/per_context_data.h"
7 #include "base/logging.h"
8 #include "gin/public/context_holder.h"
9 #include "gin/public/wrapper_info.h"
11 namespace gin {
13 ContextSupplement::ContextSupplement() {
16 ContextSupplement::~ContextSupplement() {
19 PerContextData::PerContextData(v8::Handle<v8::Context> context)
20 : runner_(NULL) {
21 context->SetAlignedPointerInEmbedderData(
22 kPerContextDataStartIndex + kEmbedderNativeGin, this);
25 PerContextData::~PerContextData() {
26 DCHECK(supplements_.empty());
29 void PerContextData::Detach(v8::Handle<v8::Context> context) {
30 DCHECK(From(context) == this);
31 context->SetAlignedPointerInEmbedderData(
32 kPerContextDataStartIndex + kEmbedderNativeGin, NULL);
34 SuplementVector supplements;
35 supplements.swap(supplements_);
37 for (SuplementVector::iterator it = supplements.begin();
38 it != supplements.end(); ++it) {
39 (*it)->Detach(context);
43 // static
44 PerContextData* PerContextData::From(v8::Handle<v8::Context> context) {
45 return static_cast<PerContextData*>(
46 context->GetAlignedPointerFromEmbedderData(kEncodedValueIndex));
49 void PerContextData::AddSupplement(scoped_ptr<ContextSupplement> supplement) {
50 supplements_.push_back(supplement.release());
53 } // namespace gin