OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/mach_broker_mac.h" | 5 #include "content/browser/mach_broker_mac.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 DCHECK(broker_); | 36 DCHECK(broker_); |
37 std::string port_name = MachBroker::GetMachPortName(); | 37 std::string port_name = MachBroker::GetMachPortName(); |
38 | 38 |
39 // Create the receive port in the constructor, not in ThreadMain(). It is | 39 // Create the receive port in the constructor, not in ThreadMain(). It is |
40 // important to create and register the receive port before starting the | 40 // important to create and register the receive port before starting the |
41 // thread so that child processes will always have someone who's listening. | 41 // thread so that child processes will always have someone who's listening. |
42 receive_port_.reset(new base::ReceivePort(port_name.c_str())); | 42 receive_port_.reset(new base::ReceivePort(port_name.c_str())); |
43 } | 43 } |
44 | 44 |
45 // Implement |PlatformThread::Delegate|. | 45 // Implement |PlatformThread::Delegate|. |
46 void ThreadMain() { | 46 virtual void ThreadMain() OVERRIDE { |
47 base::MachReceiveMessage message; | 47 base::MachReceiveMessage message; |
48 kern_return_t err; | 48 kern_return_t err; |
49 while ((err = receive_port_->WaitForMessage(&message, | 49 while ((err = receive_port_->WaitForMessage(&message, |
50 MACH_MSG_TIMEOUT_NONE)) == | 50 MACH_MSG_TIMEOUT_NONE)) == |
51 KERN_SUCCESS) { | 51 KERN_SUCCESS) { |
52 // 0 was the secret message id. Reject any messages that don't have it. | 52 // 0 was the secret message id. Reject any messages that don't have it. |
53 if (message.GetMessageID() != 0) { | 53 if (message.GetMessageID() != 0) { |
54 LOG(ERROR) << "Received message with incorrect id: " | 54 LOG(ERROR) << "Received message with incorrect id: " |
55 << message.GetMessageID(); | 55 << message.GetMessageID(); |
56 continue; | 56 continue; |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 NotificationService::AllBrowserContextsAndSources()); | 218 NotificationService::AllBrowserContextsAndSources()); |
219 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 219 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
220 NotificationService::AllBrowserContextsAndSources()); | 220 NotificationService::AllBrowserContextsAndSources()); |
221 registrar_.Add(this, NOTIFICATION_CHILD_PROCESS_CRASHED, | 221 registrar_.Add(this, NOTIFICATION_CHILD_PROCESS_CRASHED, |
222 NotificationService::AllBrowserContextsAndSources()); | 222 NotificationService::AllBrowserContextsAndSources()); |
223 registrar_.Add(this, NOTIFICATION_CHILD_PROCESS_HOST_DISCONNECTED, | 223 registrar_.Add(this, NOTIFICATION_CHILD_PROCESS_HOST_DISCONNECTED, |
224 NotificationService::AllBrowserContextsAndSources()); | 224 NotificationService::AllBrowserContextsAndSources()); |
225 } | 225 } |
226 | 226 |
227 } // namespace content | 227 } // namespace content |
OLD | NEW |