| 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 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 // Look up additional request info to pass down. | 704 // Look up additional request info to pass down. |
| 705 int child_id = -1; | 705 int child_id = -1; |
| 706 ResourceRequestInfo::WebContentsGetter wc_getter; | 706 ResourceRequestInfo::WebContentsGetter wc_getter; |
| 707 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); | 707 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); |
| 708 if (info) { | 708 if (info) { |
| 709 child_id = info->GetChildID(); | 709 child_id = info->GetChildID(); |
| 710 wc_getter = info->GetWebContentsGetterForRequest(); | 710 wc_getter = info->GetWebContentsGetterForRequest(); |
| 711 } | 711 } |
| 712 | 712 |
| 713 // Forward along the request to the data source. | 713 // Forward along the request to the data source. |
| 714 base::MessageLoop* target_message_loop = | 714 scoped_refptr<base::SingleThreadTaskRunner> target_runner = |
| 715 source->source()->MessageLoopForRequestPath(path); | 715 source->source()->TaskRunnerForRequestPath(path); |
| 716 if (!target_message_loop) { | 716 if (!target_runner) { |
| 717 job->MimeTypeAvailable(source->source()->GetMimeType(path)); | 717 job->MimeTypeAvailable(source->source()->GetMimeType(path)); |
| 718 // Eliminate potentially dangling pointer to avoid future use. | 718 // Eliminate potentially dangling pointer to avoid future use. |
| 719 job = nullptr; | 719 job = nullptr; |
| 720 | 720 |
| 721 // The DataSource is agnostic to which thread StartDataRequest is called | 721 // The DataSource is agnostic to which thread StartDataRequest is called |
| 722 // on for this path. Call directly into it from this thread, the IO | 722 // on for this path. Call directly into it from this thread, the IO |
| 723 // thread. | 723 // thread. |
| 724 source->source()->StartDataRequest( | 724 source->source()->StartDataRequest( |
| 725 path, wc_getter, | 725 path, wc_getter, |
| 726 base::Bind(&URLDataSourceImpl::SendResponse, source, request_id)); | 726 base::Bind(&URLDataSourceImpl::SendResponse, source, request_id)); |
| 727 } else { | 727 } else { |
| 728 // URLRequestChromeJob should receive mime type before data. This | 728 // URLRequestChromeJob should receive mime type before data. This |
| 729 // is guaranteed because request for mime type is placed in the | 729 // is guaranteed because request for mime type is placed in the |
| 730 // message loop before request for data. And correspondingly their | 730 // message loop before request for data. And correspondingly their |
| 731 // replies are put on the IO thread in the same order. | 731 // replies are put on the IO thread in the same order. |
| 732 target_message_loop->task_runner()->PostTask( | 732 target_runner->PostTask( |
| 733 FROM_HERE, base::Bind(&GetMimeTypeOnUI, base::RetainedRef(source), path, | 733 FROM_HERE, base::Bind(&GetMimeTypeOnUI, base::RetainedRef(source), path, |
| 734 job->AsWeakPtr())); | 734 job->AsWeakPtr())); |
| 735 | 735 |
| 736 // The DataSource wants StartDataRequest to be called on a specific thread, | 736 // The DataSource wants StartDataRequest to be called on a specific thread, |
| 737 // usually the UI thread, for this path. | 737 // usually the UI thread, for this path. |
| 738 target_message_loop->task_runner()->PostTask( | 738 target_runner->PostTask( |
| 739 FROM_HERE, base::Bind(&URLDataManagerBackend::CallStartRequest, | 739 FROM_HERE, base::Bind(&URLDataManagerBackend::CallStartRequest, |
| 740 base::RetainedRef(source), path, child_id, | 740 base::RetainedRef(source), path, child_id, |
| 741 wc_getter, request_id)); | 741 wc_getter, request_id)); |
| 742 } | 742 } |
| 743 return true; | 743 return true; |
| 744 } | 744 } |
| 745 | 745 |
| 746 URLDataSourceImpl* URLDataManagerBackend::GetDataSourceFromURL( | 746 URLDataSourceImpl* URLDataManagerBackend::GetDataSourceFromURL( |
| 747 const GURL& url) { | 747 const GURL& url) { |
| 748 // The input usually looks like: chrome://source_name/extra_bits?foo | 748 // The input usually looks like: chrome://source_name/extra_bits?foo |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 | 849 |
| 850 } // namespace | 850 } // namespace |
| 851 | 851 |
| 852 net::URLRequestJobFactory::ProtocolHandler* CreateDevToolsProtocolHandler( | 852 net::URLRequestJobFactory::ProtocolHandler* CreateDevToolsProtocolHandler( |
| 853 ResourceContext* resource_context, | 853 ResourceContext* resource_context, |
| 854 bool is_incognito) { | 854 bool is_incognito) { |
| 855 return new DevToolsJobFactory(resource_context, is_incognito); | 855 return new DevToolsJobFactory(resource_context, is_incognito); |
| 856 } | 856 } |
| 857 | 857 |
| 858 } // namespace content | 858 } // namespace content |
| OLD | NEW |