Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 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 REMOTING_HOST_NATIVE_MESSAGIN_LOG_HANDLER_H_ | |
| 6 #define REMOTING_HOST_NATIVE_MESSAGIN_LOG_HANDLER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/callback.h" | |
| 11 #include "base/memory/weak_ptr.h" | |
| 12 #include "base/values.h" | |
| 13 | |
| 14 namespace remoting { | |
| 15 | |
| 16 // Helper class for logging::SetLogMessageHandler to deliver log messages to | |
| 17 // a consistent thread in a thread-safe way and in a format suitable for sending | |
| 18 // over a Native Messaging channel. | |
| 19 class LogMessageHandler { | |
| 20 public: | |
| 21 typedef base::Callback<void (scoped_ptr<base::Value> message)> Delegate; | |
| 22 | |
| 23 explicit LogMessageHandler(const Delegate& delegate); | |
| 24 ~LogMessageHandler(); | |
| 25 | |
| 26 static const char* debug_message_type_name; | |
|
Sergey Ulanov
2015/08/20 21:50:21
kDebugMessageTypeName
Jamie
2015/08/20 22:29:16
Done.
| |
| 27 | |
| 28 private: | |
| 29 static bool OnLogMessage( | |
| 30 int severity, const char* file, int line, | |
| 31 size_t message_start, const std::string& str); | |
| 32 void PostLogMessageToCorrectThread( | |
| 33 int severity, const char* file, int line, | |
| 34 size_t message_start, const std::string& str); | |
| 35 void SendLogMessageToClient( | |
| 36 int severity, const char* file, int line, | |
| 37 size_t message_start, const std::string& str); | |
| 38 | |
| 39 Delegate delegate_; | |
| 40 bool suppress_logging_; | |
| 41 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; | |
| 42 logging::LogMessageHandlerFunction previous_log_message_handler_; | |
| 43 base::WeakPtrFactory<LogMessageHandler> weak_ptr_factory_; | |
| 44 }; | |
| 45 | |
| 46 } // namespace remoting | |
| 47 | |
| 48 #endif | |
| OLD | NEW |