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

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

Issue 2497833002: support multiple log message handlers in base/logging.h (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « remoting/host/logging_mac.cc ('k') | remoting/host/native_messaging/log_message_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 16
17 namespace base { 17 namespace base {
18 class SingleThreadTaskRunner; 18 class SingleThreadTaskRunner;
19 } 19 }
20 20
21 namespace remoting { 21 namespace remoting {
22 22
23 // Helper class for logging::SetLogMessageHandler to deliver log messages to 23 // Helper class for logging::AddLogMessageHandler to deliver log messages to
24 // a consistent thread in a thread-safe way and in a format suitable for sending 24 // a consistent thread in a thread-safe way and in a format suitable for sending
25 // over a Native Messaging channel. 25 // over a Native Messaging channel.
26 class LogMessageHandler { 26 class LogMessageHandler {
27 public: 27 public:
28 typedef base::Callback<void(std::unique_ptr<base::Value> message)> Delegate; 28 typedef base::Callback<void(std::unique_ptr<base::Value> message)> Delegate;
29 29
30 explicit LogMessageHandler(const Delegate& delegate); 30 explicit LogMessageHandler(const Delegate& delegate);
31 ~LogMessageHandler(); 31 ~LogMessageHandler();
32 32
33 static const char* kDebugMessageTypeName; 33 static const char* kDebugMessageTypeName;
34 34
35 private: 35 private:
36 static bool OnLogMessage( 36 static bool OnLogMessage(
37 int severity, const char* file, int line, 37 int severity, const char* file, int line,
38 size_t message_start, const std::string& str); 38 size_t message_start, const std::string& str);
39 void PostLogMessageToCorrectThread( 39 void PostLogMessageToCorrectThread(
40 int severity, const char* file, int line, 40 int severity, const char* file, int line,
41 size_t message_start, const std::string& str); 41 size_t message_start, const std::string& str);
42 void SendLogMessageToClient( 42 void SendLogMessageToClient(
43 int severity, const char* file, int line, 43 int severity, const char* file, int line,
44 size_t message_start, const std::string& str); 44 size_t message_start, const std::string& str);
45 45
46 Delegate delegate_; 46 Delegate delegate_;
47 bool suppress_logging_; 47 bool suppress_logging_;
48 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; 48 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_;
49 logging::LogMessageHandlerFunction previous_log_message_handler_;
50 base::WeakPtrFactory<LogMessageHandler> weak_ptr_factory_; 49 base::WeakPtrFactory<LogMessageHandler> weak_ptr_factory_;
51 }; 50 };
52 51
53 } // namespace remoting 52 } // namespace remoting
54 53
55 #endif 54 #endif
OLDNEW
« no previous file with comments | « remoting/host/logging_mac.cc ('k') | remoting/host/native_messaging/log_message_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698