Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 EXTENSIONS_RENDERER_CONSOLE_H_ | 5 #ifndef EXTENSIONS_RENDERER_CONSOLE_H_ |
| 6 #define EXTENSIONS_RENDERER_CONSOLE_H_ | 6 #define EXTENSIONS_RENDERER_CONSOLE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "content/public/common/console_message_level.h" | 10 #include "content/public/common/console_message_level.h" |
| 11 #include "v8/include/v8.h" | 11 #include "v8/include/v8.h" |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 class RenderFrame; | 14 class RenderFrame; |
| 15 } | 15 } |
| 16 | 16 |
| 17 namespace extensions { | 17 namespace extensions { |
| 18 | 18 |
| 19 // Utility for logging messages to RenderFrames. | 19 // Utility for logging messages to RenderFrames. |
| 20 namespace console { | 20 namespace console { |
| 21 | 21 |
| 22 // Adds |message| to the console of |render_frame|. If |render_frame| is null, | 22 // Adds |message| to the console of |render_frame|. If |render_frame| is null, |
| 23 // LOG()s the message instead. | 23 // LOG()s the message instead. |
| 24 void Debug(content::RenderFrame* render_frame, const std::string& message); | 24 void AddMessage(content::RenderFrame* render_frame, |
| 25 void Log(content::RenderFrame* render_frame, const std::string& message); | 25 content::ConsoleMessageLevel level, |
| 26 void Warn(content::RenderFrame* render_frame, const std::string& message); | 26 const std::string& message); |
| 27 void Error(content::RenderFrame* render_frame, const std::string& message); | 27 inline void Debug(content::RenderFrame* render_frame, |
|
Devlin
2017/02/27 22:32:12
Given we now bind these to the same function and j
jbroman
2017/02/27 22:52:49
I'd made it compile-time-inlinable, and I did noti
| |
| 28 const std::string& message) { | |
| 29 AddMessage(render_frame, content::CONSOLE_MESSAGE_LEVEL_VERBOSE, message); | |
| 30 } | |
| 31 inline void Log(content::RenderFrame* render_frame, | |
| 32 const std::string& message) { | |
| 33 AddMessage(render_frame, content::CONSOLE_MESSAGE_LEVEL_INFO, message); | |
| 34 } | |
| 35 inline void Warn(content::RenderFrame* render_frame, | |
| 36 const std::string& message) { | |
| 37 AddMessage(render_frame, content::CONSOLE_MESSAGE_LEVEL_WARNING, message); | |
| 38 } | |
| 39 inline void Error(content::RenderFrame* render_frame, | |
| 40 const std::string& message) { | |
| 41 AddMessage(render_frame, content::CONSOLE_MESSAGE_LEVEL_ERROR, message); | |
| 42 } | |
| 28 | 43 |
| 29 // Logs an Error then crashes the current process. | 44 // Logs an Error then crashes the current process. |
| 30 void Fatal(content::RenderFrame* render_frame, const std::string& message); | 45 void Fatal(content::RenderFrame* render_frame, const std::string& message); |
| 31 | 46 |
| 32 void AddMessage(content::RenderFrame* render_frame, | |
| 33 content::ConsoleMessageLevel level, | |
| 34 const std::string& message); | |
| 35 | |
| 36 // Returns a new v8::Object with each standard log method (Debug/Log/Warn/Error) | 47 // Returns a new v8::Object with each standard log method (Debug/Log/Warn/Error) |
| 37 // bound to respective debug/log/warn/error methods. This is a direct drop-in | 48 // bound to respective debug/log/warn/error methods. This is a direct drop-in |
| 38 // replacement for the standard devtools console.* methods usually accessible | 49 // replacement for the standard devtools console.* methods usually accessible |
| 39 // from JS. | 50 // from JS. |
| 40 v8::Local<v8::Object> AsV8Object(v8::Isolate* isolate); | 51 v8::Local<v8::Object> AsV8Object(v8::Isolate* isolate); |
| 41 | 52 |
| 42 } // namespace console | 53 } // namespace console |
| 43 | 54 |
| 44 } // namespace extensions | 55 } // namespace extensions |
| 45 | 56 |
| 46 #endif // EXTENSIONS_RENDERER_CONSOLE_H_ | 57 #endif // EXTENSIONS_RENDERER_CONSOLE_H_ |
| OLD | NEW |