| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #ifndef CHROME_TEST_CHROMEDRIVER_CHROME_CONSOLE_LOGGER_H_ | 5 #ifndef CHROME_TEST_CHROMEDRIVER_CHROME_CONSOLE_LOGGER_H_ |
| 6 #define CHROME_TEST_CHROMEDRIVER_CHROME_CONSOLE_LOGGER_H_ | 6 #define CHROME_TEST_CHROMEDRIVER_CHROME_CONSOLE_LOGGER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "chrome/test/chromedriver/chrome/devtools_event_listener.h" | 10 #include "chrome/test/chromedriver/chrome/devtools_event_listener.h" |
| 11 | 11 |
| 12 class Log; | 12 class Log; |
| 13 | 13 |
| 14 // Translates DevTools Console.messageAdded events into Log messages. | 14 // Translates DevTools Console.messageAdded events into Log messages. |
| 15 // | 15 // |
| 16 // The message format, in terms of Console.ConsoleMessage fields, is: | 16 // The message format, in terms of Console.ConsoleMessage fields, is: |
| 17 // "<url or source> [<line>[:<column>]] text" | 17 // "<url or source> [<line>[:<column>]] text" |
| 18 // | 18 // |
| 19 // Translates the level into Log::Level, drops all other fields. | 19 // Translates the level into Log::Level, drops all other fields. |
| 20 class ConsoleLogger : public DevToolsEventListener { | 20 class ConsoleLogger : public DevToolsEventListener { |
| 21 public: | 21 public: |
| 22 // Creates a ConsoleLogger that creates entries in the given Log object. | 22 // Creates a ConsoleLogger that creates entries in the given Log object. |
| 23 // The log is owned elsewhere and must not be null. | 23 // The log is owned elsewhere and must not be null. |
| 24 explicit ConsoleLogger(Log* log); | 24 explicit ConsoleLogger(Log* log); |
| 25 | 25 |
| 26 // Enables Console events for the client, which must not be null. | 26 // Enables Console events for the client, which must not be null. |
| 27 virtual Status OnConnected(DevToolsClient* client) OVERRIDE; | 27 virtual Status OnConnected(DevToolsClient* client) override; |
| 28 // Translates an event into a log entry. | 28 // Translates an event into a log entry. |
| 29 virtual Status OnEvent(DevToolsClient* client, | 29 virtual Status OnEvent(DevToolsClient* client, |
| 30 const std::string& method, | 30 const std::string& method, |
| 31 const base::DictionaryValue& params) OVERRIDE; | 31 const base::DictionaryValue& params) override; |
| 32 | 32 |
| 33 private: | 33 private: |
| 34 Log* log_; // The log where to create entries. | 34 Log* log_; // The log where to create entries. |
| 35 | 35 |
| 36 DISALLOW_COPY_AND_ASSIGN(ConsoleLogger); | 36 DISALLOW_COPY_AND_ASSIGN(ConsoleLogger); |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 #endif // CHROME_TEST_CHROMEDRIVER_CHROME_CONSOLE_LOGGER_H_ | 39 #endif // CHROME_TEST_CHROMEDRIVER_CHROME_CONSOLE_LOGGER_H_ |
| OLD | NEW |