Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mock_message_handler.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010 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 PAGESPEED_KERNEL_BASE_MOCK_MESSAGE_HANDLER_H_
20 #define PAGESPEED_KERNEL_BASE_MOCK_MESSAGE_HANDLER_H_
21 
22 #include <map>
23 
31 
32 namespace net_instaweb {
33 
34 class AbstractMutex;
35 class Writer;
36 
40  public:
42  explicit MockMessageHandler(AbstractMutex* mutex);
43 
44  virtual ~MockMessageHandler();
45 
47  int MessagesOfType(MessageType type) const;
48 
50  int TotalMessages() const;
51 
53  int SkippedMessagesOfType(MessageType type) const;
54 
56  int TotalSkippedMessages() const;
57 
59  int SeriousMessages() const;
60 
62  void set_mutex(AbstractMutex* mutex);
63 
66  void AddPatternToSkipPrinting(const char* pattern);
67 
69  virtual bool Dump(Writer* writer);
70 
71  protected:
72  virtual void MessageSImpl(MessageType type, const GoogleString& message);
73 
74  virtual void FileMessageSImpl(MessageType type, const char* filename,
75  int line, const GoogleString& message);
76 
77  private:
79  bool ShouldPrintMessage(const StringPiece& msg);
80 
81  private:
82  typedef std::map<MessageType, int> MessageCountMap;
83 
85  int TotalMessagesImpl(const MessageCountMap& counts) const;
86  int MessagesOfTypeImpl(const MessageCountMap& counts,
87  MessageType type) const;
88 
90  MessageCountMap message_counts_;
91  MessageCountMap skipped_message_counts_;
92  FastWildcardGroup patterns_to_skip_;
93  GoogleString buffer_;
95  GoogleMessageHandler internal_handler_;
96 
97 
98 };
99 
100 }
101 
102 #endif
Definition: fast_wildcard_group.h:94
MockMessageHandler(AbstractMutex *mutex)
Takes ownership of the mutex.
virtual bool Dump(Writer *writer)
Dumps contents of String Buffer.
void set_mutex(AbstractMutex *mutex)
Takes ownership of the mutex.
int SeriousMessages() const
Returns number of messages of severity higher than info.
Abstract interface for implementing a mutex.
Definition: abstract_mutex.h:28
int SkippedMessagesOfType(MessageType type) const
Returns number of messages which are not printed.
int TotalSkippedMessages() const
Returns total number of messages which are not printed.
int TotalMessages() const
Returns total number of messages issued.
Definition: mock_message_handler.h:39
Definition: scoped_ptr.h:30
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
virtual void MessageSImpl(MessageType type, const GoogleString &message)
Interface for writing bytes to an output stream.
Definition: writer.h:29
int MessagesOfType(MessageType type) const
Returns number of messages of given type issued.
Definition: message_handler.h:39
void AddPatternToSkipPrinting(const char *pattern)
Definition: google_message_handler.h:35