Page Speed Optimization Libraries  1.9.32.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
system_message_handler.h
Go to the documentation of this file.
1 /*
2  * Copyright 2014 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http:///www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 #ifndef NET_INSTAWEB_SYSTEM_PUBLIC_SYSTEM_MESSAGE_HANDLER_H_
20 #define NET_INSTAWEB_SYSTEM_PUBLIC_SYSTEM_MESSAGE_HANDLER_H_
21 
22 #include "pagespeed/kernel/base/basictypes.h"
23 #include "pagespeed/kernel/base/google_message_handler.h"
24 #include "pagespeed/kernel/base/message_handler.h"
25 #include "pagespeed/kernel/base/null_message_handler.h"
26 #include "pagespeed/kernel/base/scoped_ptr.h"
27 #include "pagespeed/kernel/base/string.h"
28 #include "pagespeed/kernel/base/string_util.h"
29 
30 namespace net_instaweb {
31 
32 class AbstractMutex;
33 class Timer;
34 class Writer;
35 
38 class SystemMessageHandler : public GoogleMessageHandler {
39  public:
40  SystemMessageHandler(Timer* timer, AbstractMutex* mutex);
41 
42  virtual ~SystemMessageHandler();
43 
47  void set_buffer(Writer* buff);
48 
49  void SetPidString(const int64 pid) {
50  pid_string_ = StrCat("[", Integer64ToString(pid), "]");
51  }
52 
54  virtual bool Dump(Writer* writer);
55 
56  protected:
59  virtual void AddMessageToBuffer(MessageType type,
60  StringPiece formatted_message);
61 
62  private:
63  friend class SystemMessageHandlerTest;
64 
67  Timer* timer_;
68  scoped_ptr<AbstractMutex> mutex_;
69  Writer* buffer_;
74  GoogleMessageHandler internal_handler_;
75  GoogleString pid_string_;
76  NullMessageHandler null_handler_;
77 
78  DISALLOW_COPY_AND_ASSIGN(SystemMessageHandler);
79 };
80 
81 }
82 
83 #endif
virtual void AddMessageToBuffer(MessageType type, StringPiece formatted_message)
virtual bool Dump(Writer *writer)
Dump contents of SharedCircularBuffer.
Definition: system_message_handler.h:38