Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(464)

Side by Side Diff: chrome/browser/debugger/debugger_remote_service.cc

Issue 316016: Move the json-related files into a separate json directory. This hopefully al... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 // This file contains implementations of the DebuggerRemoteService methods, 5 // This file contains implementations of the DebuggerRemoteService methods,
6 // defines DebuggerRemoteService and DebuggerRemoteServiceCommand constants. 6 // defines DebuggerRemoteService and DebuggerRemoteServiceCommand constants.
7 7
8 #include "chrome/browser/debugger/debugger_remote_service.h" 8 #include "chrome/browser/debugger/debugger_remote_service.h"
9 9
10 #include "base/json_reader.h" 10 #include "base/json/json_reader.h"
11 #include "base/json_writer.h" 11 #include "base/json/json_writer.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/debugger/devtools_manager.h" 15 #include "chrome/browser/debugger/devtools_manager.h"
16 #include "chrome/browser/debugger/devtools_protocol_handler.h" 16 #include "chrome/browser/debugger/devtools_protocol_handler.h"
17 #include "chrome/browser/debugger/devtools_remote_message.h" 17 #include "chrome/browser/debugger/devtools_remote_message.h"
18 #include "chrome/browser/debugger/inspectable_tab_proxy.h" 18 #include "chrome/browser/debugger/inspectable_tab_proxy.h"
19 #include "chrome/browser/tab_contents/tab_contents.h" 19 #include "chrome/browser/tab_contents/tab_contents.h"
20 #include "chrome/common/devtools_messages.h" 20 #include "chrome/common/devtools_messages.h"
21 #include "chrome/common/render_messages.h" 21 #include "chrome/common/render_messages.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 DebuggerRemoteService::~DebuggerRemoteService() {} 58 DebuggerRemoteService::~DebuggerRemoteService() {}
59 59
60 // This method handles the V8Debugger tool commands which are 60 // This method handles the V8Debugger tool commands which are
61 // retrieved from the request "command" field. If an operation result 61 // retrieved from the request "command" field. If an operation result
62 // is ready off-hand (synchronously), it is sent back to the remote debugger. 62 // is ready off-hand (synchronously), it is sent back to the remote debugger.
63 // Otherwise the corresponding response is received through IPC from the 63 // Otherwise the corresponding response is received through IPC from the
64 // V8 debugger via DevToolsClientHost. 64 // V8 debugger via DevToolsClientHost.
65 void DebuggerRemoteService::HandleMessage( 65 void DebuggerRemoteService::HandleMessage(
66 const DevToolsRemoteMessage& message) { 66 const DevToolsRemoteMessage& message) {
67 const std::string destination = message.destination(); 67 const std::string destination = message.destination();
68 scoped_ptr<Value> request(JSONReader::Read(message.content(), true)); 68 scoped_ptr<Value> request(base::JSONReader::Read(message.content(), true));
69 if (request.get() == NULL) { 69 if (request.get() == NULL) {
70 // Bad JSON 70 // Bad JSON
71 NOTREACHED(); 71 NOTREACHED();
72 return; 72 return;
73 } 73 }
74 DictionaryValue* content; 74 DictionaryValue* content;
75 if (!request->IsType(Value::TYPE_DICTIONARY)) { 75 if (!request->IsType(Value::TYPE_DICTIONARY)) {
76 NOTREACHED(); // Broken protocol :( 76 NOTREACHED(); // Broken protocol :(
77 return; 77 return;
78 } 78 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 void DebuggerRemoteService::OnConnectionLost() { 122 void DebuggerRemoteService::OnConnectionLost() {
123 delegate_->inspectable_tab_proxy()->OnRemoteDebuggerDetached(); 123 delegate_->inspectable_tab_proxy()->OnRemoteDebuggerDetached();
124 } 124 }
125 125
126 // Sends a JSON response to the remote debugger using |response| as content, 126 // Sends a JSON response to the remote debugger using |response| as content,
127 // |tool| and |destination| as the respective header values. 127 // |tool| and |destination| as the respective header values.
128 void DebuggerRemoteService::SendResponse(const Value& response, 128 void DebuggerRemoteService::SendResponse(const Value& response,
129 const std::string& tool, 129 const std::string& tool,
130 const std::string& destination) { 130 const std::string& destination) {
131 std::string response_content; 131 std::string response_content;
132 JSONWriter::Write(&response, false, &response_content); 132 base::JSONWriter::Write(&response, false, &response_content);
133 scoped_ptr<DevToolsRemoteMessage> response_message( 133 scoped_ptr<DevToolsRemoteMessage> response_message(
134 DevToolsRemoteMessageBuilder::instance().Create(tool, 134 DevToolsRemoteMessageBuilder::instance().Create(tool,
135 destination, 135 destination,
136 response_content)); 136 response_content));
137 delegate_->Send(*response_message.get()); 137 delegate_->Send(*response_message.get());
138 } 138 }
139 139
140 // Gets a TabContents instance corresponding to the |tab_uid| using the 140 // Gets a TabContents instance corresponding to the |tab_uid| using the
141 // InspectableTabProxy controllers map, or NULL if none found. 141 // InspectableTabProxy controllers map, or NULL if none found.
142 TabContents* DebuggerRemoteService::ToTabContents(int32 tab_uid) { 142 TabContents* DebuggerRemoteService::ToTabContents(int32 tab_uid) {
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 DevToolsClientHost* client_host = 297 DevToolsClientHost* client_host =
298 manager->GetDevToolsClientHostFor(tab_contents->render_view_host()); 298 manager->GetDevToolsClientHostFor(tab_contents->render_view_host());
299 if (client_host == NULL) { 299 if (client_host == NULL) {
300 // tab_uid is not being debugged (Attach has not been invoked) 300 // tab_uid is not being debugged (Attach has not been invoked)
301 response->SetInteger(kResultWide, RESULT_ILLEGAL_TAB_STATE); 301 response->SetInteger(kResultWide, RESULT_ILLEGAL_TAB_STATE);
302 return true; 302 return true;
303 } 303 }
304 std::string v8_command; 304 std::string v8_command;
305 DictionaryValue* v8_command_value; 305 DictionaryValue* v8_command_value;
306 content->GetDictionary(kDataWide, &v8_command_value); 306 content->GetDictionary(kDataWide, &v8_command_value);
307 JSONWriter::Write(v8_command_value, false, &v8_command); 307 base::JSONWriter::Write(v8_command_value, false, &v8_command);
308 manager->ForwardToDevToolsAgent( 308 manager->ForwardToDevToolsAgent(
309 client_host, DevToolsAgentMsg_DebuggerCommand(v8_command)); 309 client_host, DevToolsAgentMsg_DebuggerCommand(v8_command));
310 // Do not send the response right now, as the JSON will be received from 310 // Do not send the response right now, as the JSON will be received from
311 // the V8 debugger asynchronously. 311 // the V8 debugger asynchronously.
312 return false; 312 return false;
313 } 313 }
314 314
315 // Sends the immediate "evaluate Javascript" command to the V8 debugger. 315 // Sends the immediate "evaluate Javascript" command to the V8 debugger.
316 // The evaluation result is not sent back to the client as this command 316 // The evaluation result is not sent back to the client as this command
317 // is in fact needed to invoke processing of queued debugger commands. 317 // is in fact needed to invoke processing of queued debugger commands.
(...skipping 19 matching lines...) Expand all
337 return true; 337 return true;
338 } 338 }
339 std::wstring javascript; 339 std::wstring javascript;
340 content->GetString(kDataWide, &javascript); 340 content->GetString(kDataWide, &javascript);
341 render_view_host->Send( 341 render_view_host->Send(
342 new ViewMsg_ScriptEvalRequest(render_view_host->routing_id(), 342 new ViewMsg_ScriptEvalRequest(render_view_host->routing_id(),
343 L"", 343 L"",
344 javascript)); 344 javascript));
345 return false; 345 return false;
346 } 346 }
OLDNEW
« no previous file with comments | « chrome/browser/bookmarks/bookmark_storage.cc ('k') | chrome/browser/debugger/devtools_remote_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698