| 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 23 matching lines...) Expand all Loading... |
| 34 #include "content/browser/webui/shared_resources_data_source.h" | 34 #include "content/browser/webui/shared_resources_data_source.h" |
| 35 #include "content/browser/webui/url_data_source_impl.h" | 35 #include "content/browser/webui/url_data_source_impl.h" |
| 36 #include "content/public/browser/browser_context.h" | 36 #include "content/public/browser/browser_context.h" |
| 37 #include "content/public/browser/browser_thread.h" | 37 #include "content/public/browser/browser_thread.h" |
| 38 #include "content/public/browser/content_browser_client.h" | 38 #include "content/public/browser/content_browser_client.h" |
| 39 #include "content/public/browser/render_process_host.h" | 39 #include "content/public/browser/render_process_host.h" |
| 40 #include "content/public/browser/resource_request_info.h" | 40 #include "content/public/browser/resource_request_info.h" |
| 41 #include "content/public/common/url_constants.h" | 41 #include "content/public/common/url_constants.h" |
| 42 #include "net/base/io_buffer.h" | 42 #include "net/base/io_buffer.h" |
| 43 #include "net/base/net_errors.h" | 43 #include "net/base/net_errors.h" |
| 44 #include "net/filter/filter.h" | 44 #include "net/filter/gzip_source_stream.h" |
| 45 #include "net/filter/source_stream.h" |
| 45 #include "net/http/http_response_headers.h" | 46 #include "net/http/http_response_headers.h" |
| 46 #include "net/http/http_status_code.h" | 47 #include "net/http/http_status_code.h" |
| 47 #include "net/log/net_log_util.h" | 48 #include "net/log/net_log_util.h" |
| 48 #include "net/url_request/url_request.h" | 49 #include "net/url_request/url_request.h" |
| 49 #include "net/url_request/url_request_context.h" | 50 #include "net/url_request/url_request_context.h" |
| 50 #include "net/url_request/url_request_error_job.h" | 51 #include "net/url_request/url_request_error_job.h" |
| 51 #include "net/url_request/url_request_job.h" | 52 #include "net/url_request/url_request_job.h" |
| 52 #include "net/url_request/url_request_job_factory.h" | 53 #include "net/url_request/url_request_job_factory.h" |
| 53 #include "url/url_util.h" | 54 #include "url/url_util.h" |
| 54 | 55 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 URLDataManagerBackend* backend, | 137 URLDataManagerBackend* backend, |
| 137 bool is_incognito); | 138 bool is_incognito); |
| 138 | 139 |
| 139 // net::URLRequestJob implementation. | 140 // net::URLRequestJob implementation. |
| 140 void Start() override; | 141 void Start() override; |
| 141 void Kill() override; | 142 void Kill() override; |
| 142 int ReadRawData(net::IOBuffer* buf, int buf_size) override; | 143 int ReadRawData(net::IOBuffer* buf, int buf_size) override; |
| 143 bool GetMimeType(std::string* mime_type) const override; | 144 bool GetMimeType(std::string* mime_type) const override; |
| 144 int GetResponseCode() const override; | 145 int GetResponseCode() const override; |
| 145 void GetResponseInfo(net::HttpResponseInfo* info) override; | 146 void GetResponseInfo(net::HttpResponseInfo* info) override; |
| 146 std::unique_ptr<net::Filter> SetupFilter() const override; | 147 std::unique_ptr<net::SourceStream> SetUpSourceStream() override; |
| 147 | 148 |
| 148 // Used to notify that the requested data's |mime_type| is ready. | 149 // Used to notify that the requested data's |mime_type| is ready. |
| 149 void MimeTypeAvailable(const std::string& mime_type); | 150 void MimeTypeAvailable(const std::string& mime_type); |
| 150 | 151 |
| 151 // Called by ChromeURLDataManager to notify us that the data blob is ready | 152 // Called by ChromeURLDataManager to notify us that the data blob is ready |
| 152 // for us. |bytes| may be null, indicating an error. | 153 // for us. |bytes| may be null, indicating an error. |
| 153 void DataAvailable(base::RefCountedMemory* bytes); | 154 void DataAvailable(base::RefCountedMemory* bytes); |
| 154 | 155 |
| 155 // Returns a weak pointer to the job. | 156 // Returns a weak pointer to the job. |
| 156 base::WeakPtr<URLRequestChromeJob> AsWeakPtr(); | 157 base::WeakPtr<URLRequestChromeJob> AsWeakPtr(); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 if (!access_control_allow_origin_.empty()) { | 387 if (!access_control_allow_origin_.empty()) { |
| 387 info->headers->AddHeader("Access-Control-Allow-Origin: " + | 388 info->headers->AddHeader("Access-Control-Allow-Origin: " + |
| 388 access_control_allow_origin_); | 389 access_control_allow_origin_); |
| 389 info->headers->AddHeader("Vary: Origin"); | 390 info->headers->AddHeader("Vary: Origin"); |
| 390 } | 391 } |
| 391 | 392 |
| 392 if (is_gzipped_) | 393 if (is_gzipped_) |
| 393 info->headers->AddHeader("Content-Encoding: gzip"); | 394 info->headers->AddHeader("Content-Encoding: gzip"); |
| 394 } | 395 } |
| 395 | 396 |
| 396 std::unique_ptr<net::Filter> URLRequestChromeJob::SetupFilter() const { | 397 std::unique_ptr<net::SourceStream> URLRequestChromeJob::SetUpSourceStream() { |
| 397 return is_gzipped_ ? net::Filter::GZipFactory() : nullptr; | 398 std::unique_ptr<net::SourceStream> source = |
| 399 net::URLRequestJob::SetUpSourceStream(); |
| 400 return is_gzipped_ ? net::GzipSourceStream::Create( |
| 401 std::move(source), net::SourceStream::TYPE_GZIP) |
| 402 : std::move(source); |
| 398 } | 403 } |
| 399 | 404 |
| 400 void URLRequestChromeJob::MimeTypeAvailable(const std::string& mime_type) { | 405 void URLRequestChromeJob::MimeTypeAvailable(const std::string& mime_type) { |
| 401 set_mime_type(mime_type); | 406 set_mime_type(mime_type); |
| 402 NotifyHeadersComplete(); | 407 NotifyHeadersComplete(); |
| 403 } | 408 } |
| 404 | 409 |
| 405 void URLRequestChromeJob::DataAvailable(base::RefCountedMemory* bytes) { | 410 void URLRequestChromeJob::DataAvailable(base::RefCountedMemory* bytes) { |
| 406 TRACE_EVENT_ASYNC_END0("browser", "DataManager:Request", this); | 411 TRACE_EVENT_ASYNC_END0("browser", "DataManager:Request", this); |
| 407 DCHECK(!data_); | 412 DCHECK(!data_); |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 | 849 |
| 845 } // namespace | 850 } // namespace |
| 846 | 851 |
| 847 net::URLRequestJobFactory::ProtocolHandler* CreateDevToolsProtocolHandler( | 852 net::URLRequestJobFactory::ProtocolHandler* CreateDevToolsProtocolHandler( |
| 848 ResourceContext* resource_context, | 853 ResourceContext* resource_context, |
| 849 bool is_incognito) { | 854 bool is_incognito) { |
| 850 return new DevToolsJobFactory(resource_context, is_incognito); | 855 return new DevToolsJobFactory(resource_context, is_incognito); |
| 851 } | 856 } |
| 852 | 857 |
| 853 } // namespace content | 858 } // namespace content |
| OLD | NEW |