| 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 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/debug/alias.h" | 13 #include "base/debug/alias.h" |
| 14 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
| 15 #include "base/location.h" |
| 15 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/ref_counted_memory.h" | 17 #include "base/memory/ref_counted_memory.h" |
| 17 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 18 #include "base/message_loop/message_loop.h" | |
| 19 #include "base/profiler/scoped_tracker.h" | 19 #include "base/profiler/scoped_tracker.h" |
| 20 #include "base/single_thread_task_runner.h" |
| 20 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
| 21 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
| 22 #include "base/trace_event/trace_event.h" | 23 #include "base/trace_event/trace_event.h" |
| 23 #include "content/browser/appcache/view_appcache_internals_job.h" | 24 #include "content/browser/appcache/view_appcache_internals_job.h" |
| 24 #include "content/browser/fileapi/chrome_blob_storage_context.h" | 25 #include "content/browser/fileapi/chrome_blob_storage_context.h" |
| 25 #include "content/browser/histogram_internals_request_job.h" | 26 #include "content/browser/histogram_internals_request_job.h" |
| 26 #include "content/browser/net/view_blob_internals_job_factory.h" | 27 #include "content/browser/net/view_blob_internals_job_factory.h" |
| 27 #include "content/browser/net/view_http_cache_job_factory.h" | 28 #include "content/browser/net/view_http_cache_job_factory.h" |
| 28 #include "content/browser/resource_context_impl.h" | 29 #include "content/browser/resource_context_impl.h" |
| 29 #include "content/browser/tcmalloc_internals_request_job.h" | 30 #include "content/browser/tcmalloc_internals_request_job.h" |
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 // on for this path. Call directly into it from this thread, the IO | 633 // on for this path. Call directly into it from this thread, the IO |
| 633 // thread. | 634 // thread. |
| 634 source->source()->StartDataRequest( | 635 source->source()->StartDataRequest( |
| 635 path, render_process_id, render_frame_id, | 636 path, render_process_id, render_frame_id, |
| 636 base::Bind(&URLDataSourceImpl::SendResponse, source, request_id)); | 637 base::Bind(&URLDataSourceImpl::SendResponse, source, request_id)); |
| 637 } else { | 638 } else { |
| 638 // URLRequestChromeJob should receive mime type before data. This | 639 // URLRequestChromeJob should receive mime type before data. This |
| 639 // is guaranteed because request for mime type is placed in the | 640 // is guaranteed because request for mime type is placed in the |
| 640 // message loop before request for data. And correspondingly their | 641 // message loop before request for data. And correspondingly their |
| 641 // replies are put on the IO thread in the same order. | 642 // replies are put on the IO thread in the same order. |
| 642 target_message_loop->PostTask( | 643 target_message_loop->task_runner()->PostTask( |
| 643 FROM_HERE, | 644 FROM_HERE, |
| 644 base::Bind(&GetMimeTypeOnUI, | 645 base::Bind(&GetMimeTypeOnUI, scoped_refptr<URLDataSourceImpl>(source), |
| 645 scoped_refptr<URLDataSourceImpl>(source), | |
| 646 path, job->AsWeakPtr())); | 646 path, job->AsWeakPtr())); |
| 647 | 647 |
| 648 // The DataSource wants StartDataRequest to be called on a specific thread, | 648 // The DataSource wants StartDataRequest to be called on a specific thread, |
| 649 // usually the UI thread, for this path. | 649 // usually the UI thread, for this path. |
| 650 target_message_loop->PostTask( | 650 target_message_loop->task_runner()->PostTask( |
| 651 FROM_HERE, | 651 FROM_HERE, base::Bind(&URLDataManagerBackend::CallStartRequest, |
| 652 base::Bind(&URLDataManagerBackend::CallStartRequest, | 652 make_scoped_refptr(source), path, |
| 653 make_scoped_refptr(source), path, render_process_id, | 653 render_process_id, render_frame_id, request_id)); |
| 654 render_frame_id, request_id)); | |
| 655 } | 654 } |
| 656 return true; | 655 return true; |
| 657 } | 656 } |
| 658 | 657 |
| 659 URLDataSourceImpl* URLDataManagerBackend::GetDataSourceFromURL( | 658 URLDataSourceImpl* URLDataManagerBackend::GetDataSourceFromURL( |
| 660 const GURL& url) { | 659 const GURL& url) { |
| 661 // The input usually looks like: chrome://source_name/extra_bits?foo | 660 // The input usually looks like: chrome://source_name/extra_bits?foo |
| 662 // so do a lookup using the host of the URL. | 661 // so do a lookup using the host of the URL. |
| 663 DataSourceMap::iterator i = data_sources_.find(url.host()); | 662 DataSourceMap::iterator i = data_sources_.find(url.host()); |
| 664 if (i != data_sources_.end()) | 663 if (i != data_sources_.end()) |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 | 764 |
| 766 } // namespace | 765 } // namespace |
| 767 | 766 |
| 768 net::URLRequestJobFactory::ProtocolHandler* | 767 net::URLRequestJobFactory::ProtocolHandler* |
| 769 CreateDevToolsProtocolHandler(content::ResourceContext* resource_context, | 768 CreateDevToolsProtocolHandler(content::ResourceContext* resource_context, |
| 770 bool is_incognito) { | 769 bool is_incognito) { |
| 771 return new DevToolsJobFactory(resource_context, is_incognito); | 770 return new DevToolsJobFactory(resource_context, is_incognito); |
| 772 } | 771 } |
| 773 | 772 |
| 774 } // namespace content | 773 } // namespace content |
| OLD | NEW |