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/run_loop.h" | |
sdefresne
2016/09/07 11:06:37
Why the include for base/run_loop.h? Seems unused.
fdoray
2016/09/07 13:16:03
Done.
| |
21 #include "base/single_thread_task_runner.h" | |
20 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
21 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
22 #include "base/trace_event/trace_event.h" | 24 #include "base/trace_event/trace_event.h" |
23 #include "ios/web/public/browser_state.h" | 25 #include "ios/web/public/browser_state.h" |
24 #include "ios/web/public/web_client.h" | 26 #include "ios/web/public/web_client.h" |
25 #include "ios/web/public/web_thread.h" | 27 #include "ios/web/public/web_thread.h" |
26 #include "ios/web/webui/shared_resources_data_source_ios.h" | 28 #include "ios/web/webui/shared_resources_data_source_ios.h" |
27 #include "ios/web/webui/url_data_source_ios_impl.h" | 29 #include "ios/web/webui/url_data_source_ios_impl.h" |
28 #include "net/base/io_buffer.h" | 30 #include "net/base/io_buffer.h" |
29 #include "net/base/net_errors.h" | 31 #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()); | 456 job->set_deny_xframe_options(source->source()->ShouldDenyXFrameOptions()); |
455 job->set_send_content_type_header(false); | 457 job->set_send_content_type_header(false); |
456 | 458 |
457 // Forward along the request to the data source. | 459 // Forward along the request to the data source. |
458 // URLRequestChromeJob should receive mime type before data. This | 460 // URLRequestChromeJob should receive mime type before data. This |
459 // is guaranteed because request for mime type is placed in the | 461 // is guaranteed because request for mime type is placed in the |
460 // message loop before request for data. And correspondingly their | 462 // message loop before request for data. And correspondingly their |
461 // replies are put on the IO thread in the same order. | 463 // replies are put on the IO thread in the same order. |
462 base::MessageLoop* target_message_loop = | 464 base::MessageLoop* target_message_loop = |
463 web::WebThread::UnsafeGetMessageLoopForThread(web::WebThread::UI); | 465 web::WebThread::UnsafeGetMessageLoopForThread(web::WebThread::UI); |
464 target_message_loop->PostTask( | 466 target_message_loop->task_runner()->PostTask( |
465 FROM_HERE, base::Bind(&GetMimeTypeOnUI, base::RetainedRef(source), path, | 467 FROM_HERE, base::Bind(&GetMimeTypeOnUI, base::RetainedRef(source), path, |
466 job->weak_factory_.GetWeakPtr())); | 468 job->weak_factory_.GetWeakPtr())); |
467 | 469 |
468 target_message_loop->PostTask( | 470 target_message_loop->task_runner()->PostTask( |
469 FROM_HERE, base::Bind(&URLDataManagerIOSBackend::CallStartRequest, | 471 FROM_HERE, base::Bind(&URLDataManagerIOSBackend::CallStartRequest, |
470 make_scoped_refptr(source), path, request_id)); | 472 make_scoped_refptr(source), path, request_id)); |
471 return true; | 473 return true; |
472 } | 474 } |
473 | 475 |
474 URLDataSourceIOSImpl* URLDataManagerIOSBackend::GetDataSourceFromURL( | 476 URLDataSourceIOSImpl* URLDataManagerIOSBackend::GetDataSourceFromURL( |
475 const GURL& url) { | 477 const GURL& url) { |
476 // The input usually looks like: chrome://source_name/extra_bits?foo | 478 // The input usually looks like: chrome://source_name/extra_bits?foo |
477 // so do a lookup using the host of the URL. | 479 // so do a lookup using the host of the URL. |
478 DataSourceMap::iterator i = data_sources_.find(url.host()); | 480 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. | 518 // Forward this data on to the pending net::URLRequest, if it exists. |
517 PendingRequestMap::iterator i = pending_requests_.find(request_id); | 519 PendingRequestMap::iterator i = pending_requests_.find(request_id); |
518 if (i != pending_requests_.end()) { | 520 if (i != pending_requests_.end()) { |
519 URLRequestChromeJob* job(i->second); | 521 URLRequestChromeJob* job(i->second); |
520 pending_requests_.erase(i); | 522 pending_requests_.erase(i); |
521 job->DataAvailable(bytes); | 523 job->DataAvailable(bytes); |
522 } | 524 } |
523 } | 525 } |
524 | 526 |
525 } // namespace web | 527 } // namespace web |
OLD | NEW |