OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "components/nacl/browser/nacl_broker_service_win.h" | 5 #include "components/nacl/browser/nacl_broker_service_win.h" |
6 | 6 |
7 #include "components/nacl/browser/nacl_process_host.h" | 7 #include "components/nacl/browser/nacl_process_host.h" |
8 #include "components/nacl/common/nacl_process_type.h" | 8 #include "components/nacl/common/nacl_process_type.h" |
9 #include "content/public/browser/browser_child_process_host_iterator.h" | 9 #include "content/public/browser/browser_child_process_host_iterator.h" |
10 | 10 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 DCHECK(loaders_running_ > 0); | 66 DCHECK(loaders_running_ > 0); |
67 --loaders_running_; | 67 --loaders_running_; |
68 // Stop the broker only if there are no loaders running or being launched. | 68 // Stop the broker only if there are no loaders running or being launched. |
69 NaClBrokerHost* broker_host = GetBrokerHost(); | 69 NaClBrokerHost* broker_host = GetBrokerHost(); |
70 if (loaders_running_ + pending_launches_.size() == 0 && broker_host != NULL) { | 70 if (loaders_running_ + pending_launches_.size() == 0 && broker_host != NULL) { |
71 broker_host->StopBroker(); | 71 broker_host->StopBroker(); |
72 } | 72 } |
73 } | 73 } |
74 | 74 |
75 bool NaClBrokerService::LaunchDebugExceptionHandler( | 75 bool NaClBrokerService::LaunchDebugExceptionHandler( |
76 base::WeakPtr<NaClProcessHost> nacl_process_host, int32 pid, | 76 base::WeakPtr<NaClProcessHost> nacl_process_host, |
77 base::ProcessHandle process_handle, const std::string& startup_info) { | 77 int32_t pid, |
| 78 base::ProcessHandle process_handle, |
| 79 const std::string& startup_info) { |
78 pending_debuggers_[pid] = nacl_process_host; | 80 pending_debuggers_[pid] = nacl_process_host; |
79 NaClBrokerHost* broker_host = GetBrokerHost(); | 81 NaClBrokerHost* broker_host = GetBrokerHost(); |
80 if (!broker_host) | 82 if (!broker_host) |
81 return false; | 83 return false; |
82 return broker_host->LaunchDebugExceptionHandler(pid, process_handle, | 84 return broker_host->LaunchDebugExceptionHandler(pid, process_handle, |
83 startup_info); | 85 startup_info); |
84 } | 86 } |
85 | 87 |
86 void NaClBrokerService::OnDebugExceptionHandlerLaunched(int32 pid, | 88 void NaClBrokerService::OnDebugExceptionHandlerLaunched(int32_t pid, |
87 bool success) { | 89 bool success) { |
88 PendingDebugExceptionHandlersMap::iterator it = pending_debuggers_.find(pid); | 90 PendingDebugExceptionHandlersMap::iterator it = pending_debuggers_.find(pid); |
89 if (pending_debuggers_.end() == it) | 91 if (pending_debuggers_.end() == it) |
90 NOTREACHED(); | 92 NOTREACHED(); |
91 | 93 |
92 NaClProcessHost* client = it->second.get(); | 94 NaClProcessHost* client = it->second.get(); |
93 if (client) | 95 if (client) |
94 client->OnDebugExceptionHandlerLaunchedByBroker(success); | 96 client->OnDebugExceptionHandlerLaunchedByBroker(success); |
95 pending_debuggers_.erase(it); | 97 pending_debuggers_.erase(it); |
96 } | 98 } |
97 | 99 |
98 NaClBrokerHost* NaClBrokerService::GetBrokerHost() { | 100 NaClBrokerHost* NaClBrokerService::GetBrokerHost() { |
99 BrowserChildProcessHostIterator iter(PROCESS_TYPE_NACL_BROKER); | 101 BrowserChildProcessHostIterator iter(PROCESS_TYPE_NACL_BROKER); |
100 while (!iter.Done()) { | 102 while (!iter.Done()) { |
101 NaClBrokerHost* host = static_cast<NaClBrokerHost*>(iter.GetDelegate()); | 103 NaClBrokerHost* host = static_cast<NaClBrokerHost*>(iter.GetDelegate()); |
102 if (!host->IsTerminating()) | 104 if (!host->IsTerminating()) |
103 return host; | 105 return host; |
104 ++iter; | 106 ++iter; |
105 } | 107 } |
106 return NULL; | 108 return NULL; |
107 } | 109 } |
108 | 110 |
109 } // namespace nacl | 111 } // namespace nacl |
OLD | NEW |