Index: content/browser/browser_message_filter_peer.cc |
diff --git a/content/browser/browser_message_filter_peer.cc b/content/browser/browser_message_filter_peer.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5104c008988393ee40944ee0d333776ba3404fbd |
--- /dev/null |
+++ b/content/browser/browser_message_filter_peer.cc |
@@ -0,0 +1,53 @@ |
+// Copyright (c) 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "content/browser/browser_message_filter_peer.h" |
+ |
+#include "base/command_line.h" |
+#include "content/browser/browser_child_process_host_impl.h" |
+#include "content/public/common/content_switches.h" |
+#include "content/public/common/result_codes.h" |
+ |
+namespace content { |
+ |
+BrowserMessageFilterPeer::BrowserMessageFilterPeer() |
+ : pid_(base::kNullProcessId) { |
+#if defined(OS_WIN) |
+ handle_ = base::kNullProcessHandle; |
+#endif |
+} |
+ |
+BrowserMessageFilterPeer::BrowserMessageFilterPeer(base::ProcessId pid) |
+ : pid_(pid) { |
+#if defined(OS_WIN) |
+ handle_ = base::kNullProcessHandle; |
+#endif |
+} |
+ |
+void BrowserMessageFilterPeer::BadMessageReceived() { |
+ CommandLine* command_line = CommandLine::ForCurrentProcess(); |
+ if (command_line->HasSwitch(switches::kDisableKillAfterBadIPC)) |
+ return; |
+ |
+ BrowserChildProcessHostImpl::HistogramBadMessageTerminated( |
+ PROCESS_TYPE_RENDERER); |
+ base::KillProcess(GetHandle(), content::RESULT_CODE_KILLED_BAD_MESSAGE, |
+ false); |
+} |
+ |
+base::ProcessHandle BrowserMessageFilterPeer::GetHandle() { |
+#if defined(OS_WIN) |
+ base::AutoLock lock(handle_lock_); |
+ if (handle_ == base::kNullProcessHandle) |
+ base::OpenPrivilegedProcessHandle(pid_, &handle_); |
+ |
+ return handle_; |
+#else |
+ base::ProcessHandle result = base::kNullProcessHandle; |
+ base::OpenPrivilegedProcessHandle(pid_, &result); |
+ return result; |
+#endif |
+} |
+ |
+} // namespace content |