зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1793834 - part 8: add preference for number of messages to keep r=handyman
One thing to note is that if the user shrinks this number we won't reclaim any memory - this is because I wanted to avoid doing any more work than necessary when we're logging messages. Let me know if you think this is a problem! Differential Revision: https://phabricator.services.mozilla.com/D161156
This commit is contained in:
Родитель
14270825ef
Коммит
9fb7e92244
|
@ -14671,6 +14671,13 @@
|
|||
type: RelaxedAtomicInt32
|
||||
value: 0
|
||||
mirror: always
|
||||
|
||||
# The number of messages of each type to keep for display in
|
||||
# about:windows-messages
|
||||
- name: widget.windows.messages_to_log
|
||||
type: RelaxedAtomicUint32
|
||||
value: 6
|
||||
mirror: always
|
||||
#endif
|
||||
|
||||
# Whether to flush the Ole clipboard synchronously.
|
||||
|
|
|
@ -79,8 +79,6 @@ struct CircularMessageBuffer {
|
|||
};
|
||||
static std::map<HWND, std::map<UINT, CircularMessageBuffer>> gWindowMessages;
|
||||
|
||||
const size_t kNumberOfWindowMessages = 5;
|
||||
|
||||
static HWND GetHwndFromWidget(nsIWidget* windowWidget) {
|
||||
nsWindow* window = static_cast<nsWindow*>(windowWidget);
|
||||
return window->GetWindowHandle();
|
||||
|
@ -264,7 +262,9 @@ void LogWindowMessage(HWND hwnd, UINT event, bool isPreEvent, long eventCounter,
|
|||
WindowMessageData messageData = {
|
||||
eventCounter, isPreEvent, MakeMessageSpecificData(event, wParam, lParam),
|
||||
result, retValue};
|
||||
if (hwndWindowMessages.mMessages.size() < kNumberOfWindowMessages) {
|
||||
uint32_t numberOfMessagesToKeep =
|
||||
Preferences::GetUint("widget.windows.messages_to_log", 6);
|
||||
if (hwndWindowMessages.mMessages.size() < numberOfMessagesToKeep) {
|
||||
// haven't reached limit yet
|
||||
hwndWindowMessages.mMessages.push_back(std::move(messageData));
|
||||
} else {
|
||||
|
@ -272,7 +272,7 @@ void LogWindowMessage(HWND hwnd, UINT event, bool isPreEvent, long eventCounter,
|
|||
std::move(messageData);
|
||||
}
|
||||
hwndWindowMessages.mNextFreeIndex =
|
||||
(hwndWindowMessages.mNextFreeIndex + 1) % kNumberOfWindowMessages;
|
||||
(hwndWindowMessages.mNextFreeIndex + 1) % numberOfMessagesToKeep;
|
||||
}
|
||||
|
||||
void GetLatestWindowMessages(RefPtr<nsIWidget> windowWidget,
|
||||
|
@ -281,8 +281,9 @@ void GetLatestWindowMessages(RefPtr<nsIWidget> windowWidget,
|
|||
const auto& rawMessages = gWindowMessages[hwnd];
|
||||
nsTArray<std::pair<WindowMessageDataSortKey, nsCString>>
|
||||
sortKeyAndMessageArray;
|
||||
sortKeyAndMessageArray.SetCapacity(rawMessages.size() *
|
||||
kNumberOfWindowMessages);
|
||||
sortKeyAndMessageArray.SetCapacity(
|
||||
rawMessages.size() *
|
||||
Preferences::GetUint("widget.windows.messages_to_log", 6));
|
||||
for (const auto& eventAndMessage : rawMessages) {
|
||||
for (const auto& messageData : eventAndMessage.second.mMessages) {
|
||||
nsCString message = MakeFriendlyMessage(
|
||||
|
|
Загрузка…
Ссылка в новой задаче