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

Side by Side Diff: Source/core/dom/IdTargetObserverRegistry.cpp

Issue 138643003: Simpler return value of HashTable::add/HashMap:add and others (Closed)
Patch Set: Daily master update (now with base url?) Created 6 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
« no previous file with comments | « Source/core/dom/ExecutionContext.cpp ('k') | Source/core/dom/Node.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 24 matching lines...) Expand all
35 return adoptPtr(new IdTargetObserverRegistry()); 35 return adoptPtr(new IdTargetObserverRegistry());
36 } 36 }
37 37
38 void IdTargetObserverRegistry::addObserver(const AtomicString& id, IdTargetObser ver* observer) 38 void IdTargetObserverRegistry::addObserver(const AtomicString& id, IdTargetObser ver* observer)
39 { 39 {
40 if (id.isEmpty()) 40 if (id.isEmpty())
41 return; 41 return;
42 42
43 IdToObserverSetMap::AddResult result = m_registry.add(id.impl(), nullptr); 43 IdToObserverSetMap::AddResult result = m_registry.add(id.impl(), nullptr);
44 if (result.isNewEntry) 44 if (result.isNewEntry)
45 result.iterator->value = adoptPtr(new ObserverSet()); 45 result.storedValue->value = adoptPtr(new ObserverSet());
46 46
47 result.iterator->value->add(observer); 47 result.storedValue->value->add(observer);
48 } 48 }
49 49
50 void IdTargetObserverRegistry::removeObserver(const AtomicString& id, IdTargetOb server* observer) 50 void IdTargetObserverRegistry::removeObserver(const AtomicString& id, IdTargetOb server* observer)
51 { 51 {
52 if (id.isEmpty() || m_registry.isEmpty()) 52 if (id.isEmpty() || m_registry.isEmpty())
53 return; 53 return;
54 54
55 IdToObserverSetMap::iterator iter = m_registry.find(id.impl()); 55 IdToObserverSetMap::iterator iter = m_registry.find(id.impl());
56 56
57 ObserverSet* set = iter->value.get(); 57 ObserverSet* set = iter->value.get();
(...skipping 26 matching lines...) Expand all
84 84
85 bool IdTargetObserverRegistry::hasObservers(const AtomicString& id) const 85 bool IdTargetObserverRegistry::hasObservers(const AtomicString& id) const
86 { 86 {
87 if (id.isEmpty() || m_registry.isEmpty()) 87 if (id.isEmpty() || m_registry.isEmpty())
88 return false; 88 return false;
89 ObserverSet* set = m_registry.get(id.impl()); 89 ObserverSet* set = m_registry.get(id.impl());
90 return set && !set->isEmpty(); 90 return set && !set->isEmpty();
91 } 91 }
92 92
93 } // namespace WebCore 93 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/ExecutionContext.cpp ('k') | Source/core/dom/Node.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698