| OLD | NEW |
| 1 // Copyright 2015 The Crashpad Authors. All rights reserved. | 1 // Copyright 2015 The Crashpad Authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 // Only one object of this class may exist in the program at a time. There must | 29 // Only one object of this class may exist in the program at a time. There must |
| 30 // not be any log message handler in effect when it is created, and nothing else | 30 // not be any log message handler in effect when it is created, and nothing else |
| 31 // can be set as a log message handler while an object of this class exists. | 31 // can be set as a log message handler while an object of this class exists. |
| 32 // | 32 // |
| 33 // Practically, the only object of this class that might exist is managed by the | 33 // Practically, the only object of this class that might exist is managed by the |
| 34 // g_master lazy instance, which will create it upon first use. | 34 // g_master lazy instance, which will create it upon first use. |
| 35 class ThreadLogMessagesMaster { | 35 class ThreadLogMessagesMaster { |
| 36 public: | 36 public: |
| 37 ThreadLogMessagesMaster() { | 37 ThreadLogMessagesMaster() { |
| 38 DCHECK(!tls_.initialized()); | 38 DCHECK(!tls_.initialized()); |
| 39 CHECK(tls_.Initialize(nullptr)); | 39 tls_.Initialize(nullptr); |
| 40 DCHECK(tls_.initialized()); |
| 40 | 41 |
| 41 DCHECK(!logging::GetLogMessageHandler()); | 42 DCHECK(!logging::GetLogMessageHandler()); |
| 42 logging::SetLogMessageHandler(LogMessageHandler); | 43 logging::SetLogMessageHandler(LogMessageHandler); |
| 43 } | 44 } |
| 44 | 45 |
| 45 ~ThreadLogMessagesMaster() { | 46 ~ThreadLogMessagesMaster() { |
| 46 DCHECK_EQ(logging::GetLogMessageHandler(), LogMessageHandler); | 47 DCHECK_EQ(logging::GetLogMessageHandler(), LogMessageHandler); |
| 47 logging::SetLogMessageHandler(nullptr); | 48 logging::SetLogMessageHandler(nullptr); |
| 48 | 49 |
| 49 tls_.Free(); | 50 tls_.Free(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 ThreadLogMessages::ThreadLogMessages() | 90 ThreadLogMessages::ThreadLogMessages() |
| 90 : log_messages_() { | 91 : log_messages_() { |
| 91 g_master.Get().SetThreadMessageList(&log_messages_); | 92 g_master.Get().SetThreadMessageList(&log_messages_); |
| 92 } | 93 } |
| 93 | 94 |
| 94 ThreadLogMessages::~ThreadLogMessages() { | 95 ThreadLogMessages::~ThreadLogMessages() { |
| 95 g_master.Get().SetThreadMessageList(nullptr); | 96 g_master.Get().SetThreadMessageList(nullptr); |
| 96 } | 97 } |
| 97 | 98 |
| 98 } // namespace crashpad | 99 } // namespace crashpad |
| OLD | NEW |