OLD | NEW |
(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 #ifndef GIN_PER_CONTEXT_DATA_H_ |
| 6 #define GIN_PER_CONTEXT_DATA_H_ |
| 7 |
| 8 #include <vector> |
| 9 #include "base/basictypes.h" |
| 10 #include "v8/include/v8.h" |
| 11 |
| 12 namespace gin { |
| 13 |
| 14 class ContextSupplement { |
| 15 public: |
| 16 ContextSupplement(); |
| 17 virtual ~ContextSupplement(); |
| 18 |
| 19 virtual void Detach(v8::Handle<v8::Context> context) = 0; |
| 20 |
| 21 private: |
| 22 DISALLOW_COPY_AND_ASSIGN(ContextSupplement); |
| 23 }; |
| 24 |
| 25 class PerContextData { |
| 26 public: |
| 27 explicit PerContextData(v8::Handle<v8::Context> context); |
| 28 ~PerContextData(); |
| 29 |
| 30 // Can return NULL after the ContextHolder has detached from context. |
| 31 static PerContextData* From(v8::Handle<v8::Context>); |
| 32 void Detach(v8::Handle<v8::Context> context); |
| 33 |
| 34 // Takes ownership of the supplement. |
| 35 void AddSupplement(ContextSupplement* supplement); |
| 36 |
| 37 private: |
| 38 typedef std::vector<ContextSupplement*> SuplementVector; |
| 39 |
| 40 // Owning reference. |
| 41 SuplementVector supplements_; |
| 42 |
| 43 DISALLOW_COPY_AND_ASSIGN(PerContextData); |
| 44 }; |
| 45 |
| 46 } // namespace gin |
| 47 |
| 48 #endif // GIN_PER_CONTEXT_DATA_H_ |
OLD | NEW |