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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 ResourcePtr<RawResource> protect(this); | 58 ResourcePtr<RawResource> protect(this); |
59 RawResourceClient* client = static_cast<RawResourceClient*>(c); | 59 RawResourceClient* client = static_cast<RawResourceClient*>(c); |
60 for (const auto& redirect : redirectChain()) { | 60 for (const auto& redirect : redirectChain()) { |
61 ResourceRequest request(redirect.m_request); | 61 ResourceRequest request(redirect.m_request); |
62 client->redirectReceived(this, request, redirect.m_redirectResponse); | 62 client->redirectReceived(this, request, redirect.m_redirectResponse); |
63 if (!hasClient(c)) | 63 if (!hasClient(c)) |
64 return; | 64 return; |
65 } | 65 } |
66 | 66 |
67 if (!m_response.isNull()) | 67 if (!m_response.isNull()) |
68 client->responseReceived(this, m_response); | 68 client->responseReceived(this, m_response, nullptr); |
69 if (!hasClient(c)) | 69 if (!hasClient(c)) |
70 return; | 70 return; |
71 if (m_data) | 71 if (m_data) |
72 client->dataReceived(this, m_data->data(), m_data->size()); | 72 client->dataReceived(this, m_data->data(), m_data->size()); |
73 if (!hasClient(c)) | 73 if (!hasClient(c)) |
74 return; | 74 return; |
75 Resource::didAddClient(client); | 75 Resource::didAddClient(client); |
76 } | 76 } |
77 | 77 |
78 void RawResource::willFollowRedirect(ResourceRequest& newRequest, const Resource
Response& redirectResponse) | 78 void RawResource::willFollowRedirect(ResourceRequest& newRequest, const Resource
Response& redirectResponse) |
79 { | 79 { |
80 ResourcePtr<RawResource> protect(this); | 80 ResourcePtr<RawResource> protect(this); |
81 if (!redirectResponse.isNull()) { | 81 if (!redirectResponse.isNull()) { |
82 ResourceClientWalker<RawResourceClient> w(m_clients); | 82 ResourceClientWalker<RawResourceClient> w(m_clients); |
83 while (RawResourceClient* c = w.next()) | 83 while (RawResourceClient* c = w.next()) |
84 c->redirectReceived(this, newRequest, redirectResponse); | 84 c->redirectReceived(this, newRequest, redirectResponse); |
85 } | 85 } |
86 Resource::willFollowRedirect(newRequest, redirectResponse); | 86 Resource::willFollowRedirect(newRequest, redirectResponse); |
87 } | 87 } |
88 | 88 |
89 void RawResource::updateRequest(const ResourceRequest& request) | 89 void RawResource::updateRequest(const ResourceRequest& request) |
90 { | 90 { |
91 ResourcePtr<RawResource> protect(this); | 91 ResourcePtr<RawResource> protect(this); |
92 ResourceClientWalker<RawResourceClient> w(m_clients); | 92 ResourceClientWalker<RawResourceClient> w(m_clients); |
93 while (RawResourceClient* c = w.next()) | 93 while (RawResourceClient* c = w.next()) |
94 c->updateRequest(this, request); | 94 c->updateRequest(this, request); |
95 } | 95 } |
96 | 96 |
97 void RawResource::responseReceived(const ResourceResponse& response) | 97 void RawResource::responseReceived(const ResourceResponse& response, PassOwnPtr<
WebDataConsumerHandle> handle) |
98 { | 98 { |
99 InternalResourcePtr protect(this); | 99 InternalResourcePtr protect(this); |
100 Resource::responseReceived(response); | 100 Resource::responseReceived(response, nullptr); |
101 ResourceClientWalker<RawResourceClient> w(m_clients); | 101 ResourceClientWalker<RawResourceClient> w(m_clients); |
102 while (RawResourceClient* c = w.next()) | 102 ASSERT(count() <= 1 || !handle); |
103 c->responseReceived(this, m_response); | 103 while (RawResourceClient* c = w.next()) { |
| 104 // |handle| is cleared when passed, but it's not a problem because |
| 105 // |handle| is null when there are two or more clients, as asserted. |
| 106 c->responseReceived(this, m_response, handle); |
| 107 } |
104 } | 108 } |
105 | 109 |
106 void RawResource::didSendData(unsigned long long bytesSent, unsigned long long t
otalBytesToBeSent) | 110 void RawResource::didSendData(unsigned long long bytesSent, unsigned long long t
otalBytesToBeSent) |
107 { | 111 { |
108 ResourceClientWalker<RawResourceClient> w(m_clients); | 112 ResourceClientWalker<RawResourceClient> w(m_clients); |
109 while (RawResourceClient* c = w.next()) | 113 while (RawResourceClient* c = w.next()) |
110 c->dataSent(this, bytesSent, totalBytesToBeSent); | 114 c->dataSent(this, bytesSent, totalBytesToBeSent); |
111 } | 115 } |
112 | 116 |
113 void RawResource::didDownloadData(int dataLength) | 117 void RawResource::didDownloadData(int dataLength) |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 for (const auto& header : oldHeaders) { | 183 for (const auto& header : oldHeaders) { |
180 AtomicString headerName = header.key; | 184 AtomicString headerName = header.key; |
181 if (!shouldIgnoreHeaderForCacheReuse(headerName) && header.value != newH
eaders.get(headerName)) | 185 if (!shouldIgnoreHeaderForCacheReuse(headerName) && header.value != newH
eaders.get(headerName)) |
182 return false; | 186 return false; |
183 } | 187 } |
184 | 188 |
185 return true; | 189 return true; |
186 } | 190 } |
187 | 191 |
188 } // namespace blink | 192 } // namespace blink |
OLD | NEW |