| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 // used on a single thread. The thread gets captured when setShared(true) is | 44 // used on a single thread. The thread gets captured when setShared(true) is |
| 45 // called. The mode may be changed by calling useMutexMode (or | 45 // called. The mode may be changed by calling useMutexMode (or |
| 46 // turnOffVerification). | 46 // turnOffVerification). |
| 47 class ThreadRestrictionVerifier { | 47 class ThreadRestrictionVerifier { |
| 48 public: | 48 public: |
| 49 ThreadRestrictionVerifier() : m_shared(false), m_owningThread(0) {} | 49 ThreadRestrictionVerifier() : m_shared(false), m_owningThread(0) {} |
| 50 | 50 |
| 51 void checkSafeToUse() const { | 51 void checkSafeToUse() const { |
| 52 // If this assert fires, it either indicates a thread safety issue or | 52 // If this assert fires, it either indicates a thread safety issue or |
| 53 // that the verification needs to change. | 53 // that the verification needs to change. |
| 54 ASSERT_WITH_SECURITY_IMPLICATION(isSafeToUse()); | 54 SECURITY_DCHECK(isSafeToUse()); |
| 55 } | 55 } |
| 56 | 56 |
| 57 // Call onRef() before refCount is incremented in ref(). | 57 // Call onRef() before refCount is incremented in ref(). |
| 58 void onRef(int refCount) { | 58 void onRef(int refCount) { |
| 59 // Start thread verification as soon as the ref count gets to 2. This | 59 // Start thread verification as soon as the ref count gets to 2. This |
| 60 // heuristic reflects the fact that items are often created on one | 60 // heuristic reflects the fact that items are often created on one |
| 61 // thread and then given to another thread to be used. | 61 // thread and then given to another thread to be used. |
| 62 // FIXME: Make this restriction tigher. Especially as we move to more | 62 // FIXME: Make this restriction tigher. Especially as we move to more |
| 63 // common methods for sharing items across threads like | 63 // common methods for sharing items across threads like |
| 64 // CrossThreadCopier.h | 64 // CrossThreadCopier.h |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 104 |
| 105 bool m_shared; | 105 bool m_shared; |
| 106 | 106 |
| 107 ThreadIdentifier m_owningThread; | 107 ThreadIdentifier m_owningThread; |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 } // namespace WTF | 110 } // namespace WTF |
| 111 | 111 |
| 112 #endif // ENABLE(ASSERT) | 112 #endif // ENABLE(ASSERT) |
| 113 #endif // ThreadRestrictionVerifier_h | 113 #endif // ThreadRestrictionVerifier_h |
| OLD | NEW |