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