OLD | NEW |
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 // Implementation of the ExtensionPortsRemoteService. | 5 // Implementation of the ExtensionPortsRemoteService. |
6 | 6 |
7 // Inspired significantly from debugger_remote_service | 7 // Inspired significantly from debugger_remote_service |
8 // and ../automation/extension_port_container. | 8 // and ../automation/extension_port_container. |
9 | 9 |
10 #include "chrome/browser/debugger/extension_ports_remote_service.h" | 10 #include "chrome/browser/debugger/extension_ports_remote_service.h" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 if (!service_) { | 167 if (!service_) { |
168 // This happens if we failed to obtain an ExtensionMessageService | 168 // This happens if we failed to obtain an ExtensionMessageService |
169 // during initialization. | 169 // during initialization. |
170 NOTREACHED(); | 170 NOTREACHED(); |
171 response.SetInteger(kResultKey, RESULT_NO_SERVICE); | 171 response.SetInteger(kResultKey, RESULT_NO_SERVICE); |
172 SendResponse(response, message.tool(), message.destination()); | 172 SendResponse(response, message.tool(), message.destination()); |
173 return; | 173 return; |
174 } | 174 } |
175 | 175 |
176 int destination = -1; | 176 int destination = -1; |
177 if (destinationString.size() != 0) | 177 if (!destinationString.empty()) |
178 base::StringToInt(destinationString, &destination); | 178 base::StringToInt(destinationString, &destination); |
179 | 179 |
180 if (command == kConnect) { | 180 if (command == kConnect) { |
181 if (destination != -1) // destination should be empty for this command. | 181 if (destination != -1) // destination should be empty for this command. |
182 response.SetInteger(kResultKey, RESULT_UNKNOWN_COMMAND); | 182 response.SetInteger(kResultKey, RESULT_UNKNOWN_COMMAND); |
183 else | 183 else |
184 ConnectCommand(content, &response); | 184 ConnectCommand(content, &response); |
185 } else if (command == kDisconnect) { | 185 } else if (command == kDisconnect) { |
186 if (destination == -1) // Destination required for this command. | 186 if (destination == -1) // Destination required for this command. |
187 response.SetInteger(kResultKey, RESULT_UNKNOWN_COMMAND); | 187 response.SetInteger(kResultKey, RESULT_UNKNOWN_COMMAND); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 VLOG(1) << "unknown port: " << port_id; | 379 VLOG(1) << "unknown port: " << port_id; |
380 response->SetInteger(kResultKey, RESULT_UNKNOWN_PORT); | 380 response->SetInteger(kResultKey, RESULT_UNKNOWN_PORT); |
381 return; | 381 return; |
382 } | 382 } |
383 // Post the message through the ExtensionMessageService. | 383 // Post the message through the ExtensionMessageService. |
384 DCHECK(service_); | 384 DCHECK(service_); |
385 service_->PostMessageFromRenderer(port_id, message); | 385 service_->PostMessageFromRenderer(port_id, message); |
386 // Confirm to the external client that we sent its message. | 386 // Confirm to the external client that we sent its message. |
387 response->SetInteger(kResultKey, RESULT_OK); | 387 response->SetInteger(kResultKey, RESULT_OK); |
388 } | 388 } |
OLD | NEW |