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

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: Fix types in CHECK comparisons. Created 7 years, 6 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, for the WD wire protocol "/log" and "/log/types".
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
44 virtual void AddEntry(const base::Time& time, 51 // Translates a Log entry level into a WebDriver level and stores the entry.
45 Level level, 52 virtual void AddEntryTimestamped(const base::Time& timestamp,
46 const std::string& message) OVERRIDE; 53 Level level,
47 using Log::AddEntry; // Inherited overload that takes level and message. 54 const std::string& message) OVERRIDE;
48 55
49 private: 56 private:
50 const std::string type_; 57 const std::string type_; // WebDriver log type.
51 const WebDriverLevel min_wd_level_; 58 const WebDriverLevel min_wd_level_; // Minimum level of entries to store.
52 scoped_ptr<base::ListValue> entries_; 59 scoped_ptr<base::ListValue> entries_; // Accumulated entries.
53 60
54 DISALLOW_COPY_AND_ASSIGN(WebDriverLog); 61 DISALLOW_COPY_AND_ASSIGN(WebDriverLog);
55 }; 62 };
56 63
57 // Creates Log's and DevToolsEventListener's for ones that are DevTools-based. 64 // Creates Log's and DevToolsEventListener's for ones that are DevTools-based.
58 Status CreateLogs(const Capabilities& capabilities, 65 Status CreateLogs(const Capabilities& capabilities,
59 ScopedVector<WebDriverLog>* out_devtools_logs, 66 ScopedVector<WebDriverLog>* out_devtools_logs,
60 ScopedVector<DevToolsEventListener>* out_listeners); 67 ScopedVector<DevToolsEventListener>* out_listeners);
61 68
62 #endif // CHROME_TEST_CHROMEDRIVER_LOGGING_H_ 69 #endif // CHROME_TEST_CHROMEDRIVER_LOGGING_H_
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/chrome/performance_logger_unittest.cc ('k') | chrome/test/chromedriver/logging.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698