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/renderer/render_thread_impl.h" | 5 #include "content/renderer/render_thread_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <map> | 9 #include <map> |
10 #include <vector> | 10 #include <vector> |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 } | 259 } |
260 | 260 |
261 private: | 261 private: |
262 const std::string scheme_; | 262 const std::string scheme_; |
263 const std::string host_; | 263 const std::string host_; |
264 const double zoom_level_; | 264 const double zoom_level_; |
265 | 265 |
266 DISALLOW_COPY_AND_ASSIGN(RenderViewZoomer); | 266 DISALLOW_COPY_AND_ASSIGN(RenderViewZoomer); |
267 }; | 267 }; |
268 | 268 |
269 class CompositorRasterThread : public base::SimpleThread { | 269 class WorkerThread : public base::SimpleThread { |
270 public: | 270 public: |
271 CompositorRasterThread(cc::TaskGraphRunner* task_graph_runner, | 271 WorkerThread(cc::TaskGraphRunner* task_graph_runner, |
272 const std::string& name_prefix, | 272 const std::string& name_prefix, |
273 base::SimpleThread::Options options) | 273 base::SimpleThread::Options options) |
274 : base::SimpleThread(name_prefix, options), | 274 : base::SimpleThread(name_prefix, options), |
275 task_graph_runner_(task_graph_runner) {} | 275 task_graph_runner_(task_graph_runner) {} |
276 | 276 |
277 // Overridden from base::SimpleThread: | 277 // Overridden from base::SimpleThread: |
278 void Run() override { task_graph_runner_->Run(); } | 278 void Run() override { task_graph_runner_->Run(); } |
279 | 279 |
280 private: | 280 private: |
281 cc::TaskGraphRunner* task_graph_runner_; | 281 cc::TaskGraphRunner* task_graph_runner_; |
282 | 282 |
283 DISALLOW_COPY_AND_ASSIGN(CompositorRasterThread); | 283 DISALLOW_COPY_AND_ASSIGN(WorkerThread); |
284 }; | 284 }; |
285 | 285 |
286 std::string HostToCustomHistogramSuffix(const std::string& host) { | 286 std::string HostToCustomHistogramSuffix(const std::string& host) { |
287 if (host == "mail.google.com") | 287 if (host == "mail.google.com") |
288 return ".gmail"; | 288 return ".gmail"; |
289 if (host == "docs.google.com" || host == "drive.google.com") | 289 if (host == "docs.google.com" || host == "drive.google.com") |
290 return ".docs"; | 290 return ".docs"; |
291 if (host == "plus.google.com") | 291 if (host == "plus.google.com") |
292 return ".plus"; | 292 return ".plus"; |
293 if (host == "inbox.google.com") | 293 if (host == "inbox.google.com") |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 is_distance_field_text_enabled_ = false; | 640 is_distance_field_text_enabled_ = false; |
641 } | 641 } |
642 | 642 |
643 // Note that under Linux, the media library will normally already have | 643 // Note that under Linux, the media library will normally already have |
644 // been initialized by the Zygote before this instance became a Renderer. | 644 // been initialized by the Zygote before this instance became a Renderer. |
645 media::InitializeMediaLibrary(); | 645 media::InitializeMediaLibrary(); |
646 | 646 |
647 memory_pressure_listener_.reset(new base::MemoryPressureListener( | 647 memory_pressure_listener_.reset(new base::MemoryPressureListener( |
648 base::Bind(&RenderThreadImpl::OnMemoryPressure, base::Unretained(this)))); | 648 base::Bind(&RenderThreadImpl::OnMemoryPressure, base::Unretained(this)))); |
649 | 649 |
650 compositor_task_graph_runner_.reset(new cc::TaskGraphRunner); | 650 task_graph_runner_.reset(new cc::TaskGraphRunner); |
651 | 651 |
652 is_gather_pixel_refs_enabled_ = false; | 652 is_gather_pixel_refs_enabled_ = false; |
653 | 653 |
654 int num_raster_threads = 0; | 654 int num_worker_threads = 0; |
655 std::string string_value = | 655 std::string string_value = |
656 command_line.GetSwitchValueASCII(switches::kNumRasterThreads); | 656 command_line.GetSwitchValueASCII(switches::kNumWorkerThreads); |
657 bool parsed_num_raster_threads = | 657 bool parsed_num_worker_threads = |
658 base::StringToInt(string_value, &num_raster_threads); | 658 base::StringToInt(string_value, &num_worker_threads); |
659 DCHECK(parsed_num_raster_threads) << string_value; | 659 DCHECK(parsed_num_worker_threads) << string_value; |
660 DCHECK_GT(num_raster_threads, 0); | 660 DCHECK_GT(num_worker_threads, 0); |
661 | 661 |
662 // Note: Currently, gathering of pixel refs when using a single | 662 // Note: Currently, gathering of pixel refs when using a single |
663 // raster thread doesn't provide any benefit. This might change | 663 // worker thread doesn't provide any benefit. This might change |
664 // in the future but we avoid it for now to reduce the cost of | 664 // in the future but we avoid it for now to reduce the cost of |
665 // Picture::Create. | 665 // Picture::Create. |
666 is_gather_pixel_refs_enabled_ = num_raster_threads > 1; | 666 is_gather_pixel_refs_enabled_ = num_worker_threads > 1; |
667 | 667 |
668 base::SimpleThread::Options thread_options; | 668 base::SimpleThread::Options thread_options; |
669 #if defined(OS_ANDROID) || defined(OS_LINUX) | 669 #if defined(OS_ANDROID) || defined(OS_LINUX) |
670 if (!command_line.HasSwitch( | 670 if (!command_line.HasSwitch( |
671 switches::kUseNormalPriorityForTileTaskWorkerThreads)) { | 671 switches::kUseNormalPriorityForTileTaskWorkerThreads)) { |
672 thread_options.set_priority(base::ThreadPriority::BACKGROUND); | 672 thread_options.set_priority(base::ThreadPriority::BACKGROUND); |
673 } | 673 } |
674 #endif | 674 #endif |
675 while (compositor_raster_threads_.size() < | 675 while (worker_threads_.size() < static_cast<size_t>(num_worker_threads)) { |
676 static_cast<size_t>(num_raster_threads)) { | 676 scoped_ptr<WorkerThread> worker_thread(new WorkerThread( |
677 scoped_ptr<CompositorRasterThread> raster_thread(new CompositorRasterThread( | 677 task_graph_runner_.get(), |
678 compositor_task_graph_runner_.get(), | 678 base::StringPrintf("Worker%u", static_cast<unsigned>( |
679 base::StringPrintf("CompositorTileWorker%u", | 679 worker_threads_.size() + 1)).c_str(), |
680 static_cast<unsigned>( | |
681 compositor_raster_threads_.size() + 1)).c_str(), | |
682 thread_options)); | 680 thread_options)); |
683 raster_thread->Start(); | 681 worker_thread->Start(); |
684 compositor_raster_threads_.push_back(raster_thread.Pass()); | 682 worker_threads_.push_back(worker_thread.Pass()); |
685 } | 683 } |
686 | 684 |
687 // In single process, browser main loop set up the discardable memory | 685 // In single process, browser main loop set up the discardable memory |
688 // allocator. | 686 // allocator. |
689 if (!command_line.HasSwitch(switches::kSingleProcess)) { | 687 if (!command_line.HasSwitch(switches::kSingleProcess)) { |
690 base::DiscardableMemoryAllocator::SetInstance( | 688 base::DiscardableMemoryAllocator::SetInstance( |
691 ChildThreadImpl::discardable_shared_memory_manager()); | 689 ChildThreadImpl::discardable_shared_memory_manager()); |
692 } | 690 } |
693 | 691 |
694 service_registry()->AddService<RenderFrameSetup>( | 692 service_registry()->AddService<RenderFrameSetup>( |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 } | 753 } |
756 | 754 |
757 media_thread_.reset(); | 755 media_thread_.reset(); |
758 | 756 |
759 // AudioMessageFilter may be accessed on |media_thread_|, so shutdown after. | 757 // AudioMessageFilter may be accessed on |media_thread_|, so shutdown after. |
760 RemoveFilter(audio_message_filter_.get()); | 758 RemoveFilter(audio_message_filter_.get()); |
761 audio_message_filter_ = NULL; | 759 audio_message_filter_ = NULL; |
762 | 760 |
763 compositor_thread_.reset(); | 761 compositor_thread_.reset(); |
764 | 762 |
765 // Shutdown raster threads. | 763 // Shutdown worker threads. |
766 compositor_task_graph_runner_->Shutdown(); | 764 task_graph_runner_->Shutdown(); |
767 while (!compositor_raster_threads_.empty()) { | 765 while (!worker_threads_.empty()) { |
768 compositor_raster_threads_.back()->Join(); | 766 worker_threads_.back()->Join(); |
769 compositor_raster_threads_.pop_back(); | 767 worker_threads_.pop_back(); |
770 } | 768 } |
771 compositor_task_graph_runner_.reset(); | 769 task_graph_runner_.reset(); |
772 | 770 |
773 main_input_callback_.Cancel(); | 771 main_input_callback_.Cancel(); |
774 input_handler_manager_.reset(); | 772 input_handler_manager_.reset(); |
775 if (input_event_filter_.get()) { | 773 if (input_event_filter_.get()) { |
776 RemoveFilter(input_event_filter_.get()); | 774 RemoveFilter(input_event_filter_.get()); |
777 input_event_filter_ = NULL; | 775 input_event_filter_ = NULL; |
778 } | 776 } |
779 | 777 |
780 // RemoveEmbeddedWorkerRoute may be called while deleting | 778 // RemoveEmbeddedWorkerRoute may be called while deleting |
781 // EmbeddedWorkerDispatcher. So it must be deleted before deleting | 779 // EmbeddedWorkerDispatcher. So it must be deleted before deleting |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1447 if (SynchronousCompositorFactory* factory = | 1445 if (SynchronousCompositorFactory* factory = |
1448 SynchronousCompositorFactory::GetInstance()) { | 1446 SynchronousCompositorFactory::GetInstance()) { |
1449 return factory->CreateExternalBeginFrameSource(routing_id); | 1447 return factory->CreateExternalBeginFrameSource(routing_id); |
1450 } | 1448 } |
1451 #endif | 1449 #endif |
1452 return make_scoped_ptr(new CompositorExternalBeginFrameSource( | 1450 return make_scoped_ptr(new CompositorExternalBeginFrameSource( |
1453 compositor_message_filter_.get(), sync_message_filter(), routing_id)); | 1451 compositor_message_filter_.get(), sync_message_filter(), routing_id)); |
1454 } | 1452 } |
1455 | 1453 |
1456 cc::TaskGraphRunner* RenderThreadImpl::GetTaskGraphRunner() { | 1454 cc::TaskGraphRunner* RenderThreadImpl::GetTaskGraphRunner() { |
1457 return compositor_task_graph_runner_.get(); | 1455 return task_graph_runner_.get(); |
1458 } | 1456 } |
1459 | 1457 |
1460 bool RenderThreadImpl::IsGatherPixelRefsEnabled() { | 1458 bool RenderThreadImpl::IsGatherPixelRefsEnabled() { |
1461 return is_gather_pixel_refs_enabled_; | 1459 return is_gather_pixel_refs_enabled_; |
1462 } | 1460 } |
1463 | 1461 |
1464 bool RenderThreadImpl::IsMainThread() { | 1462 bool RenderThreadImpl::IsMainThread() { |
1465 return !!current(); | 1463 return !!current(); |
1466 } | 1464 } |
1467 | 1465 |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1888 } | 1886 } |
1889 | 1887 |
1890 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { | 1888 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { |
1891 size_t erased = | 1889 size_t erased = |
1892 RenderThreadImpl::current()->pending_render_frame_connects_.erase( | 1890 RenderThreadImpl::current()->pending_render_frame_connects_.erase( |
1893 routing_id_); | 1891 routing_id_); |
1894 DCHECK_EQ(1u, erased); | 1892 DCHECK_EQ(1u, erased); |
1895 } | 1893 } |
1896 | 1894 |
1897 } // namespace content | 1895 } // namespace content |
OLD | NEW |