| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/public/common/content_debug_logging.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 |
| 9 namespace content { |
| 10 namespace debug { |
| 11 |
| 12 namespace { |
| 13 |
| 14 // These should be initialized by the process as early in main() as |
| 15 // possible, so should be thread-safe. |
| 16 RecordMsgFn* g_record_handler = NULL; |
| 17 GetMessagesFn* g_get_handler = NULL; |
| 18 |
| 19 } // namespace |
| 20 |
| 21 void RegisterMessageHandlers(RecordMsgFn* record_handler, |
| 22 GetMessagesFn* get_handler) { |
| 23 g_record_handler = record_handler; |
| 24 g_get_handler = get_handler; |
| 25 } |
| 26 |
| 27 void RecordMsg(int bug_id, const std::string& msg) { |
| 28 // TODO(shess): It might be useful to log warnings or even DCHECK if |
| 29 // there is no handler, since that implies that the messages are not |
| 30 // being recorded. Unfortunately, it would also cause dirty test |
| 31 // output. |
| 32 if (g_record_handler) |
| 33 (*g_record_handler)(bug_id, msg); |
| 34 } |
| 35 |
| 36 bool GetMessages(int bug_id, std::vector<std::string>* msgs) { |
| 37 if (g_get_handler) |
| 38 return (*g_get_handler)(bug_id, msgs); |
| 39 |
| 40 msgs->clear(); |
| 41 return false; |
| 42 } |
| 43 |
| 44 } // namespace debug |
| 45 } // namespace content |
| OLD | NEW |