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

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

Issue 2888073002: Remove raw DictionaryValue::Set in //chrome (Closed)
Patch Set: Fix Tests Created 3 years, 7 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 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/test/chromedriver/devtools_events_logger.h" 5 #include "chrome/test/chromedriver/devtools_events_logger.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/memory/ptr_util.h"
9 #include "base/values.h"
8 #include "chrome/test/chromedriver/chrome/devtools_client.h" 10 #include "chrome/test/chromedriver/chrome/devtools_client.h"
9 #include "chrome/test/chromedriver/chrome/devtools_client_impl.h" 11 #include "chrome/test/chromedriver/chrome/devtools_client_impl.h"
10 12
11 DevToolsEventsLogger::DevToolsEventsLogger(Log* log, 13 DevToolsEventsLogger::DevToolsEventsLogger(Log* log,
12 const base::ListValue* prefs) 14 const base::ListValue* prefs)
13 : log_(log), 15 : log_(log),
14 prefs_(prefs) {} 16 prefs_(prefs) {}
15 17
16 inline DevToolsEventsLogger::~DevToolsEventsLogger() {} 18 inline DevToolsEventsLogger::~DevToolsEventsLogger() {}
17 19
18 Status DevToolsEventsLogger::OnConnected(DevToolsClient* client) { 20 Status DevToolsEventsLogger::OnConnected(DevToolsClient* client) {
19 for (base::ListValue::const_iterator it = prefs_->begin(); 21 for (base::ListValue::const_iterator it = prefs_->begin();
20 it != prefs_->end(); 22 it != prefs_->end();
21 ++it) { 23 ++it) {
22 std::string event; 24 std::string event;
23 it->GetAsString(&event); 25 it->GetAsString(&event);
24 events_.insert(event); 26 events_.insert(event);
25 } 27 }
26 return Status(kOk); 28 return Status(kOk);
27 } 29 }
28 30
29 Status DevToolsEventsLogger::OnEvent(DevToolsClient* client, 31 Status DevToolsEventsLogger::OnEvent(DevToolsClient* client,
30 const std::string& method, 32 const std::string& method,
31 const base::DictionaryValue& params) { 33 const base::DictionaryValue& params) {
32 std::unordered_set<std::string>::iterator it = events_.find(method); 34 std::unordered_set<std::string>::iterator it = events_.find(method);
33 if (it != events_.end()) { 35 if (it != events_.end()) {
34 base::DictionaryValue log_message_dict; 36 base::DictionaryValue log_message_dict;
35 log_message_dict.SetString("method", method); 37 log_message_dict.SetString("method", method);
36 log_message_dict.Set("params", params.DeepCopy()); 38 log_message_dict.Set("params", base::MakeUnique<base::Value>(params));
37 std::string log_message_json; 39 std::string log_message_json;
38 base::JSONWriter::Write(log_message_dict, &log_message_json); 40 base::JSONWriter::Write(log_message_dict, &log_message_json);
39 41
40 log_->AddEntry(Log::kInfo, log_message_json); 42 log_->AddEntry(Log::kInfo, log_message_json);
41 } 43 }
42 return Status(kOk); 44 return Status(kOk);
43 } 45 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698