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

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

Issue 794223003: Cheaper thread-safe atomic initialization of static references. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add type check for initial value Created 5 years, 11 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 21 matching lines...) Expand all
32 #include "wtf/Assertions.h" 32 #include "wtf/Assertions.h"
33 #include "wtf/Functional.h" 33 #include "wtf/Functional.h"
34 #include "wtf/MainThread.h" 34 #include "wtf/MainThread.h"
35 #include "wtf/StdLibExtras.h" 35 #include "wtf/StdLibExtras.h"
36 #include "wtf/Threading.h" 36 #include "wtf/Threading.h"
37 37
38 namespace blink { 38 namespace blink {
39 39
40 NetworkStateNotifier& networkStateNotifier() 40 NetworkStateNotifier& networkStateNotifier()
41 { 41 {
42 AtomicallyInitializedStatic(NetworkStateNotifier*, networkStateNotifier = ne w NetworkStateNotifier); 42 AtomicallyInitializedStaticReference(NetworkStateNotifier, networkStateNotif ier, new NetworkStateNotifier);
43 return *networkStateNotifier; 43 return networkStateNotifier;
44 } 44 }
45 45
46 void NetworkStateNotifier::setOnLine(bool onLine) 46 void NetworkStateNotifier::setOnLine(bool onLine)
47 { 47 {
48 ASSERT(isMainThread()); 48 ASSERT(isMainThread());
49 49
50 { 50 {
51 MutexLocker locker(m_mutex); 51 MutexLocker locker(m_mutex);
52 if (m_isOnLine == onLine) 52 if (m_isOnLine == onLine)
53 return; 53 return;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 172
173 list->zeroedObservers.clear(); 173 list->zeroedObservers.clear();
174 174
175 if (list->observers.isEmpty()) { 175 if (list->observers.isEmpty()) {
176 MutexLocker locker(m_mutex); 176 MutexLocker locker(m_mutex);
177 m_observers.remove(context); // deletes list 177 m_observers.remove(context); // deletes list
178 } 178 }
179 } 179 }
180 180
181 } // namespace blink 181 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698