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

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: address comments, deque for listeners, reentrant test Created 4 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 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::LogMessageHandler 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 : logging::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() override;
27 27
28 static const char* kDebugMessageTypeName; 28 static const char* kDebugMessageTypeName;
29 29
30 // logging::LogMessageHandler
31 bool OnMessage(int severity,
32 const char* file,
33 int line,
34 size_t message_start,
35 const std::string& str) override;
36
30 private: 37 private:
31 static bool OnLogMessage(
32 int severity, const char* file, int line,
33 size_t message_start, const std::string& str);
34 void PostLogMessageToCorrectThread( 38 void PostLogMessageToCorrectThread(
35 int severity, const char* file, int line, 39 int severity, const char* file, int line,
36 size_t message_start, const std::string& str); 40 size_t message_start, const std::string& str);
37 void SendLogMessageToClient( 41 void SendLogMessageToClient(
38 int severity, const char* file, int line, 42 int severity, const char* file, int line,
39 size_t message_start, const std::string& str); 43 size_t message_start, const std::string& str);
40 44
41 Delegate delegate_; 45 Delegate delegate_;
42 bool suppress_logging_; 46 bool suppress_logging_;
43 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; 47 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_;
44 logging::LogMessageHandlerFunction previous_log_message_handler_;
45 base::WeakPtrFactory<LogMessageHandler> weak_ptr_factory_; 48 base::WeakPtrFactory<LogMessageHandler> weak_ptr_factory_;
46 }; 49 };
47 50
48 } // namespace remoting 51 } // namespace remoting
49 52
50 #endif 53 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698