| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 { | 59 { |
| 60 // This must be called only after m_event is signalled. | 60 // This must be called only after m_event is signalled. |
| 61 MutexLocker lock(m_lock); | 61 MutexLocker lock(m_lock); |
| 62 ASSERT(m_done); | 62 ASSERT(m_done); |
| 63 for (size_t i = 0; i < m_clientTasks.size(); ++i) | 63 for (size_t i = 0; i < m_clientTasks.size(); ++i) |
| 64 (*m_clientTasks[i])(); | 64 (*m_clientTasks[i])(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void WorkerLoaderClientBridgeSyncHelper::didSendData(unsigned long long bytesSen
t, unsigned long long totalBytesToBeSent) | 67 void WorkerLoaderClientBridgeSyncHelper::didSendData(unsigned long long bytesSen
t, unsigned long long totalBytesToBeSent) |
| 68 { | 68 { |
| 69 RELEASE_ASSERT(!m_done); |
| 70 |
| 69 MutexLocker lock(m_lock); | 71 MutexLocker lock(m_lock); |
| 70 ASSERT(isMainThread()); | 72 ASSERT(isMainThread()); |
| 71 m_clientTasks.append(bind(&ThreadableLoaderClient::didSendData, &m_client, b
ytesSent, totalBytesToBeSent)); | 73 m_clientTasks.append(bind(&ThreadableLoaderClient::didSendData, &m_client, b
ytesSent, totalBytesToBeSent)); |
| 72 } | 74 } |
| 73 | 75 |
| 74 static void didReceiveResponseAdapter(ThreadableLoaderClient* client, unsigned l
ong identifier, PassOwnPtr<CrossThreadResourceResponseData> responseData, PassOw
nPtr<WebDataConsumerHandle> handle) | 76 static void didReceiveResponseAdapter(ThreadableLoaderClient* client, unsigned l
ong identifier, PassOwnPtr<CrossThreadResourceResponseData> responseData, PassOw
nPtr<WebDataConsumerHandle> handle) |
| 75 { | 77 { |
| 76 OwnPtr<ResourceResponse> response(ResourceResponse::adopt(responseData)); | 78 OwnPtr<ResourceResponse> response(ResourceResponse::adopt(responseData)); |
| 77 client->didReceiveResponse(identifier, *response, handle); | 79 client->didReceiveResponse(identifier, *response, handle); |
| 78 } | 80 } |
| 79 | 81 |
| 80 void WorkerLoaderClientBridgeSyncHelper::didReceiveResponse(unsigned long identi
fier, const ResourceResponse& response, PassOwnPtr<WebDataConsumerHandle> handle
) | 82 void WorkerLoaderClientBridgeSyncHelper::didReceiveResponse(unsigned long identi
fier, const ResourceResponse& response, PassOwnPtr<WebDataConsumerHandle> handle
) |
| 81 { | 83 { |
| 84 RELEASE_ASSERT(!m_done); |
| 85 |
| 82 MutexLocker lock(m_lock); | 86 MutexLocker lock(m_lock); |
| 83 ASSERT(isMainThread()); | 87 ASSERT(isMainThread()); |
| 84 m_clientTasks.append(bind(&didReceiveResponseAdapter, &m_client, identifier,
response.copyData(), handle)); | 88 m_clientTasks.append(bind(&didReceiveResponseAdapter, &m_client, identifier,
response.copyData(), handle)); |
| 85 } | 89 } |
| 86 | 90 |
| 87 void WorkerLoaderClientBridgeSyncHelper::didReceiveData(const char* data, unsign
ed dataLength) | 91 void WorkerLoaderClientBridgeSyncHelper::didReceiveData(const char* data, unsign
ed dataLength) |
| 88 { | 92 { |
| 93 RELEASE_ASSERT(!m_done); |
| 94 |
| 89 MutexLocker lock(m_lock); | 95 MutexLocker lock(m_lock); |
| 90 ASSERT(isMainThread()); | 96 ASSERT(isMainThread()); |
| 91 Vector<char>* buffer = new Vector<char>(dataLength); | 97 Vector<char>* buffer = new Vector<char>(dataLength); |
| 92 memcpy(buffer->data(), data, dataLength); | 98 memcpy(buffer->data(), data, dataLength); |
| 93 m_receivedData.append(buffer); | 99 m_receivedData.append(buffer); |
| 94 m_clientTasks.append(bind(&ThreadableLoaderClient::didReceiveData, &m_client
, static_cast<const char*>(buffer->data()), dataLength)); | 100 m_clientTasks.append(bind(&ThreadableLoaderClient::didReceiveData, &m_client
, static_cast<const char*>(buffer->data()), dataLength)); |
| 95 } | 101 } |
| 96 | 102 |
| 97 void WorkerLoaderClientBridgeSyncHelper::didDownloadData(int dataLength) | 103 void WorkerLoaderClientBridgeSyncHelper::didDownloadData(int dataLength) |
| 98 { | 104 { |
| 105 RELEASE_ASSERT(!m_done); |
| 106 |
| 99 MutexLocker lock(m_lock); | 107 MutexLocker lock(m_lock); |
| 100 ASSERT(isMainThread()); | 108 ASSERT(isMainThread()); |
| 101 m_clientTasks.append(bind(&ThreadableLoaderClient::didDownloadData, &m_clien
t, dataLength)); | 109 m_clientTasks.append(bind(&ThreadableLoaderClient::didDownloadData, &m_clien
t, dataLength)); |
| 102 } | 110 } |
| 103 | 111 |
| 104 void WorkerLoaderClientBridgeSyncHelper::didReceiveCachedMetadata(const char* da
ta, int dataLength) | 112 void WorkerLoaderClientBridgeSyncHelper::didReceiveCachedMetadata(const char* da
ta, int dataLength) |
| 105 { | 113 { |
| 114 RELEASE_ASSERT(!m_done); |
| 115 |
| 106 MutexLocker lock(m_lock); | 116 MutexLocker lock(m_lock); |
| 107 ASSERT(isMainThread()); | 117 ASSERT(isMainThread()); |
| 108 Vector<char>* buffer = new Vector<char>(dataLength); | 118 Vector<char>* buffer = new Vector<char>(dataLength); |
| 109 memcpy(buffer->data(), data, dataLength); | 119 memcpy(buffer->data(), data, dataLength); |
| 110 m_receivedData.append(buffer); | 120 m_receivedData.append(buffer); |
| 111 m_clientTasks.append(bind(&ThreadableLoaderClient::didReceiveCachedMetadata,
&m_client, static_cast<const char*>(buffer->data()), dataLength)); | 121 m_clientTasks.append(bind(&ThreadableLoaderClient::didReceiveCachedMetadata,
&m_client, static_cast<const char*>(buffer->data()), dataLength)); |
| 112 } | 122 } |
| 113 | 123 |
| 114 void WorkerLoaderClientBridgeSyncHelper::didFinishLoading(unsigned long identifi
er, double finishTime) | 124 void WorkerLoaderClientBridgeSyncHelper::didFinishLoading(unsigned long identifi
er, double finishTime) |
| 115 { | 125 { |
| 126 RELEASE_ASSERT(!m_done); |
| 127 |
| 116 MutexLocker lock(m_lock); | 128 MutexLocker lock(m_lock); |
| 117 ASSERT(isMainThread()); | 129 ASSERT(isMainThread()); |
| 118 m_clientTasks.append(bind(&ThreadableLoaderClient::didFinishLoading, &m_clie
nt, identifier, finishTime)); | 130 m_clientTasks.append(bind(&ThreadableLoaderClient::didFinishLoading, &m_clie
nt, identifier, finishTime)); |
| 119 m_done = true; | 131 m_done = true; |
| 120 m_event->signal(); | 132 m_event->signal(); |
| 121 } | 133 } |
| 122 | 134 |
| 123 void WorkerLoaderClientBridgeSyncHelper::didFail(const ResourceError& error) | 135 void WorkerLoaderClientBridgeSyncHelper::didFail(const ResourceError& error) |
| 124 { | 136 { |
| 137 RELEASE_ASSERT(!m_done); |
| 138 |
| 125 MutexLocker lock(m_lock); | 139 MutexLocker lock(m_lock); |
| 126 ASSERT(isMainThread()); | 140 ASSERT(isMainThread()); |
| 127 m_clientTasks.append(bind(&ThreadableLoaderClient::didFail, &m_client, error
.copy())); | 141 m_clientTasks.append(bind(&ThreadableLoaderClient::didFail, &m_client, error
.copy())); |
| 128 m_done = true; | 142 m_done = true; |
| 129 m_event->signal(); | 143 m_event->signal(); |
| 130 } | 144 } |
| 131 | 145 |
| 132 void WorkerLoaderClientBridgeSyncHelper::didFailAccessControlCheck(const Resourc
eError& error) | 146 void WorkerLoaderClientBridgeSyncHelper::didFailAccessControlCheck(const Resourc
eError& error) |
| 133 { | 147 { |
| 148 RELEASE_ASSERT(!m_done); |
| 149 |
| 134 MutexLocker lock(m_lock); | 150 MutexLocker lock(m_lock); |
| 135 ASSERT(isMainThread()); | 151 ASSERT(isMainThread()); |
| 136 m_clientTasks.append(bind(&ThreadableLoaderClient::didFailAccessControlCheck
, &m_client, error.copy())); | 152 m_clientTasks.append(bind(&ThreadableLoaderClient::didFailAccessControlCheck
, &m_client, error.copy())); |
| 137 m_done = true; | 153 m_done = true; |
| 138 m_event->signal(); | 154 m_event->signal(); |
| 139 } | 155 } |
| 140 | 156 |
| 141 void WorkerLoaderClientBridgeSyncHelper::didFailRedirectCheck() | 157 void WorkerLoaderClientBridgeSyncHelper::didFailRedirectCheck() |
| 142 { | 158 { |
| 159 RELEASE_ASSERT(!m_done); |
| 160 |
| 143 MutexLocker lock(m_lock); | 161 MutexLocker lock(m_lock); |
| 144 ASSERT(isMainThread()); | 162 ASSERT(isMainThread()); |
| 145 m_clientTasks.append(bind(&ThreadableLoaderClient::didFailRedirectCheck, &m_
client)); | 163 m_clientTasks.append(bind(&ThreadableLoaderClient::didFailRedirectCheck, &m_
client)); |
| 146 m_done = true; | 164 m_done = true; |
| 147 m_event->signal(); | 165 m_event->signal(); |
| 148 } | 166 } |
| 149 | 167 |
| 150 WorkerLoaderClientBridgeSyncHelper::WorkerLoaderClientBridgeSyncHelper(Threadabl
eLoaderClient& client, PassOwnPtr<blink::WebWaitableEvent> event) | 168 WorkerLoaderClientBridgeSyncHelper::WorkerLoaderClientBridgeSyncHelper(Threadabl
eLoaderClient& client, PassOwnPtr<blink::WebWaitableEvent> event) |
| 151 : m_done(false) | 169 : m_done(false) |
| 152 , m_client(client) | 170 , m_client(client) |
| 153 , m_event(event) | 171 , m_event(event) |
| 154 { | 172 { |
| 155 ASSERT(m_event); | 173 ASSERT(m_event); |
| 156 } | 174 } |
| 157 | 175 |
| 158 } // namespace blink | 176 } // namespace blink |
| OLD | NEW |