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

Side by Side Diff: chrome/test/chromedriver/logging.h

Issue 14591005: C++ readability review from original change https://chromiumcodereview.appspot.com/14263024/ (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Rewrite ConsoleLogger::OnEvent from stringstream to printf. Created 7 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 (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_LOGGING_H_ 5 #ifndef CHROME_TEST_CHROMEDRIVER_LOGGING_H_
6 #define CHROME_TEST_CHROMEDRIVER_LOGGING_H_ 6 #define CHROME_TEST_CHROMEDRIVER_LOGGING_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/test/chromedriver/chrome/log.h" 14 #include "chrome/test/chromedriver/chrome/log.h"
15 15
16 struct Capabilities; 16 struct Capabilities;
17 class DevToolsEventListener; 17 class DevToolsEventListener;
18 class ListValue; 18 class ListValue;
19 class Status; 19 class Status;
20 20
21 // Accumulates WebDriver Logging API events of a given type and minimum level. 21 // Accumulates WebDriver Logging API entries of a given type and minimum level.
22 // See https://code.google.com/p/selenium/wiki/Logging. 22 // See https://code.google.com/p/selenium/wiki/Logging.
23 class WebDriverLog : public Log { 23 class WebDriverLog : public Log {
24 public: 24 public:
25 // Constants corresponding to log entry severity levels in the wire protocol.
25 enum WebDriverLevel { 26 enum WebDriverLevel {
26 kWdAll, 27 kWdAll,
27 kWdDebug, 28 kWdDebug,
28 kWdInfo, 29 kWdInfo,
29 kWdWarning, 30 kWdWarning,
30 kWdSevere, 31 kWdSevere,
31 kWdOff 32 kWdOff
32 }; 33 };
33 34
34 // Converts WD wire protocol level name -> WebDriverLevel, false on bad name. 35 // Converts WD wire protocol level name -> WebDriverLevel, false on bad name.
35 static bool NameToLevel(const std::string& name, WebDriverLevel* out_level); 36 static bool NameToLevel(const std::string& name, WebDriverLevel* out_level);
36 37
38 // Creates a WebDriverLog with the given type and minimum level.
37 WebDriverLog(const std::string& type, WebDriverLevel min_wd_level); 39 WebDriverLog(const std::string& type, WebDriverLevel min_wd_level);
38 virtual ~WebDriverLog(); 40 virtual ~WebDriverLog();
39 41
42 // Returns this log's type.
jdennett 2013/05/23 03:44:24 That much I could guess from the name ;-) An exam
klm 2013/05/23 15:21:39 Done.
40 const std::string& GetType(); 43 const std::string& GetType();
41 44
45 // Returns entries accumulated so far, as a ListValue ready for serialization
46 // into the wire protocol response to the "/log" command.
47 // The caller assumes ownership of the ListValue, and the WebDriverLog
48 // creates and owns a new empty ListValue for further accumulation.
42 scoped_ptr<base::ListValue> GetAndClearEntries(); 49 scoped_ptr<base::ListValue> GetAndClearEntries();
43 50
51 // Translates a Log entry level into a WebDriver level and stores the entry.
44 virtual void AddEntry(const base::Time& time, 52 virtual void AddEntry(const base::Time& time,
45 Level level, 53 Level level,
46 const std::string& message) OVERRIDE; 54 const std::string& message) OVERRIDE;
47 using Log::AddEntry; // Inherited overload that takes level and message. 55 using Log::AddEntry; // Inherited overload that takes level and message.
48 56
49 private: 57 private:
50 const std::string type_; 58 const std::string type_; // WebDriver log type.
51 const WebDriverLevel min_wd_level_; 59 const WebDriverLevel min_wd_level_; // Minimum level of entries to store.
52 scoped_ptr<base::ListValue> entries_; 60 scoped_ptr<base::ListValue> entries_; // Accumulated entries.
53 61
54 DISALLOW_COPY_AND_ASSIGN(WebDriverLog); 62 DISALLOW_COPY_AND_ASSIGN(WebDriverLog);
55 }; 63 };
56 64
57 // Creates Log's and DevToolsEventListener's for ones that are DevTools-based. 65 // Creates Log's and DevToolsEventListener's for ones that are DevTools-based.
58 Status CreateLogs(const Capabilities& capabilities, 66 Status CreateLogs(const Capabilities& capabilities,
59 ScopedVector<WebDriverLog>* out_devtools_logs, 67 ScopedVector<WebDriverLog>* out_devtools_logs,
60 ScopedVector<DevToolsEventListener>* out_listeners); 68 ScopedVector<DevToolsEventListener>* out_listeners);
61 69
62 #endif // CHROME_TEST_CHROMEDRIVER_LOGGING_H_ 70 #endif // CHROME_TEST_CHROMEDRIVER_LOGGING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698