| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 private: | 82 private: |
| 83 // Indicates that the object may (or may not) be owned by more than one place. | 83 // Indicates that the object may (or may not) be owned by more than one place. |
| 84 void setShared(bool shared) { | 84 void setShared(bool shared) { |
| 85 bool previouslyShared = m_shared; | 85 bool previouslyShared = m_shared; |
| 86 m_shared = shared; | 86 m_shared = shared; |
| 87 | 87 |
| 88 if (!m_shared) | 88 if (!m_shared) |
| 89 return; | 89 return; |
| 90 | 90 |
| 91 ASSERT_UNUSED(previouslyShared, shared != previouslyShared); | 91 DCHECK_NE(shared, previouslyShared); |
| 92 // Capture the current thread to verify that subsequent ref/deref happen on | 92 // Capture the current thread to verify that subsequent ref/deref happen on |
| 93 // this thread. | 93 // this thread. |
| 94 m_owningThread = currentThread(); | 94 m_owningThread = currentThread(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 // Is it OK to use the object at this moment on the current thread? | 97 // Is it OK to use the object at this moment on the current thread? |
| 98 bool isSafeToUse() const { | 98 bool isSafeToUse() const { |
| 99 if (!m_shared) | 99 if (!m_shared) |
| 100 return true; | 100 return true; |
| 101 | 101 |
| 102 return m_owningThread == currentThread(); | 102 return m_owningThread == currentThread(); |
| 103 } | 103 } |
| 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 |