| OLD | NEW |
| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 class Supplementable; | 91 class Supplementable; |
| 92 | 92 |
| 93 template<typename T> | 93 template<typename T> |
| 94 class Supplement { | 94 class Supplement { |
| 95 public: | 95 public: |
| 96 virtual ~Supplement() { } | 96 virtual ~Supplement() { } |
| 97 #if SECURITY_ASSERT_ENABLED | 97 #if SECURITY_ASSERT_ENABLED |
| 98 virtual bool isRefCountedWrapper() const { return false; } | 98 virtual bool isRefCountedWrapper() const { return false; } |
| 99 #endif | 99 #endif |
| 100 | 100 |
| 101 static void provideTo(Supplementable<T>* host, const char* key, PassOwnPtr<S
upplement<T> > supplement) | 101 static void provideTo(Supplementable<T>& host, const char* key, PassOwnPtr<S
upplement<T> > supplement) |
| 102 { | 102 { |
| 103 host->provideSupplement(key, supplement); | 103 host.provideSupplement(key, supplement); |
| 104 } |
| 105 |
| 106 static Supplement<T>* from(Supplementable<T>& host, const char* key) |
| 107 { |
| 108 return host.requireSupplement(key); |
| 104 } | 109 } |
| 105 | 110 |
| 106 static Supplement<T>* from(Supplementable<T>* host, const char* key) | 111 static Supplement<T>* from(Supplementable<T>* host, const char* key) |
| 107 { | 112 { |
| 108 return host ? host->requireSupplement(key) : 0; | 113 return host ? host->requireSupplement(key) : 0; |
| 109 } | 114 } |
| 110 }; | 115 }; |
| 111 | 116 |
| 112 template<typename T> | 117 template<typename T> |
| 113 class Supplementable { | 118 class Supplementable { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 typedef HashMap<const char*, OwnPtr<Supplement<T> >, PtrHash<const char*> >
SupplementMap; | 152 typedef HashMap<const char*, OwnPtr<Supplement<T> >, PtrHash<const char*> >
SupplementMap; |
| 148 SupplementMap m_supplements; | 153 SupplementMap m_supplements; |
| 149 #if !ASSERT_DISABLED | 154 #if !ASSERT_DISABLED |
| 150 ThreadIdentifier m_threadId; | 155 ThreadIdentifier m_threadId; |
| 151 #endif | 156 #endif |
| 152 }; | 157 }; |
| 153 | 158 |
| 154 } // namespace WebCore | 159 } // namespace WebCore |
| 155 | 160 |
| 156 #endif // Supplementable_h | 161 #endif // Supplementable_h |
| OLD | NEW |