Bring the browser window to the front when clicking on deprecated accelerator notific...
[chromium-blink-merge.git] / remoting / host / native_messaging / log_message_handler.h
blob74596fa19038a20d24a92b0132d73b19d5696ec9
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.
5 #ifndef REMOTING_HOST_NATIVE_MESSAGIN_LOG_HANDLER_H_
6 #define REMOTING_HOST_NATIVE_MESSAGIN_LOG_HANDLER_H_
8 #include "base/callback.h"
9 #include "base/memory/weak_ptr.h"
10 #include "base/values.h"
12 namespace remoting {
14 // Helper class for logging::SetLogMessageHandler to deliver log messages to
15 // a consistent thread in a thread-safe way and in a format suitable for sending
16 // over a Native Messaging channel.
17 class LogMessageHandler {
18 public:
19 typedef base::Callback<void (scoped_ptr<base::Value> message)> Delegate;
21 explicit LogMessageHandler(const Delegate& delegate);
22 ~LogMessageHandler();
24 static const char* kDebugMessageTypeName;
26 private:
27 static bool OnLogMessage(
28 int severity, const char* file, int line,
29 size_t message_start, const std::string& str);
30 void PostLogMessageToCorrectThread(
31 int severity, const char* file, int line,
32 size_t message_start, const std::string& str);
33 void SendLogMessageToClient(
34 int severity, const char* file, int line,
35 size_t message_start, const std::string& str);
37 Delegate delegate_;
38 bool suppress_logging_;
39 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_;
40 logging::LogMessageHandlerFunction previous_log_message_handler_;
41 base::WeakPtrFactory<LogMessageHandler> weak_ptr_factory_;
44 } // namespace remoting
46 #endif