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

Side by Side Diff: content/browser/debugger/devtools_browser_target.cc

Issue 11548032: Telemetry / Devtools TraceHandler: exposes tracing via dev tools. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pavel comment 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
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 "content/browser/debugger/devtools_browser_target.h"
6
7 #include "base/json/json_reader.h"
8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/values.h"
11
12
13 namespace content {
14
15 DevToolsBrowserTarget::DevToolsBrowserTarget(int connection_id)
16 : connection_id_(connection_id) {
17 }
18
19 DevToolsBrowserTarget::~DevToolsBrowserTarget() {
20 }
21
22 void DevToolsBrowserTarget::RegisterHandler(const std::string& domain,
23 Handler* handler) {
24 handlers_[domain] = handler;
25 }
26
27 base::Value* DevToolsBrowserTarget::OnWebSocketMessage(
28 int connection_id, const std::string& data) {
29 scoped_ptr<base::Value> command(base::JSONReader::Read(data));
30 int request_id;
31 std::string domain;
32 std::string method;
33 base::DictionaryValue* params = NULL;
34 if (command && command->IsType(base::Value::TYPE_DICTIONARY)) {
pfeldman 2012/12/14 10:39:33 Fast return otherwise.
bulach 2012/12/14 16:03:52 Done.
35 base::DictionaryValue* command_dict;
36 command->GetAsDictionary(&command_dict);
37 command_dict->GetInteger("id", &request_id);
38 command_dict->GetString("method", &method);
39 command_dict->GetDictionary("params", &params);
40 }
41 size_t pos = method.find(".");
42 if (pos != std::string::npos)
pfeldman 2012/12/14 10:39:33 Return "error" response that has request id and er
bulach 2012/12/14 16:03:52 Done.
43 domain = method.substr(0, pos);
44 if (domain.empty() || handlers_.find(domain) == handlers_.end())
45 return NULL;
46 base::Value* domain_response = handlers_[domain]->OnProtocolCommand(
47 connection_id, request_id, method, params);
48 base::DictionaryValue* response = new base::DictionaryValue();
49 response->SetInteger("id", request_id);
50 response->Set("response", domain_response);
51 return response;
52 }
53
54 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698