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" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/debug/alias.h" | 12 #include "base/debug/alias.h" |
13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/memory/ref_counted_memory.h" | 17 #include "base/memory/ref_counted_memory.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "base/message_loop/message_loop.h" | 19 #include "base/message_loop/message_loop.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 "ios/web/public/browser_state.h" | 24 #include "ios/web/public/browser_state.h" |
24 #include "ios/web/public/web_client.h" | 25 #include "ios/web/public/web_client.h" |
25 #include "ios/web/public/web_thread.h" | 26 #include "ios/web/public/web_thread.h" |
26 #include "ios/web/webui/shared_resources_data_source_ios.h" | 27 #include "ios/web/webui/shared_resources_data_source_ios.h" |
27 #include "ios/web/webui/url_data_source_ios_impl.h" | 28 #include "ios/web/webui/url_data_source_ios_impl.h" |
28 #include "net/base/io_buffer.h" | 29 #include "net/base/io_buffer.h" |
29 #include "net/base/net_errors.h" | 30 #include "net/base/net_errors.h" |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 job->set_deny_xframe_options(source->source()->ShouldDenyXFrameOptions()); | 455 job->set_deny_xframe_options(source->source()->ShouldDenyXFrameOptions()); |
455 job->set_send_content_type_header(false); | 456 job->set_send_content_type_header(false); |
456 | 457 |
457 // Forward along the request to the data source. | 458 // Forward along the request to the data source. |
458 // URLRequestChromeJob should receive mime type before data. This | 459 // URLRequestChromeJob should receive mime type before data. This |
459 // is guaranteed because request for mime type is placed in the | 460 // is guaranteed because request for mime type is placed in the |
460 // message loop before request for data. And correspondingly their | 461 // message loop before request for data. And correspondingly their |
461 // replies are put on the IO thread in the same order. | 462 // replies are put on the IO thread in the same order. |
462 base::MessageLoop* target_message_loop = | 463 base::MessageLoop* target_message_loop = |
463 web::WebThread::UnsafeGetMessageLoopForThread(web::WebThread::UI); | 464 web::WebThread::UnsafeGetMessageLoopForThread(web::WebThread::UI); |
464 target_message_loop->PostTask( | 465 target_message_loop->task_runner()->PostTask( |
465 FROM_HERE, base::Bind(&GetMimeTypeOnUI, base::RetainedRef(source), path, | 466 FROM_HERE, base::Bind(&GetMimeTypeOnUI, base::RetainedRef(source), path, |
466 job->weak_factory_.GetWeakPtr())); | 467 job->weak_factory_.GetWeakPtr())); |
467 | 468 |
468 target_message_loop->PostTask( | 469 target_message_loop->task_runner()->PostTask( |
469 FROM_HERE, base::Bind(&URLDataManagerIOSBackend::CallStartRequest, | 470 FROM_HERE, base::Bind(&URLDataManagerIOSBackend::CallStartRequest, |
470 make_scoped_refptr(source), path, request_id)); | 471 make_scoped_refptr(source), path, request_id)); |
471 return true; | 472 return true; |
472 } | 473 } |
473 | 474 |
474 URLDataSourceIOSImpl* URLDataManagerIOSBackend::GetDataSourceFromURL( | 475 URLDataSourceIOSImpl* URLDataManagerIOSBackend::GetDataSourceFromURL( |
475 const GURL& url) { | 476 const GURL& url) { |
476 // The input usually looks like: chrome://source_name/extra_bits?foo | 477 // The input usually looks like: chrome://source_name/extra_bits?foo |
477 // so do a lookup using the host of the URL. | 478 // so do a lookup using the host of the URL. |
478 DataSourceMap::iterator i = data_sources_.find(url.host()); | 479 DataSourceMap::iterator i = data_sources_.find(url.host()); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 // Forward this data on to the pending net::URLRequest, if it exists. | 517 // Forward this data on to the pending net::URLRequest, if it exists. |
517 PendingRequestMap::iterator i = pending_requests_.find(request_id); | 518 PendingRequestMap::iterator i = pending_requests_.find(request_id); |
518 if (i != pending_requests_.end()) { | 519 if (i != pending_requests_.end()) { |
519 URLRequestChromeJob* job(i->second); | 520 URLRequestChromeJob* job(i->second); |
520 pending_requests_.erase(i); | 521 pending_requests_.erase(i); |
521 job->DataAvailable(bytes); | 522 job->DataAvailable(bytes); |
522 } | 523 } |
523 } | 524 } |
524 | 525 |
525 } // namespace web | 526 } // namespace web |
OLD | NEW |