| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/webui/url_data_manager_backend.h" | 5 #include "content/browser/webui/url_data_manager_backend.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 URLRequestChromeJob(net::URLRequest* request, | 138 URLRequestChromeJob(net::URLRequest* request, |
| 139 net::NetworkDelegate* network_delegate, | 139 net::NetworkDelegate* network_delegate, |
| 140 URLDataManagerBackend* backend, | 140 URLDataManagerBackend* backend, |
| 141 bool is_incognito); | 141 bool is_incognito); |
| 142 | 142 |
| 143 // net::URLRequestJob implementation. | 143 // net::URLRequestJob implementation. |
| 144 void Start() override; | 144 void Start() override; |
| 145 void Kill() override; | 145 void Kill() override; |
| 146 int ReadRawData(net::IOBuffer* buf, int buf_size) override; | 146 int ReadRawData(net::IOBuffer* buf, int buf_size) override; |
| 147 bool GetMimeType(std::string* mime_type) const override; | 147 bool GetMimeType(std::string* mime_type) const override; |
| 148 int GetResponseCode() const override; | |
| 149 void GetResponseInfo(net::HttpResponseInfo* info) override; | 148 void GetResponseInfo(net::HttpResponseInfo* info) override; |
| 150 std::unique_ptr<net::SourceStream> SetUpSourceStream() override; | 149 std::unique_ptr<net::SourceStream> SetUpSourceStream() override; |
| 151 | 150 |
| 152 // Used to notify that the requested data's |mime_type| is ready. | 151 // Used to notify that the requested data's |mime_type| is ready. |
| 153 void MimeTypeAvailable(const std::string& mime_type); | 152 void MimeTypeAvailable(const std::string& mime_type); |
| 154 | 153 |
| 155 // Called by ChromeURLDataManager to notify us that the data blob is ready | 154 // Called by ChromeURLDataManager to notify us that the data blob is ready |
| 156 // for us. |bytes| may be null, indicating an error. | 155 // for us. |bytes| may be null, indicating an error. |
| 157 void DataAvailable(base::RefCountedMemory* bytes); | 156 void DataAvailable(base::RefCountedMemory* bytes); |
| 158 | 157 |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 weak_factory_.InvalidateWeakPtrs(); | 350 weak_factory_.InvalidateWeakPtrs(); |
| 352 backend_->RemoveRequest(this); | 351 backend_->RemoveRequest(this); |
| 353 URLRequestJob::Kill(); | 352 URLRequestJob::Kill(); |
| 354 } | 353 } |
| 355 | 354 |
| 356 bool URLRequestChromeJob::GetMimeType(std::string* mime_type) const { | 355 bool URLRequestChromeJob::GetMimeType(std::string* mime_type) const { |
| 357 *mime_type = mime_type_; | 356 *mime_type = mime_type_; |
| 358 return !mime_type_.empty(); | 357 return !mime_type_.empty(); |
| 359 } | 358 } |
| 360 | 359 |
| 361 int URLRequestChromeJob::GetResponseCode() const { | |
| 362 return net::HTTP_OK; | |
| 363 } | |
| 364 | |
| 365 void URLRequestChromeJob::GetResponseInfo(net::HttpResponseInfo* info) { | 360 void URLRequestChromeJob::GetResponseInfo(net::HttpResponseInfo* info) { |
| 366 DCHECK(!info->headers.get()); | 361 DCHECK(!info->headers.get()); |
| 367 // Set the headers so that requests serviced by ChromeURLDataManager return a | 362 // Set the headers so that requests serviced by ChromeURLDataManager return a |
| 368 // status code of 200. Without this they return a 0, which makes the status | 363 // status code of 200. Without this they return a 0, which makes the status |
| 369 // indistiguishable from other error types. Instant relies on getting a 200. | 364 // indistiguishable from other error types. Instant relies on getting a 200. |
| 370 info->headers = new net::HttpResponseHeaders("HTTP/1.1 200 OK"); | 365 info->headers = new net::HttpResponseHeaders("HTTP/1.1 200 OK"); |
| 371 | 366 |
| 372 // Determine the least-privileged content security policy header, if any, | 367 // Determine the least-privileged content security policy header, if any, |
| 373 // that is compatible with a given WebUI URL, and append it to the existing | 368 // that is compatible with a given WebUI URL, and append it to the existing |
| 374 // response headers. | 369 // response headers. |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 | 850 |
| 856 } // namespace | 851 } // namespace |
| 857 | 852 |
| 858 net::URLRequestJobFactory::ProtocolHandler* CreateDevToolsProtocolHandler( | 853 net::URLRequestJobFactory::ProtocolHandler* CreateDevToolsProtocolHandler( |
| 859 ResourceContext* resource_context, | 854 ResourceContext* resource_context, |
| 860 bool is_incognito) { | 855 bool is_incognito) { |
| 861 return new DevToolsJobFactory(resource_context, is_incognito); | 856 return new DevToolsJobFactory(resource_context, is_incognito); |
| 862 } | 857 } |
| 863 | 858 |
| 864 } // namespace content | 859 } // namespace content |
| OLD | NEW |