Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
|
jam
2011/09/20 02:59:05
why isn't thisi handle_enumerator_win.h as well?
| |
| 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 #ifndef CONTENT_BROWSER_HANDLE_ENUMERATOR_WIN_H_ | 5 #ifndef CONTENT_COMMON_HANDLE_ENUMERATOR_H_ |
| 6 #define CONTENT_BROWSER_HANDLE_ENUMERATOR_WIN_H_ | 6 #define CONTENT_COMMON_HANDLE_ENUMERATOR_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/process.h" | 9 #include "base/process.h" |
| 10 #include "content/common/child_process_info.h" | 10 #include "base/string16.h" |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 | 13 |
| 14 enum HandleType { | 14 enum HandleType { |
| 15 ProcessHandle, | 15 ProcessHandle, |
| 16 ThreadHandle, | 16 ThreadHandle, |
| 17 FileHandle, | 17 FileHandle, |
| 18 DirectoryHandle, | 18 DirectoryHandle, |
| 19 KeyHandle, | 19 KeyHandle, |
| 20 WindowStationHandle, | 20 WindowStationHandle, |
| 21 DesktopHandle, | 21 DesktopHandle, |
| 22 ServiceHandle, | 22 ServiceHandle, |
| 23 EventHandle, | 23 EventHandle, |
| 24 MutexHandle, | 24 MutexHandle, |
| 25 SemaphoreHandle, | 25 SemaphoreHandle, |
| 26 TimerHandle, | 26 TimerHandle, |
| 27 NamedPipeHandle, | 27 NamedPipeHandle, |
| 28 JobHandle, | 28 JobHandle, |
| 29 FileMapHandle, | 29 FileMapHandle, |
| 30 AlpcPortHandle, | 30 AlpcPortHandle, |
| 31 OtherHandle | 31 OtherHandle |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 static HandleType StringToHandleType(const string16& type); | 34 static HandleType StringToHandleType(const string16& type); |
| 35 | 35 |
| 36 static string16 ProcessTypeString(ChildProcessInfo::ProcessType process_type); | |
| 37 | |
| 38 static string16 GetAccessString(HandleType handle_type, ACCESS_MASK access); | 36 static string16 GetAccessString(HandleType handle_type, ACCESS_MASK access); |
| 39 | 37 |
| 40 class HandleEnumerator : public base::RefCountedThreadSafe<HandleEnumerator> { | 38 class HandleEnumerator : public base::RefCountedThreadSafe<HandleEnumerator> { |
| 41 public: | 39 public: |
| 42 enum HandleEnumStatus { | 40 explicit HandleEnumerator(bool all_handles): |
| 43 Starting, | |
| 44 InProgress, | |
| 45 Finished | |
| 46 }; | |
| 47 | |
| 48 HandleEnumerator(base::ProcessHandle handle, bool all_handles): | |
| 49 handle_(handle), | |
| 50 type_(ChildProcessInfo::UNKNOWN_PROCESS), | |
| 51 status_(Starting), | |
| 52 all_handles_(all_handles) { } | 41 all_handles_(all_handles) { } |
| 53 | 42 |
| 54 ChildProcessInfo::ProcessType type() const { return type_; } | |
| 55 | |
| 56 HandleEnumStatus status() const { return status_; } | |
| 57 | |
| 58 void RunHandleEnumeration(); | |
| 59 | |
| 60 void EnumerateHandles(); | 43 void EnumerateHandles(); |
| 61 | 44 |
| 62 private: | 45 private: |
| 63 void FindProcessOnIOThread(); | |
| 64 | |
| 65 void FindProcessOnUIThread(); | |
| 66 | |
| 67 void EnumerateHandlesAndTerminateProcess(); | |
| 68 | |
| 69 base::ProcessHandle handle_; | |
| 70 ChildProcessInfo::ProcessType type_; | |
| 71 HandleEnumStatus status_; | |
| 72 bool all_handles_; | 46 bool all_handles_; |
| 73 | 47 |
| 74 DISALLOW_COPY_AND_ASSIGN(HandleEnumerator); | 48 DISALLOW_COPY_AND_ASSIGN(HandleEnumerator); |
| 75 }; | 49 }; |
| 76 | 50 |
| 77 } // namespace content | 51 } // namespace content |
| 78 | 52 |
| 79 #endif // CONTENT_BROWSER_HANDLE_ENUMERATOR_WIN_H_ | 53 #endif // CONTENT_COMMON_HANDLE_ENUMERATOR_H_ |
| 54 | |
| OLD | NEW |