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

Side by Side Diff: third_party/WebKit/Source/core/page/NetworkStateNotifier.cpp

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 years, 6 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) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple 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 12 matching lines...) Expand all
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "core/page/NetworkStateNotifier.h" 26 #include "core/page/NetworkStateNotifier.h"
27 27
28 #include "core/dom/CrossThreadTask.h" 28 #include "core/dom/CrossThreadTask.h"
29 #include "core/dom/ExecutionContext.h" 29 #include "core/dom/ExecutionContext.h"
30 #include "core/page/Page.h" 30 #include "core/page/Page.h"
31 #include "wtf/Assertions.h" 31 #include "wtf/Assertions.h"
32 #include "wtf/Functional.h" 32 #include "wtf/Functional.h"
33 #include "wtf/PtrUtil.h"
33 #include "wtf/StdLibExtras.h" 34 #include "wtf/StdLibExtras.h"
34 #include "wtf/Threading.h" 35 #include "wtf/Threading.h"
35 36
36 namespace blink { 37 namespace blink {
37 38
38 NetworkStateNotifier& networkStateNotifier() 39 NetworkStateNotifier& networkStateNotifier()
39 { 40 {
40 DEFINE_THREAD_SAFE_STATIC_LOCAL(NetworkStateNotifier, networkStateNotifier, new NetworkStateNotifier); 41 DEFINE_THREAD_SAFE_STATIC_LOCAL(NetworkStateNotifier, networkStateNotifier, new NetworkStateNotifier);
41 return networkStateNotifier; 42 return networkStateNotifier;
42 } 43 }
(...skipping 23 matching lines...) Expand all
66 } 67 }
67 68
68 void NetworkStateNotifier::addObserver(NetworkStateObserver* observer, Execution Context* context) 69 void NetworkStateNotifier::addObserver(NetworkStateObserver* observer, Execution Context* context)
69 { 70 {
70 ASSERT(context->isContextThread()); 71 ASSERT(context->isContextThread());
71 ASSERT(observer); 72 ASSERT(observer);
72 73
73 MutexLocker locker(m_mutex); 74 MutexLocker locker(m_mutex);
74 ObserverListMap::AddResult result = m_observers.add(context, nullptr); 75 ObserverListMap::AddResult result = m_observers.add(context, nullptr);
75 if (result.isNewEntry) 76 if (result.isNewEntry)
76 result.storedValue->value = adoptPtr(new ObserverList); 77 result.storedValue->value = wrapUnique(new ObserverList);
77 78
78 ASSERT(result.storedValue->value->observers.find(observer) == kNotFound); 79 ASSERT(result.storedValue->value->observers.find(observer) == kNotFound);
79 result.storedValue->value->observers.append(observer); 80 result.storedValue->value->observers.append(observer);
80 } 81 }
81 82
82 void NetworkStateNotifier::removeObserver(NetworkStateObserver* observer, Execut ionContext* context) 83 void NetworkStateNotifier::removeObserver(NetworkStateObserver* observer, Execut ionContext* context)
83 { 84 {
84 ASSERT(context->isContextThread()); 85 ASSERT(context->isContextThread());
85 ASSERT(observer); 86 ASSERT(observer);
86 87
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 183
183 list->zeroedObservers.clear(); 184 list->zeroedObservers.clear();
184 185
185 if (list->observers.isEmpty()) { 186 if (list->observers.isEmpty()) {
186 MutexLocker locker(m_mutex); 187 MutexLocker locker(m_mutex);
187 m_observers.remove(context); // deletes list 188 m_observers.remove(context); // deletes list
188 } 189 }
189 } 190 }
190 191
191 } // namespace blink 192 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/page/NetworkStateNotifier.h ('k') | third_party/WebKit/Source/core/page/PrintContextTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698