Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Side by Side Diff: Source/core/fetch/RawResource.cpp

Issue 603903003: [Streams] Pass WebDataConsumerHandle when the response arrives. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@web-data-pipe
Patch Set: rebase Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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);
Mike West 2014/11/04 15:09:30 Can 'count()' be 0?
yhirano 2014/11/05 04:38:40 Done.
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698