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

Side by Side Diff: Source/bindings/v8/DOMWrapperMap.h

Issue 26792002: Reland: Reland: Implement new Blink IDL attribute [SetReference] (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: codegen impl Created 7 years, 2 months 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
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 template<class KeyType> 42 template<class KeyType>
43 class DOMWrapperMap { 43 class DOMWrapperMap {
44 public: 44 public:
45 typedef HashMap<KeyType*, UnsafePersistent<v8::Object> > MapType; 45 typedef HashMap<KeyType*, UnsafePersistent<v8::Object> > MapType;
46 46
47 explicit DOMWrapperMap(v8::Isolate* isolate) 47 explicit DOMWrapperMap(v8::Isolate* isolate)
48 : m_isolate(isolate) 48 : m_isolate(isolate)
49 { 49 {
50 } 50 }
51 51
52 // FIXME: rewrite other methods to use this?
53 UnsafePersistent<v8::Object> get(KeyType* key)
54 {
55 return m_map.get(key);
56 }
57
52 v8::Handle<v8::Object> newLocal(KeyType* key, v8::Isolate* isolate) 58 v8::Handle<v8::Object> newLocal(KeyType* key, v8::Isolate* isolate)
53 { 59 {
54 return m_map.get(key).newLocal(isolate); 60 return m_map.get(key).newLocal(isolate);
55 } 61 }
56 62
57 bool setReturnValueFrom(v8::ReturnValue<v8::Value> returnValue, KeyType* key ) 63 bool setReturnValueFrom(v8::ReturnValue<v8::Value> returnValue, KeyType* key )
58 { 64 {
59 typename MapType::iterator it = m_map.find(key); 65 typename MapType::iterator it = m_map.find(key);
60 if (it == m_map.end()) 66 if (it == m_map.end())
61 return false; 67 return false;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 ASSERT(type->derefObjectFunction); 131 ASSERT(type->derefObjectFunction);
126 void* key = static_cast<void*>(toNative(*wrapper)); 132 void* key = static_cast<void*>(toNative(*wrapper));
127 ASSERT(*(map->m_map.get(key).persistent()) == *wrapper); 133 ASSERT(*(map->m_map.get(key).persistent()) == *wrapper);
128 map->removeAndDispose(key); 134 map->removeAndDispose(key);
129 type->derefObject(key); 135 type->derefObject(key);
130 } 136 }
131 137
132 } // namespace WebCore 138 } // namespace WebCore
133 139
134 #endif // DOMWrapperMap_h 140 #endif // DOMWrapperMap_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698