| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // The memory_watcher.dll is hooked by simply linking it. When we get the | 5 // The memory_watcher.dll is hooked by simply linking it. When we get the |
| 6 // windows notification that this DLL is loaded, we do a few things: | 6 // windows notification that this DLL is loaded, we do a few things: |
| 7 // 1) Register a Hot Key. | 7 // 1) Register a Hot Key. |
| 8 // Only one process can hook the Hot Key, so one will get it, and the | 8 // Only one process can hook the Hot Key, so one will get it, and the |
| 9 // others will silently fail. | 9 // others will silently fail. |
| 10 // 2) Create a thread to wait on an event. | 10 // 2) Create a thread to wait on an event. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 static HANDLE g_dump_event = INVALID_HANDLE_VALUE; | 28 static HANDLE g_dump_event = INVALID_HANDLE_VALUE; |
| 29 static HANDLE g_quit_event = INVALID_HANDLE_VALUE; | 29 static HANDLE g_quit_event = INVALID_HANDLE_VALUE; |
| 30 static HANDLE g_watcher_thread = INVALID_HANDLE_VALUE; | 30 static HANDLE g_watcher_thread = INVALID_HANDLE_VALUE; |
| 31 | 31 |
| 32 // A HotKey to dump the memory statistics. | 32 // A HotKey to dump the memory statistics. |
| 33 class MemoryWatcherDumpKey : public HotKeyHandler { | 33 class MemoryWatcherDumpKey : public HotKeyHandler { |
| 34 public: | 34 public: |
| 35 MemoryWatcherDumpKey(UINT modifiers, UINT vkey) | 35 MemoryWatcherDumpKey(UINT modifiers, UINT vkey) |
| 36 : HotKeyHandler(modifiers, vkey) {} | 36 : HotKeyHandler(modifiers, vkey) {} |
| 37 | 37 |
| 38 virtual LRESULT OnHotKey(UINT, WPARAM, LPARAM, BOOL& bHandled) { | 38 virtual void OnHotKey(UINT, WPARAM, LPARAM) { |
| 39 SetEvent(g_dump_event); | 39 SetEvent(g_dump_event); |
| 40 return 1; | |
| 41 } | 40 } |
| 42 }; | 41 }; |
| 43 | 42 |
| 44 // Creates the global memory watcher. | 43 // Creates the global memory watcher. |
| 45 void CreateMemoryWatcher() { | 44 void CreateMemoryWatcher() { |
| 46 g_memory_watcher_exit_manager = new base::AtExitManager(); | 45 g_memory_watcher_exit_manager = new base::AtExitManager(); |
| 47 g_memory_watcher = new MemoryWatcher(); | 46 g_memory_watcher = new MemoryWatcher(); |
| 48 // Register ALT-CONTROL-D to Dump Memory stats. | 47 // Register ALT-CONTROL-D to Dump Memory stats. |
| 49 g_hotkey_handler = new MemoryWatcherDumpKey(MOD_ALT|MOD_CONTROL, 0x44); | 48 g_hotkey_handler = new MemoryWatcherDumpKey(MOD_ALT|MOD_CONTROL, 0x44); |
| 50 } | 49 } |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 break; | 145 break; |
| 147 } | 146 } |
| 148 return TRUE; | 147 return TRUE; |
| 149 } | 148 } |
| 150 | 149 |
| 151 __declspec(dllexport) void __cdecl SetLogName(char* name) { | 150 __declspec(dllexport) void __cdecl SetLogName(char* name) { |
| 152 g_memory_watcher->SetLogName(name); | 151 g_memory_watcher->SetLogName(name); |
| 153 } | 152 } |
| 154 | 153 |
| 155 } // extern "C" | 154 } // extern "C" |
| OLD | NEW |