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

Unified Diff: remoting/host/native_messaging/log_message_handler.h

Issue 1272833002: Pass error messages from native messaging to web-app. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit tests. Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: remoting/host/native_messaging/log_message_handler.h
diff --git a/remoting/host/native_messaging/log_message_handler.h b/remoting/host/native_messaging/log_message_handler.h
new file mode 100644
index 0000000000000000000000000000000000000000..e4d17ef2f33219c27bf4b9008e543cf50414a516
--- /dev/null
+++ b/remoting/host/native_messaging/log_message_handler.h
@@ -0,0 +1,48 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef REMOTING_HOST_NATIVE_MESSAGIN_LOG_HANDLER_H_
+#define REMOTING_HOST_NATIVE_MESSAGIN_LOG_HANDLER_H_
+
+#include <string>
+
+#include "base/callback.h"
+#include "base/memory/weak_ptr.h"
+#include "base/values.h"
+
+namespace remoting {
+
+// Helper class for logging::SetLogMessageHandler to deliver log messages to
+// a consistent thread in a thread-safe way and in a format suitable for sending
+// over a Native Messaging channel.
+class LogMessageHandler {
+ public:
+ typedef base::Callback<void (scoped_ptr<base::Value> message)> Delegate;
+
+ explicit LogMessageHandler(const Delegate& delegate);
+ ~LogMessageHandler();
+
+ static const char* debug_message_type_name;
Sergey Ulanov 2015/08/20 21:50:21 kDebugMessageTypeName
Jamie 2015/08/20 22:29:16 Done.
+
+ private:
+ static bool OnLogMessage(
+ int severity, const char* file, int line,
+ size_t message_start, const std::string& str);
+ void PostLogMessageToCorrectThread(
+ int severity, const char* file, int line,
+ size_t message_start, const std::string& str);
+ void SendLogMessageToClient(
+ int severity, const char* file, int line,
+ size_t message_start, const std::string& str);
+
+ Delegate delegate_;
+ bool suppress_logging_;
+ scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_;
+ logging::LogMessageHandlerFunction previous_log_message_handler_;
+ base::WeakPtrFactory<LogMessageHandler> weak_ptr_factory_;
+};
+
+} // namespace remoting
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698