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

Side by Side Diff: remoting/host/native_messaging/log_message_handler.h

Issue 2034393004: Allow multiple logging::LogMessage{Handler,Listener}s Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix installation_validator_unittest Created 4 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 2015 The Chromium Authors. All rights reserved. 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 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 REMOTING_HOST_NATIVE_MESSAGIN_LOG_HANDLER_H_ 5 #ifndef REMOTING_HOST_NATIVE_MESSAGIN_LOG_HANDLER_H_
6 #define REMOTING_HOST_NATIVE_MESSAGIN_LOG_HANDLER_H_ 6 #define REMOTING_HOST_NATIVE_MESSAGIN_LOG_HANDLER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 15
16 namespace remoting { 16 namespace remoting {
17 17
18 // Helper class for logging::SetLogMessageHandler to deliver log messages to 18 // Helper class for logging::PushLogMessageHandler to deliver log messages to
19 // a consistent thread in a thread-safe way and in a format suitable for sending 19 // a consistent thread in a thread-safe way and in a format suitable for sending
20 // over a Native Messaging channel. 20 // over a Native Messaging channel.
21 class LogMessageHandler { 21 class LogMessageHandler {
22 public: 22 public:
23 typedef base::Callback<void(std::unique_ptr<base::Value> message)> Delegate; 23 typedef base::Callback<void(std::unique_ptr<base::Value> message)> Delegate;
24 24
25 explicit LogMessageHandler(const Delegate& delegate); 25 explicit LogMessageHandler(const Delegate& delegate);
26 ~LogMessageHandler(); 26 ~LogMessageHandler();
27 27
28 static const char* kDebugMessageTypeName; 28 static const char* kDebugMessageTypeName;
29 29
30 private: 30 private:
31 static bool OnLogMessage( 31 static bool OnLogMessage(
32 int severity, const char* file, int line, 32 int severity, const char* file, int line,
33 size_t message_start, const std::string& str); 33 size_t message_start, const std::string& str);
34 void PostLogMessageToCorrectThread( 34 void PostLogMessageToCorrectThread(
35 int severity, const char* file, int line, 35 int severity, const char* file, int line,
36 size_t message_start, const std::string& str); 36 size_t message_start, const std::string& str);
37 void SendLogMessageToClient( 37 void SendLogMessageToClient(
38 int severity, const char* file, int line, 38 int severity, const char* file, int line,
39 size_t message_start, const std::string& str); 39 size_t message_start, const std::string& str);
40 40
41 Delegate delegate_; 41 Delegate delegate_;
42 bool suppress_logging_; 42 bool suppress_logging_;
43 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; 43 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_;
44 logging::LogMessageHandlerFunction previous_log_message_handler_;
45 base::WeakPtrFactory<LogMessageHandler> weak_ptr_factory_; 44 base::WeakPtrFactory<LogMessageHandler> weak_ptr_factory_;
46 }; 45 };
47 46
48 } // namespace remoting 47 } // namespace remoting
49 48
50 #endif 49 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698