| 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 "chrome/browser/debugger/devtools_remote_service.h" | 5 #include "chrome/browser/debugger/devtools_remote_service.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 void DevToolsRemoteService::HandleMessage( | 40 void DevToolsRemoteService::HandleMessage( |
| 41 const DevToolsRemoteMessage& message) { | 41 const DevToolsRemoteMessage& message) { |
| 42 scoped_ptr<Value> request(base::JSONReader::Read(message.content(), false)); | 42 scoped_ptr<Value> request(base::JSONReader::Read(message.content(), false)); |
| 43 if (request.get() == NULL) { | 43 if (request.get() == NULL) { |
| 44 // Bad JSON | 44 // Bad JSON |
| 45 NOTREACHED(); | 45 NOTREACHED(); |
| 46 return; | 46 return; |
| 47 } | 47 } |
| 48 DictionaryValue* json; | 48 DictionaryValue* json; |
| 49 if (request->IsType(Value::TYPE_DICTIONARY)) { | 49 if (request->IsDictionary()) { |
| 50 json = static_cast<DictionaryValue*>(request.get()); | 50 json = static_cast<DictionaryValue*>(request.get()); |
| 51 if (!json->HasKey(kCommandKey)) { | 51 if (!json->HasKey(kCommandKey)) { |
| 52 NOTREACHED(); // Broken protocol - no "command" specified | 52 NOTREACHED(); // Broken protocol - no "command" specified |
| 53 return; | 53 return; |
| 54 } | 54 } |
| 55 } else { | 55 } else { |
| 56 NOTREACHED(); // Broken protocol - not a JS object | 56 NOTREACHED(); // Broken protocol - not a JS object |
| 57 return; | 57 return; |
| 58 } | 58 } |
| 59 ProcessJson(json, message); | 59 ProcessJson(json, message); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 response.SetInteger(kResultKey, Result::kUnknownCommand); | 101 response.SetInteger(kResultKey, Result::kUnknownCommand); |
| 102 } | 102 } |
| 103 std::string response_json; | 103 std::string response_json; |
| 104 base::JSONWriter::Write(&response, false, &response_json); | 104 base::JSONWriter::Write(&response, false, &response_json); |
| 105 scoped_ptr<DevToolsRemoteMessage> response_message( | 105 scoped_ptr<DevToolsRemoteMessage> response_message( |
| 106 DevToolsRemoteMessageBuilder::instance().Create(message.tool(), | 106 DevToolsRemoteMessageBuilder::instance().Create(message.tool(), |
| 107 message.destination(), | 107 message.destination(), |
| 108 response_json)); | 108 response_json)); |
| 109 delegate_->Send(*response_message.get()); | 109 delegate_->Send(*response_message.get()); |
| 110 } | 110 } |
| OLD | NEW |