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 | 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 setEncodedSize(data->size()); | 65 setEncodedSize(data->size()); |
66 m_data = data; | 66 m_data = data; |
67 } | 67 } |
68 CachedResource::data(m_data, allDataReceived); | 68 CachedResource::data(m_data, allDataReceived); |
69 } | 69 } |
70 | 70 |
71 void CachedRawResource::didAddClient(CachedResourceClient* c) | 71 void CachedRawResource::didAddClient(CachedResourceClient* c) |
72 { | 72 { |
73 if (m_response.isNull() || !hasClient(c)) | 73 if (m_response.isNull() || !hasClient(c)) |
74 return; | 74 return; |
| 75 // The calls to the client can result in events running, potentially causing |
| 76 // this resource to be evicted from the cache and all clients to be removed, |
| 77 // so a protector is necessary. |
| 78 CachedResourceHandle<CachedRawResource> protect(this); |
75 CachedRawResourceClient* client = static_cast<CachedRawResourceClient*>(c); | 79 CachedRawResourceClient* client = static_cast<CachedRawResourceClient*>(c); |
76 client->responseReceived(this, m_response); | 80 client->responseReceived(this, m_response); |
77 if (!hasClient(c)) | 81 if (!hasClient(c)) |
78 return; | 82 return; |
79 if (m_data) | 83 if (m_data) |
80 client->dataReceived(this, m_data->data(), m_data->size()); | 84 client->dataReceived(this, m_data->data(), m_data->size()); |
81 if (!hasClient(c)) | 85 if (!hasClient(c)) |
82 return; | 86 return; |
83 CachedResource::didAddClient(client); | 87 CachedResource::didAddClient(client); |
84 } | 88 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 HTTPHeaderMap::const_iterator end = newHeaders.end(); | 153 HTTPHeaderMap::const_iterator end = newHeaders.end(); |
150 for (HTTPHeaderMap::const_iterator i = newHeaders.begin(); i != end; ++i) { | 154 for (HTTPHeaderMap::const_iterator i = newHeaders.begin(); i != end; ++i) { |
151 AtomicString headerName = i->first; | 155 AtomicString headerName = i->first; |
152 if (i->second != oldHeaders.get(headerName)) | 156 if (i->second != oldHeaders.get(headerName)) |
153 return false; | 157 return false; |
154 } | 158 } |
155 return true; | 159 return true; |
156 } | 160 } |
157 | 161 |
158 } // namespace WebCore | 162 } // namespace WebCore |
OLD | NEW |