| 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 24 matching lines...) Expand all Loading... |
| 35 #include <wtf/PassRefPtr.h> | 35 #include <wtf/PassRefPtr.h> |
| 36 | 36 |
| 37 namespace WebCore { | 37 namespace WebCore { |
| 38 | 38 |
| 39 CachedRawResource::CachedRawResource(ResourceRequest& resourceRequest, Type type
) | 39 CachedRawResource::CachedRawResource(ResourceRequest& resourceRequest, Type type
) |
| 40 : CachedResource(resourceRequest, type) | 40 : CachedResource(resourceRequest, type) |
| 41 , m_identifier(0) | 41 , m_identifier(0) |
| 42 { | 42 { |
| 43 } | 43 } |
| 44 | 44 |
| 45 void CachedRawResource::data(PassRefPtr<ResourceBuffer> data, bool allDataReceiv
ed) | 45 void CachedRawResource::data(PassRefPtr<ResourceBuffer> data) |
| 46 { | 46 { |
| 47 CachedResourceHandle<CachedRawResource> protect(this); | 47 CachedResourceHandle<CachedRawResource> protect(this); |
| 48 const char* incrementalData = 0; | 48 const char* incrementalData = 0; |
| 49 size_t incrementalDataLength = 0; | 49 size_t incrementalDataLength = 0; |
| 50 if (data) { | 50 if (data) { |
| 51 // If we are buffering data, then we are saving the buffer in m_data and
need to manually | 51 // If we are buffering data, then we are saving the buffer in m_data and
need to manually |
| 52 // calculate the incremental data. If we are not buffering, then m_data
will be null and | 52 // calculate the incremental data. If we are not buffering, then m_data
will be null and |
| 53 // the buffer contains only the incremental data. | 53 // the buffer contains only the incremental data. |
| 54 size_t previousDataLength = (m_options.dataBufferingPolicy == BufferData
) ? encodedSize() : 0; | 54 size_t previousDataLength = (m_options.dataBufferingPolicy == BufferData
) ? encodedSize() : 0; |
| 55 ASSERT(data->size() >= previousDataLength); | 55 ASSERT(data->size() >= previousDataLength); |
| 56 incrementalData = data->data() + previousDataLength; | 56 incrementalData = data->data() + previousDataLength; |
| 57 incrementalDataLength = data->size() - previousDataLength; | 57 incrementalDataLength = data->size() - previousDataLength; |
| 58 } | 58 } |
| 59 | 59 |
| 60 if (m_options.dataBufferingPolicy == BufferData) { | 60 if (m_options.dataBufferingPolicy == BufferData) |
| 61 if (data) | 61 CachedResource::data(data); |
| 62 setEncodedSize(data->size()); | |
| 63 m_data = data; | |
| 64 } | |
| 65 | 62 |
| 66 DataBufferingPolicy dataBufferingPolicy = m_options.dataBufferingPolicy; | 63 DataBufferingPolicy dataBufferingPolicy = m_options.dataBufferingPolicy; |
| 67 if (incrementalDataLength) { | 64 if (incrementalDataLength) { |
| 68 CachedResourceClientWalker<CachedRawResourceClient> w(m_clients); | 65 CachedResourceClientWalker<CachedRawResourceClient> w(m_clients); |
| 69 while (CachedRawResourceClient* c = w.next()) | 66 while (CachedRawResourceClient* c = w.next()) |
| 70 c->dataReceived(this, incrementalData, incrementalDataLength); | 67 c->dataReceived(this, incrementalData, incrementalDataLength); |
| 71 } | 68 } |
| 72 CachedResource::data(m_data, allDataReceived); | |
| 73 | 69 |
| 74 if (dataBufferingPolicy == BufferData && m_options.dataBufferingPolicy == Do
NotBufferData) { | 70 if (dataBufferingPolicy == BufferData && m_options.dataBufferingPolicy == Do
NotBufferData) { |
| 75 if (m_loader) | 71 if (m_loader) |
| 76 m_loader->setDataBufferingPolicy(DoNotBufferData); | 72 m_loader->setDataBufferingPolicy(DoNotBufferData); |
| 77 clear(); | 73 clear(); |
| 78 } | 74 } |
| 79 } | 75 } |
| 80 | 76 |
| 81 void CachedRawResource::didAddClient(CachedResourceClient* c) | 77 void CachedRawResource::didAddClient(CachedResourceClient* c) |
| 82 { | 78 { |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 } | 237 } |
| 242 | 238 |
| 243 void CachedRawResource::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) co
nst | 239 void CachedRawResource::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) co
nst |
| 244 { | 240 { |
| 245 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CachedResou
rceRaw); | 241 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CachedResou
rceRaw); |
| 246 CachedResource::reportMemoryUsage(memoryObjectInfo); | 242 CachedResource::reportMemoryUsage(memoryObjectInfo); |
| 247 } | 243 } |
| 248 | 244 |
| 249 | 245 |
| 250 } // namespace WebCore | 246 } // namespace WebCore |
| OLD | NEW |