Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: gin/per_context_data.cc

Issue 62333018: Implement Asynchronous Module Definition API for Mojo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moar testing Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
7 #include <assert.h>
8 #include "gin/wrapper_info.h"
9
10 namespace gin {
11
12 ContextSupplement::ContextSupplement() {
13 }
14
15 ContextSupplement::~ContextSupplement() {
16 }
17
18 PerContextData::PerContextData(v8::Handle<v8::Context> context) {
19 context->SetAlignedPointerInEmbedderData(kEncodedValueIndex, this);
20 }
21
22 PerContextData::~PerContextData() {
23 assert(supplements_.empty());
24 }
25
26 void PerContextData::Detach(v8::Handle<v8::Context> context) {
27 assert(From(context) == this);
28 context->SetAlignedPointerInEmbedderData(kEncodedValueIndex, NULL);
29
30 SuplementVector supplements;
31 supplements.swap(supplements_);
32
33 for (SuplementVector::iterator it = supplements.begin();
34 it != supplements.end(); ++it) {
35 (*it)->Detach(context);
36 delete *it;
37 }
38 }
39
40 PerContextData* PerContextData::From(v8::Handle<v8::Context> context) {
41 return static_cast<PerContextData*>(
42 context->GetAlignedPointerFromEmbedderData(kEncodedValueIndex));
43 }
44
45 void PerContextData::AddSupplement(ContextSupplement* supplement) {
46 supplements_.push_back(supplement);
47 }
48
49 } // namespace gin
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698