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 // 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 const DevToolsRemoteMessage& message) { | 141 const DevToolsRemoteMessage& message) { |
142 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); | 142 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); |
143 const std::string destinationString = message.destination(); | 143 const std::string destinationString = message.destination(); |
144 scoped_ptr<Value> request(base::JSONReader::Read(message.content(), true)); | 144 scoped_ptr<Value> request(base::JSONReader::Read(message.content(), true)); |
145 if (request.get() == NULL) { | 145 if (request.get() == NULL) { |
146 // Bad JSON | 146 // Bad JSON |
147 NOTREACHED(); | 147 NOTREACHED(); |
148 return; | 148 return; |
149 } | 149 } |
150 DictionaryValue* content; | 150 DictionaryValue* content; |
151 if (!request->IsType(Value::TYPE_DICTIONARY)) { | 151 if (!request->IsDictionary()) { |
152 NOTREACHED(); // Broken protocol :( | 152 NOTREACHED(); // Broken protocol :( |
153 return; | 153 return; |
154 } | 154 } |
155 content = static_cast<DictionaryValue*>(request.get()); | 155 content = static_cast<DictionaryValue*>(request.get()); |
156 if (!content->HasKey(kCommandKey)) { | 156 if (!content->HasKey(kCommandKey)) { |
157 NOTREACHED(); // Broken protocol :( | 157 NOTREACHED(); // Broken protocol :( |
158 return; | 158 return; |
159 } | 159 } |
160 std::string command; | 160 std::string command; |
161 DictionaryValue response; | 161 DictionaryValue response; |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 VLOG(1) << "unknown port: " << port_id; | 376 VLOG(1) << "unknown port: " << port_id; |
377 response->SetInteger(kResultKey, RESULT_UNKNOWN_PORT); | 377 response->SetInteger(kResultKey, RESULT_UNKNOWN_PORT); |
378 return; | 378 return; |
379 } | 379 } |
380 // Post the message through the ExtensionMessageService. | 380 // Post the message through the ExtensionMessageService. |
381 DCHECK(service_); | 381 DCHECK(service_); |
382 service_->PostMessageFromRenderer(port_id, message); | 382 service_->PostMessageFromRenderer(port_id, message); |
383 // Confirm to the external client that we sent its message. | 383 // Confirm to the external client that we sent its message. |
384 response->SetInteger(kResultKey, RESULT_OK); | 384 response->SetInteger(kResultKey, RESULT_OK); |
385 } | 385 } |
OLD | NEW |