| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 // Represents the browser side of the browser <--> renderer communication | 5 // Represents the browser side of the browser <--> renderer communication |
| 6 // channel. There will be one RenderProcessHost per renderer process. | 6 // channel. There will be one RenderProcessHost per renderer process. |
| 7 | 7 |
| 8 #include "chrome/browser/renderer_host/browser_render_process_host.h" | 8 #include "chrome/browser/renderer_host/browser_render_process_host.h" |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 queued_messages_.push(msg); | 728 queued_messages_.push(msg); |
| 729 return true; | 729 return true; |
| 730 } | 730 } |
| 731 | 731 |
| 732 return channel_->Send(msg); | 732 return channel_->Send(msg); |
| 733 } | 733 } |
| 734 | 734 |
| 735 void BrowserRenderProcessHost::OnMessageReceived(const IPC::Message& msg) { | 735 void BrowserRenderProcessHost::OnMessageReceived(const IPC::Message& msg) { |
| 736 mark_child_process_activity_time(); | 736 mark_child_process_activity_time(); |
| 737 if (msg.routing_id() == MSG_ROUTING_CONTROL) { | 737 if (msg.routing_id() == MSG_ROUTING_CONTROL) { |
| 738 // dispatch control messages | 738 // Dispatch control messages. |
| 739 bool msg_is_ok = true; | 739 bool msg_is_ok = true; |
| 740 IPC_BEGIN_MESSAGE_MAP_EX(BrowserRenderProcessHost, msg, msg_is_ok) | 740 IPC_BEGIN_MESSAGE_MAP_EX(BrowserRenderProcessHost, msg, msg_is_ok) |
| 741 IPC_MESSAGE_HANDLER(ViewHostMsg_PageContents, OnPageContents) | |
| 742 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdatedCacheStats, | 741 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdatedCacheStats, |
| 743 OnUpdatedCacheStats) | 742 OnUpdatedCacheStats) |
| 744 IPC_MESSAGE_HANDLER(ViewHostMsg_SuddenTerminationChanged, | 743 IPC_MESSAGE_HANDLER(ViewHostMsg_SuddenTerminationChanged, |
| 745 SuddenTerminationChanged); | 744 SuddenTerminationChanged); |
| 746 IPC_MESSAGE_HANDLER(ViewHostMsg_ExtensionAddListener, | 745 IPC_MESSAGE_HANDLER(ViewHostMsg_ExtensionAddListener, |
| 747 OnExtensionAddListener) | 746 OnExtensionAddListener) |
| 748 IPC_MESSAGE_HANDLER(ViewHostMsg_ExtensionRemoveListener, | 747 IPC_MESSAGE_HANDLER(ViewHostMsg_ExtensionRemoveListener, |
| 749 OnExtensionRemoveListener) | 748 OnExtensionRemoveListener) |
| 750 IPC_MESSAGE_HANDLER(ViewHostMsg_ExtensionCloseChannel, | 749 IPC_MESSAGE_HANDLER(ViewHostMsg_ExtensionCloseChannel, |
| 751 OnExtensionCloseChannel) | 750 OnExtensionCloseChannel) |
| 752 IPC_MESSAGE_HANDLER(ViewHostMsg_SpellChecker_RequestDictionary, | 751 IPC_MESSAGE_HANDLER(ViewHostMsg_SpellChecker_RequestDictionary, |
| 753 OnSpellCheckerRequestDictionary) | 752 OnSpellCheckerRequestDictionary) |
| 754 IPC_MESSAGE_UNHANDLED_ERROR() | 753 IPC_MESSAGE_UNHANDLED_ERROR() |
| 755 IPC_END_MESSAGE_MAP_EX() | 754 IPC_END_MESSAGE_MAP_EX() |
| 756 | 755 |
| 757 if (!msg_is_ok) { | 756 if (!msg_is_ok) { |
| 758 // The message had a handler, but its de-serialization failed. | 757 // The message had a handler, but its de-serialization failed. |
| 759 // We consider this a capital crime. Kill the renderer if we have one. | 758 // We consider this a capital crime. Kill the renderer if we have one. |
| 760 ReceivedBadMessage(msg.type()); | 759 ReceivedBadMessage(msg.type()); |
| 761 } | 760 } |
| 762 return; | 761 return; |
| 763 } | 762 } |
| 764 | 763 |
| 765 // dispatch incoming messages to the appropriate TabContents | 764 // Dispatch incoming messages to the appropriate TabContents. |
| 766 IPC::Channel::Listener* listener = GetListenerByID(msg.routing_id()); | 765 IPC::Channel::Listener* listener = GetListenerByID(msg.routing_id()); |
| 767 if (!listener) { | 766 if (!listener) { |
| 768 if (msg.is_sync()) { | 767 if (msg.is_sync()) { |
| 769 // The listener has gone away, so we must respond or else the caller will | 768 // The listener has gone away, so we must respond or else the caller will |
| 770 // hang waiting for a reply. | 769 // hang waiting for a reply. |
| 771 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg); | 770 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg); |
| 772 reply->set_reply_error(); | 771 reply->set_reply_error(); |
| 773 Send(reply); | 772 Send(reply); |
| 774 } | 773 } |
| 775 return; | 774 return; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 ViewHostMsg_RenderViewGone(iter.GetCurrentKey())); | 828 ViewHostMsg_RenderViewGone(iter.GetCurrentKey())); |
| 830 iter.Advance(); | 829 iter.Advance(); |
| 831 } | 830 } |
| 832 | 831 |
| 833 ClearTransportDIBCache(); | 832 ClearTransportDIBCache(); |
| 834 | 833 |
| 835 // this object is not deleted at this point and may be reused later. | 834 // this object is not deleted at this point and may be reused later. |
| 836 // TODO(darin): clean this up | 835 // TODO(darin): clean this up |
| 837 } | 836 } |
| 838 | 837 |
| 839 void BrowserRenderProcessHost::OnPageContents(const GURL& url, | |
| 840 int32 page_id, | |
| 841 const std::wstring& contents) { | |
| 842 Profile* p = profile(); | |
| 843 if (!p || p->IsOffTheRecord()) | |
| 844 return; | |
| 845 | |
| 846 HistoryService* hs = p->GetHistoryService(Profile::IMPLICIT_ACCESS); | |
| 847 if (hs) | |
| 848 hs->SetPageContents(url, contents); | |
| 849 } | |
| 850 | |
| 851 void BrowserRenderProcessHost::OnUpdatedCacheStats( | 838 void BrowserRenderProcessHost::OnUpdatedCacheStats( |
| 852 const WebCache::UsageStats& stats) { | 839 const WebCache::UsageStats& stats) { |
| 853 WebCacheManager::GetInstance()->ObserveStats(id(), stats); | 840 WebCacheManager::GetInstance()->ObserveStats(id(), stats); |
| 854 } | 841 } |
| 855 | 842 |
| 856 void BrowserRenderProcessHost::SuddenTerminationChanged(bool enabled) { | 843 void BrowserRenderProcessHost::SuddenTerminationChanged(bool enabled) { |
| 857 set_sudden_termination_allowed(enabled); | 844 set_sudden_termination_allowed(enabled); |
| 858 } | 845 } |
| 859 | 846 |
| 860 void BrowserRenderProcessHost::SetBackgrounded(bool backgrounded) { | 847 void BrowserRenderProcessHost::SetBackgrounded(bool backgrounded) { |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 998 IPC::InvalidPlatformFileForTransit(), | 985 IPC::InvalidPlatformFileForTransit(), |
| 999 std::vector<std::string>(), | 986 std::vector<std::string>(), |
| 1000 std::string(), | 987 std::string(), |
| 1001 false)); | 988 false)); |
| 1002 } | 989 } |
| 1003 } | 990 } |
| 1004 | 991 |
| 1005 void BrowserRenderProcessHost::EnableAutoSpellCorrect(bool enable) { | 992 void BrowserRenderProcessHost::EnableAutoSpellCorrect(bool enable) { |
| 1006 Send(new ViewMsg_SpellChecker_EnableAutoSpellCorrect(enable)); | 993 Send(new ViewMsg_SpellChecker_EnableAutoSpellCorrect(enable)); |
| 1007 } | 994 } |
| OLD | NEW |