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