| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ios/web/webui/url_data_manager_ios_backend.h" | 5 #include "ios/web/webui/url_data_manager_ios_backend.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 URLRequestChromeJob(net::URLRequest* request, | 97 URLRequestChromeJob(net::URLRequest* request, |
| 98 net::NetworkDelegate* network_delegate, | 98 net::NetworkDelegate* network_delegate, |
| 99 BrowserState* browser_state, | 99 BrowserState* browser_state, |
| 100 bool is_incognito); | 100 bool is_incognito); |
| 101 | 101 |
| 102 // net::URLRequestJob implementation. | 102 // net::URLRequestJob implementation. |
| 103 void Start() override; | 103 void Start() override; |
| 104 void Kill() override; | 104 void Kill() override; |
| 105 int ReadRawData(net::IOBuffer* buf, int buf_size) override; | 105 int ReadRawData(net::IOBuffer* buf, int buf_size) override; |
| 106 bool GetMimeType(std::string* mime_type) const override; | 106 bool GetMimeType(std::string* mime_type) const override; |
| 107 int GetResponseCode() const override; | |
| 108 void GetResponseInfo(net::HttpResponseInfo* info) override; | 107 void GetResponseInfo(net::HttpResponseInfo* info) override; |
| 109 | 108 |
| 110 // Used to notify that the requested data's |mime_type| is ready. | 109 // Used to notify that the requested data's |mime_type| is ready. |
| 111 void MimeTypeAvailable(const std::string& mime_type); | 110 void MimeTypeAvailable(const std::string& mime_type); |
| 112 | 111 |
| 113 // Called by ChromeURLDataManagerIOS to notify us that the data blob is ready | 112 // Called by ChromeURLDataManagerIOS to notify us that the data blob is ready |
| 114 // for us. | 113 // for us. |
| 115 void DataAvailable(base::RefCountedMemory* bytes); | 114 void DataAvailable(base::RefCountedMemory* bytes); |
| 116 | 115 |
| 117 void set_mime_type(const std::string& mime_type) { mime_type_ = mime_type; } | 116 void set_mime_type(const std::string& mime_type) { mime_type_ = mime_type; } |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 if (backend_) | 242 if (backend_) |
| 244 backend_->RemoveRequest(this); | 243 backend_->RemoveRequest(this); |
| 245 URLRequestJob::Kill(); | 244 URLRequestJob::Kill(); |
| 246 } | 245 } |
| 247 | 246 |
| 248 bool URLRequestChromeJob::GetMimeType(std::string* mime_type) const { | 247 bool URLRequestChromeJob::GetMimeType(std::string* mime_type) const { |
| 249 *mime_type = mime_type_; | 248 *mime_type = mime_type_; |
| 250 return !mime_type_.empty(); | 249 return !mime_type_.empty(); |
| 251 } | 250 } |
| 252 | 251 |
| 253 int URLRequestChromeJob::GetResponseCode() const { | |
| 254 return net::HTTP_OK; | |
| 255 } | |
| 256 | |
| 257 void URLRequestChromeJob::GetResponseInfo(net::HttpResponseInfo* info) { | 252 void URLRequestChromeJob::GetResponseInfo(net::HttpResponseInfo* info) { |
| 258 DCHECK(!info->headers.get()); | 253 DCHECK(!info->headers.get()); |
| 259 // Set the headers so that requests serviced by ChromeURLDataManagerIOS | 254 // Set the headers so that requests serviced by ChromeURLDataManagerIOS |
| 260 // return a status code of 200. Without this they return a 0, which makes the | 255 // return a status code of 200. Without this they return a 0, which makes the |
| 261 // status indistiguishable from other error types. Instant relies on getting | 256 // status indistiguishable from other error types. Instant relies on getting |
| 262 // a 200. | 257 // a 200. |
| 263 info->headers = new net::HttpResponseHeaders("HTTP/1.1 200 OK"); | 258 info->headers = new net::HttpResponseHeaders("HTTP/1.1 200 OK"); |
| 264 | 259 |
| 265 // Determine the least-privileged content security policy header, if any, | 260 // Determine the least-privileged content security policy header, if any, |
| 266 // that is compatible with a given WebUI URL, and append it to the existing | 261 // that is compatible with a given WebUI URL, and append it to the existing |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 // Forward this data on to the pending net::URLRequest, if it exists. | 516 // Forward this data on to the pending net::URLRequest, if it exists. |
| 522 PendingRequestMap::iterator i = pending_requests_.find(request_id); | 517 PendingRequestMap::iterator i = pending_requests_.find(request_id); |
| 523 if (i != pending_requests_.end()) { | 518 if (i != pending_requests_.end()) { |
| 524 URLRequestChromeJob* job(i->second); | 519 URLRequestChromeJob* job(i->second); |
| 525 pending_requests_.erase(i); | 520 pending_requests_.erase(i); |
| 526 job->DataAvailable(bytes); | 521 job->DataAvailable(bytes); |
| 527 } | 522 } |
| 528 } | 523 } |
| 529 | 524 |
| 530 } // namespace web | 525 } // namespace web |
| OLD | NEW |