OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/renderer/render_thread.h" | 5 #include "chrome/renderer/render_thread.h" |
6 | 6 |
7 #include <v8.h> | 7 #include <v8.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <limits> | 10 #include <limits> |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 83 |
84 #if defined(OS_WIN) | 84 #if defined(OS_WIN) |
85 #include <windows.h> | 85 #include <windows.h> |
86 #include <objbase.h> | 86 #include <objbase.h> |
87 #endif | 87 #endif |
88 | 88 |
89 #if defined(OS_MACOSX) | 89 #if defined(OS_MACOSX) |
90 #include "chrome/app/breakpad_mac.h" | 90 #include "chrome/app/breakpad_mac.h" |
91 #endif | 91 #endif |
92 | 92 |
| 93 #if defined(OS_POSIX) |
| 94 #include "ipc/ipc_channel_posix.h" |
| 95 #endif |
| 96 |
93 using WebKit::WebCache; | 97 using WebKit::WebCache; |
94 using WebKit::WebCrossOriginPreflightResultCache; | 98 using WebKit::WebCrossOriginPreflightResultCache; |
95 using WebKit::WebFontCache; | 99 using WebKit::WebFontCache; |
96 using WebKit::WebFrame; | 100 using WebKit::WebFrame; |
97 using WebKit::WebRuntimeFeatures; | 101 using WebKit::WebRuntimeFeatures; |
98 using WebKit::WebSecurityPolicy; | 102 using WebKit::WebSecurityPolicy; |
99 using WebKit::WebScriptController; | 103 using WebKit::WebScriptController; |
100 using WebKit::WebString; | 104 using WebKit::WebString; |
101 using WebKit::WebStorageEventDispatcher; | 105 using WebKit::WebStorageEventDispatcher; |
102 using WebKit::WebView; | 106 using WebKit::WebView; |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 #if defined(IPC_MESSAGE_LOG_ENABLED) | 562 #if defined(IPC_MESSAGE_LOG_ENABLED) |
559 IPC_MESSAGE_HANDLER(ViewMsg_SetIPCLoggingEnabled, | 563 IPC_MESSAGE_HANDLER(ViewMsg_SetIPCLoggingEnabled, |
560 OnSetIPCLoggingEnabled) | 564 OnSetIPCLoggingEnabled) |
561 #endif | 565 #endif |
562 IPC_MESSAGE_HANDLER(ViewMsg_SpellChecker_Init, | 566 IPC_MESSAGE_HANDLER(ViewMsg_SpellChecker_Init, |
563 OnInitSpellChecker) | 567 OnInitSpellChecker) |
564 IPC_MESSAGE_HANDLER(ViewMsg_SpellChecker_WordAdded, | 568 IPC_MESSAGE_HANDLER(ViewMsg_SpellChecker_WordAdded, |
565 OnSpellCheckWordAdded) | 569 OnSpellCheckWordAdded) |
566 IPC_MESSAGE_HANDLER(ViewMsg_SpellChecker_EnableAutoSpellCorrect, | 570 IPC_MESSAGE_HANDLER(ViewMsg_SpellChecker_EnableAutoSpellCorrect, |
567 OnSpellCheckEnableAutoSpellCorrect) | 571 OnSpellCheckEnableAutoSpellCorrect) |
| 572 IPC_MESSAGE_HANDLER(ViewMsg_GpuChannelEstablished, OnGpuChannelEstablished) |
568 IPC_END_MESSAGE_MAP() | 573 IPC_END_MESSAGE_MAP() |
569 } | 574 } |
570 | 575 |
571 void RenderThread::OnSetNextPageID(int32 next_page_id) { | 576 void RenderThread::OnSetNextPageID(int32 next_page_id) { |
572 // This should only be called at process initialization time, so we shouldn't | 577 // This should only be called at process initialization time, so we shouldn't |
573 // have to worry about thread-safety. | 578 // have to worry about thread-safety. |
574 RenderView::SetNextPageID(next_page_id); | 579 RenderView::SetNextPageID(next_page_id); |
575 } | 580 } |
576 | 581 |
577 // Called when to register CSS Color name->system color mappings. | 582 // Called when to register CSS Color name->system color mappings. |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 // In single-process mode, the browser process reports the active extensions. | 678 // In single-process mode, the browser process reports the active extensions. |
674 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) | 679 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) |
675 return; | 680 return; |
676 | 681 |
677 std::set<std::string> active_extensions; | 682 std::set<std::string> active_extensions; |
678 user_script_slave_->GetActiveExtensions(&active_extensions); | 683 user_script_slave_->GetActiveExtensions(&active_extensions); |
679 ExtensionProcessBindings::GetActiveExtensions(&active_extensions); | 684 ExtensionProcessBindings::GetActiveExtensions(&active_extensions); |
680 child_process_logging::SetActiveExtensions(active_extensions); | 685 child_process_logging::SetActiveExtensions(active_extensions); |
681 } | 686 } |
682 | 687 |
| 688 void RenderThread::EstablishGpuChannel() { |
| 689 if (gpu_channel_.get()) { |
| 690 // Do nothing if we are already establishing GPU channel. |
| 691 if (gpu_channel_->state() == GpuChannelHost::UNCONNECTED) |
| 692 return; |
| 693 |
| 694 // Recreate the channel if it has been lost. |
| 695 if (gpu_channel_->state() == GpuChannelHost::LOST) |
| 696 gpu_channel_ = NULL; |
| 697 } |
| 698 |
| 699 if (!gpu_channel_.get()) |
| 700 gpu_channel_ = new GpuChannelHost; |
| 701 |
| 702 // Ask the browser for the channel name. |
| 703 Send(new ViewHostMsg_EstablishGpuChannel()); |
| 704 } |
| 705 |
| 706 GpuChannelHost* RenderThread::GetGpuChannel() { |
| 707 if (!gpu_channel_.get()) |
| 708 return NULL; |
| 709 |
| 710 if (gpu_channel_->state() != GpuChannelHost::CONNECTED) |
| 711 return NULL; |
| 712 |
| 713 return gpu_channel_.get(); |
| 714 } |
| 715 |
683 static void* CreateHistogram( | 716 static void* CreateHistogram( |
684 const char *name, int min, int max, size_t buckets) { | 717 const char *name, int min, int max, size_t buckets) { |
685 if (min <= 0) | 718 if (min <= 0) |
686 min = 1; | 719 min = 1; |
687 scoped_refptr<Histogram> histogram = Histogram::FactoryGet( | 720 scoped_refptr<Histogram> histogram = Histogram::FactoryGet( |
688 name, min, max, buckets, Histogram::kUmaTargetedHistogramFlag); | 721 name, min, max, buckets, Histogram::kUmaTargetedHistogramFlag); |
689 // We'll end up leaking these histograms, unless there is some code hiding in | 722 // We'll end up leaking these histograms, unless there is some code hiding in |
690 // there to do the dec-ref. | 723 // there to do the dec-ref. |
691 // TODO(jar): Handle reference counting in webkit glue. | 724 // TODO(jar): Handle reference counting in webkit glue. |
692 histogram->AddRef(); | 725 histogram->AddRef(); |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 spellchecker_->WordAdded(word); | 966 spellchecker_->WordAdded(word); |
934 } | 967 } |
935 | 968 |
936 void RenderThread::OnSpellCheckEnableAutoSpellCorrect(bool enable) { | 969 void RenderThread::OnSpellCheckEnableAutoSpellCorrect(bool enable) { |
937 spellchecker_->EnableAutoSpellCorrect(enable); | 970 spellchecker_->EnableAutoSpellCorrect(enable); |
938 } | 971 } |
939 | 972 |
940 void RenderThread::OnSetIsIncognitoProcess(bool is_incognito_process) { | 973 void RenderThread::OnSetIsIncognitoProcess(bool is_incognito_process) { |
941 is_incognito_process_ = is_incognito_process; | 974 is_incognito_process_ = is_incognito_process; |
942 } | 975 } |
| 976 |
| 977 void RenderThread::OnGpuChannelEstablished( |
| 978 const IPC::ChannelHandle& channel_handle) { |
| 979 #if defined(OS_POSIX) |
| 980 // If we received a ChannelHandle, register it now. |
| 981 if (channel_handle.socket.fd >= 0) |
| 982 IPC::AddChannelSocket(channel_handle.name, channel_handle.socket.fd); |
| 983 #endif |
| 984 |
| 985 if (channel_handle.name.size() != 0) { |
| 986 // Connect to the GPU process if a channel name was received. |
| 987 gpu_channel_->Connect(channel_handle.name); |
| 988 } else { |
| 989 // Otherwise cancel the connection. |
| 990 gpu_channel_ = NULL; |
| 991 } |
| 992 } |
OLD | NEW |