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

Side by Side Diff: chrome/test/chromedriver/devtools_client.cc

Issue 11415205: [chromedriver] Implement connecting to devtools and loading a page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 8 years 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
« no previous file with comments | « chrome/test/chromedriver/devtools_client.h ('k') | chrome/test/chromedriver/net/net_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/test/chromedriver/devtools_client.h"
6
7 #include "base/json/json_writer.h"
8 #include "base/values.h"
9 #include "chrome/test/chromedriver/net/sync_websocket.h"
10 #include "chrome/test/chromedriver/net/url_request_context_getter.h"
11 #include "chrome/test/chromedriver/status.h"
12 #include "googleurl/src/gurl.h"
13
14 DevToolsClient::DevToolsClient(
15 URLRequestContextGetter* context_getter,
16 const std::string& url)
17 : context_getter_(context_getter),
18 url_(url),
19 socket_(new SyncWebSocket(context_getter)),
20 connected_(false) {}
21
22 DevToolsClient::~DevToolsClient() {}
23
24 Status DevToolsClient::SendCommand(
25 const std::string& method,
26 const base::DictionaryValue& params) {
27 if (!connected_) {
28 if (!socket_->Connect(GURL(url_)))
29 return Status(kUnknownError, "unable to connect to renderer");
30 connected_ = true;
31 }
32 base::DictionaryValue command;
33 command.SetInteger("id", 1);
34 command.SetString("method", method);
35 command.Set("params", params.DeepCopy());
36 std::string message;
37 base::JSONWriter::Write(&command, &message);
38 if (!socket_->Send(message))
39 return Status(kUnknownError, "unable to send message to renderer");
40 std::string response;
41 if (!socket_->ReceiveNextMessage(&response))
42 return Status(kUnknownError, "unable to receive message from renderer");
43 return Status(kOk);
44 }
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/devtools_client.h ('k') | chrome/test/chromedriver/net/net_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698