Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: chrome/browser/renderer_host/browser_render_process_host.cc

Issue 5978003: Make IPC::Channel::Listener:OnMessageReceived have a return value indicating ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // 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 959 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 } 970 }
971 971
972 if (child_process_.get() && child_process_->IsStarting()) { 972 if (child_process_.get() && child_process_->IsStarting()) {
973 queued_messages_.push(msg); 973 queued_messages_.push(msg);
974 return true; 974 return true;
975 } 975 }
976 976
977 return channel_->Send(msg); 977 return channel_->Send(msg);
978 } 978 }
979 979
980 void BrowserRenderProcessHost::OnMessageReceived(const IPC::Message& msg) { 980 bool BrowserRenderProcessHost::OnMessageReceived(const IPC::Message& msg) {
981 // If we're about to be deleted, we can no longer trust that our profile is 981 // If we're about to be deleted, we can no longer trust that our profile is
982 // valid, so we ignore incoming messages. 982 // valid, so we ignore incoming messages.
983 if (deleting_soon_) 983 if (deleting_soon_)
984 return; 984 return false;
985 985
986 #if defined(OS_CHROMEOS) 986 #if defined(OS_CHROMEOS)
987 // To troubleshoot crosbug.com/7327. 987 // To troubleshoot crosbug.com/7327.
988 CHECK(this); 988 CHECK(this);
989 CHECK(&msg); 989 CHECK(&msg);
990 #endif 990 #endif
991 991
992 mark_child_process_activity_time(); 992 mark_child_process_activity_time();
993 if (msg.routing_id() == MSG_ROUTING_CONTROL) { 993 if (msg.routing_id() == MSG_ROUTING_CONTROL) {
994 // Dispatch control messages. 994 // Dispatch control messages.
(...skipping 16 matching lines...) Expand all
1011 IPC_MESSAGE_UNHANDLED_ERROR() 1011 IPC_MESSAGE_UNHANDLED_ERROR()
1012 IPC_END_MESSAGE_MAP_EX() 1012 IPC_END_MESSAGE_MAP_EX()
1013 1013
1014 if (!msg_is_ok) { 1014 if (!msg_is_ok) {
1015 // The message had a handler, but its de-serialization failed. 1015 // The message had a handler, but its de-serialization failed.
1016 // We consider this a capital crime. Kill the renderer if we have one. 1016 // We consider this a capital crime. Kill the renderer if we have one.
1017 LOG(ERROR) << "bad message " << msg.type() << " terminating renderer."; 1017 LOG(ERROR) << "bad message " << msg.type() << " terminating renderer.";
1018 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_BRPH")); 1018 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_BRPH"));
1019 ReceivedBadMessage(); 1019 ReceivedBadMessage();
1020 } 1020 }
1021 return; 1021 return true;
1022 } 1022 }
1023 1023
1024 // Dispatch incoming messages to the appropriate RenderView/WidgetHost. 1024 // Dispatch incoming messages to the appropriate RenderView/WidgetHost.
1025 IPC::Channel::Listener* listener = GetListenerByID(msg.routing_id()); 1025 IPC::Channel::Listener* listener = GetListenerByID(msg.routing_id());
1026 if (!listener) { 1026 if (!listener) {
1027 if (msg.is_sync()) { 1027 if (msg.is_sync()) {
1028 // The listener has gone away, so we must respond or else the caller will 1028 // The listener has gone away, so we must respond or else the caller will
1029 // hang waiting for a reply. 1029 // hang waiting for a reply.
1030 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg); 1030 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg);
1031 reply->set_reply_error(); 1031 reply->set_reply_error();
1032 Send(reply); 1032 Send(reply);
1033 } 1033 }
1034 return; 1034 return true;
1035 } 1035 }
1036 listener->OnMessageReceived(msg); 1036 return listener->OnMessageReceived(msg);
1037 } 1037 }
1038 1038
1039 void BrowserRenderProcessHost::OnChannelConnected(int32 peer_pid) { 1039 void BrowserRenderProcessHost::OnChannelConnected(int32 peer_pid) {
1040 #if defined(IPC_MESSAGE_LOG_ENABLED) 1040 #if defined(IPC_MESSAGE_LOG_ENABLED)
1041 Send(new ViewMsg_SetIPCLoggingEnabled( 1041 Send(new ViewMsg_SetIPCLoggingEnabled(
1042 IPC::Logging::GetInstance()->Enabled())); 1042 IPC::Logging::GetInstance()->Enabled()));
1043 #endif 1043 #endif
1044 } 1044 }
1045 1045
1046 void BrowserRenderProcessHost::OnChannelError() { 1046 void BrowserRenderProcessHost::OnChannelError() {
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 IPC::PlatformFileForTransit file; 1305 IPC::PlatformFileForTransit file;
1306 #if defined(OS_POSIX) 1306 #if defined(OS_POSIX)
1307 file = base::FileDescriptor(model_file, false); 1307 file = base::FileDescriptor(model_file, false);
1308 #elif defined(OS_WIN) 1308 #elif defined(OS_WIN)
1309 ::DuplicateHandle(::GetCurrentProcess(), model_file, GetHandle(), &file, 0, 1309 ::DuplicateHandle(::GetCurrentProcess(), model_file, GetHandle(), &file, 0,
1310 false, DUPLICATE_SAME_ACCESS); 1310 false, DUPLICATE_SAME_ACCESS);
1311 #endif 1311 #endif
1312 Send(new ViewMsg_SetPhishingModel(file)); 1312 Send(new ViewMsg_SetPhishingModel(file));
1313 } 1313 }
1314 } 1314 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/browser_render_process_host.h ('k') | chrome/browser/renderer_host/mock_render_process_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698