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

Side by Side Diff: third_party/WebKit/Source/core/dom/custom/V0CustomElementObserver.cpp

Issue 2694283003: Annotate ScriptWrappable-embedding singletons.
Patch Set: add XPathValue singleton Created 3 years, 10 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 22 matching lines...) Expand all
33 #include "core/dom/Element.h" 33 #include "core/dom/Element.h"
34 34
35 namespace blink { 35 namespace blink {
36 36
37 // Maps elements to the observer watching them. At most one per 37 // Maps elements to the observer watching them. At most one per
38 // element at a time. 38 // element at a time.
39 typedef HeapHashMap<WeakMember<Element>, Member<V0CustomElementObserver>> 39 typedef HeapHashMap<WeakMember<Element>, Member<V0CustomElementObserver>>
40 ElementObserverMap; 40 ElementObserverMap;
41 41
42 static ElementObserverMap& elementObservers() { 42 static ElementObserverMap& elementObservers() {
43 ALLOW_UNSAFE_SINGLETON()
43 DEFINE_STATIC_LOCAL(ElementObserverMap, map, (new ElementObserverMap)); 44 DEFINE_STATIC_LOCAL(ElementObserverMap, map, (new ElementObserverMap));
44 return map; 45 return map;
45 } 46 }
46 47
47 void V0CustomElementObserver::notifyElementWasDestroyed(Element* element) { 48 void V0CustomElementObserver::notifyElementWasDestroyed(Element* element) {
48 ElementObserverMap::iterator it = elementObservers().find(element); 49 ElementObserverMap::iterator it = elementObservers().find(element);
49 if (it == elementObservers().end()) 50 if (it == elementObservers().end())
50 return; 51 return;
51 it->value->elementWasDestroyed(element); 52 it->value->elementWasDestroyed(element);
52 } 53 }
53 54
54 void V0CustomElementObserver::observe(Element* element) { 55 void V0CustomElementObserver::observe(Element* element) {
55 ElementObserverMap::AddResult result = 56 ElementObserverMap::AddResult result =
56 elementObservers().insert(element, this); 57 elementObservers().insert(element, this);
57 DCHECK(result.isNewEntry); 58 DCHECK(result.isNewEntry);
58 } 59 }
59 60
60 void V0CustomElementObserver::unobserve(Element* element) { 61 void V0CustomElementObserver::unobserve(Element* element) {
61 V0CustomElementObserver* observer = elementObservers().take(element); 62 V0CustomElementObserver* observer = elementObservers().take(element);
62 DCHECK_EQ(observer, this); 63 DCHECK_EQ(observer, this);
63 } 64 }
64 65
65 } // namespace blink 66 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698