OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 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_events_logger.h" | |
6 | |
7 #include "base/json/json_writer.h" | |
8 #include "chrome/test/chromedriver/chrome/devtools_client.h" | |
9 #include "chrome/test/chromedriver/chrome/devtools_client_impl.h" | |
10 | |
11 DevToolsEventsLogger::DevToolsEventsLogger(Log* log, | |
12 const base::ListValue* prefs) | |
stgao
2017/05/03 20:24:44
style nit: params not aligned.
em
2017/05/04 01:11:22
Done.
| |
13 : log_(log), | |
14 prefs_(prefs) {} | |
15 | |
16 inline DevToolsEventsLogger::~DevToolsEventsLogger() {} | |
17 | |
18 Status DevToolsEventsLogger::OnConnected(DevToolsClient* client) { | |
19 for (base::ListValue::const_iterator it = prefs_->begin(); | |
20 it != prefs_->end(); | |
21 ++it) { | |
22 std::string event; | |
23 it->GetAsString(&event); | |
24 events_.insert(event); | |
25 } | |
26 return Status(kOk); | |
27 } | |
28 | |
29 Status DevToolsEventsLogger::OnEvent( | |
30 DevToolsClient* client, | |
31 const std::string& method, | |
32 const base::DictionaryValue& params) { | |
33 std::unordered_set<std::string>::iterator it = events_.find(method); | |
34 if (it != events_.end()) { | |
35 base::DictionaryValue log_message_dict; | |
36 log_message_dict.SetString("method", method); | |
37 log_message_dict.Set("params", params.DeepCopy()); | |
38 std::string log_message_json; | |
39 base::JSONWriter::Write(log_message_dict, &log_message_json); | |
40 | |
41 log_->AddEntry(Log::kInfo, log_message_json); | |
42 } | |
43 return Status(kOk); | |
44 } | |
OLD | NEW |