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

Unified Diff: content/browser/browser_message_filter_peer.cc

Issue 324143002: Decouple IPC::MessageFilter from IPC::Channel (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing compilation errors Created 6 years, 6 months 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698