Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: installer/src/installer-lib/process.h

Issue 5663180676136960: Make sure IE and Engine are actually being closed by custom action (Closed)
Patch Set: Created June 20, 2014, 10:33 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /** 1 /**
2 * \file process.h 2 * \file process.h
3 */ 3 */
4 4
5 #ifndef PROCESS_H 5 #ifndef PROCESS_H
6 #define PROCESS_H 6 #define PROCESS_H
7 7
8 #include "installer-lib.h" 8 #include "installer-lib.h"
9 #include "handle.h" 9 #include "handle.h"
10 10
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 for ( unsigned int j = 0 ; j < n_file_names ; ++ j ) 85 for ( unsigned int j = 0 ; j < n_file_names ; ++ j )
86 { 86 {
87 insert( wstring_ci( file_name_list[ j ] ) ) ; 87 insert( wstring_ci( file_name_list[ j ] ) ) ;
88 } 88 }
89 } 89 }
90 } ; 90 } ;
91 91
92 //------------------------------------------------------- 92 //-------------------------------------------------------
93 //------------------------------------------------------- 93 //-------------------------------------------------------
94 /** 94 /**
95 * Filter by process name. Comparison is case-insensitive. With ABP module loade d 95 * Filter by process name. Comparison is case-insensitive. Windows Store app pro cesses excluded
96 */ 96 */
97 class process_by_any_exe_with_any_module 97 class process_by_any_exe_not_immersive
98 : public std::binary_function< PROCESSENTRY32W, file_name_set, bool > 98 : public std::unary_function<PROCESSENTRY32W, bool>
99 { 99 {
100 /** 100 /**
101 * Set of file names from which to match candidate process names. 101 * Set of file names from which to match candidate process names.
102 * 102 *
103 * This is a reference to, not a copy of, the set. 103 * This is a reference to, not a copy of, the set.
104 * The lifetime of this object must be subordinate to that of its referent. 104 * The lifetime of this object must be subordinate to that of its referent.
105 * The set used to instantiate this class is a member of Process_Closer, 105 * The set used to instantiate this class is a member of Process_Closer,
106 * and so also is this class. 106 * and so also is this class.
107 * Hence the lifetimes are coterminous, and the reference is not problematic. 107 * Hence the lifetimes are coterminous, and the reference is not problematic.
108 */ 108 */
109 const file_name_set & processNames ; 109 const file_name_set & processNames;
110 const file_name_set & moduleNames;
111 public: 110 public:
112 bool operator()( const PROCESSENTRY32W & ) ; 111 bool operator()( const PROCESSENTRY32W & );
113 process_by_any_exe_with_any_module( const file_name_set & names, const file_na me_set & moduleNames ) 112 process_by_any_exe_not_immersive(const file_name_set & names) : processNames( names ) {}
114 : processNames( names ), moduleNames( moduleNames )
115 {}
116 } ; 113 } ;
117 114
118 115
119 //------------------------------------------------------- 116 //-------------------------------------------------------
120 // Process utility functions. 117 // Process utility functions.
121 //------------------------------------------------------- 118 //-------------------------------------------------------
122 /** 119 /**
123 * A promiscuous filter admits everything. 120 * A promiscuous filter admits everything.
124 */ 121 */
125 struct every_process 122 struct every_process
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 std::set< DWORD > pid_set ; 598 std::set< DWORD > pid_set ;
602 599
603 /** 600 /**
604 * Set of executable names by which to filter. 601 * Set of executable names by which to filter.
605 * 602 *
606 * The argument of the filter constructor is a set by reference. 603 * The argument of the filter constructor is a set by reference.
607 * Since it does not make a copy for itself, we define it as a class member to provide its allocation. 604 * Since it does not make a copy for itself, we define it as a class member to provide its allocation.
608 */ 605 */
609 file_name_set process_names ; 606 file_name_set process_names ;
610 607
611 /** 608 process_by_any_exe_not_immersive filter ;
612 * Set of module (DLL) names by which to filter.
613 */
614 file_name_set module_names ;
615
616 process_by_any_exe_with_any_module filter ;
617 609
618 /** 610 /**
619 * Copy function object copies just the process ID. 611 * Copy function object copies just the process ID.
620 */ 612 */
621 copy_PID copy ; 613 copy_PID copy ;
622 614
623 /** 615 /**
624 * Snapshot of running processes. 616 * Snapshot of running processes.
625 */ 617 */
626 Process_Snapshot & snapshot ; 618 Process_Snapshot & snapshot ;
(...skipping 30 matching lines...) Expand all
657 if ( ! b ) 649 if ( ! b )
658 { 650 {
659 // Assert the process that created the window is not in our pid_set 651 // Assert the process that created the window is not in our pid_set
660 return true ; 652 return true ;
661 } 653 }
662 return f( window ) ; 654 return f( window ) ;
663 } 655 }
664 } ; 656 } ;
665 657
666 public: 658 public:
667 template <size_t n_file_names, size_t n_module_names> 659 template <size_t n_file_names>
668 Process_Closer(Process_Snapshot & snapshot, const wchar_t* (&file_name_list)[n _file_names], const wchar_t* (&module_name_list)[n_module_names]) 660 Process_Closer(Process_Snapshot & snapshot, const wchar_t * (&file_name_list)[ n_file_names])
669 : snapshot(snapshot), process_names(file_name_list), module_names(module_nam e_list), filter(process_names, module_names) 661 : snapshot(snapshot), process_names(file_name_list), filter(process_names)
670 { 662 {
671 update() ; 663 update() ;
672 } 664 }
673 template <size_t n_file_names>
674 Process_Closer(Process_Snapshot & snapshot, const wchar_t * (&file_name_list)[ n_file_names])
675 : snapshot(snapshot), process_names(file_name_list), module_names(), filter( process_names, module_names)
676 {
677 update() ;
678 }
679 665
680 /** 666 /**
681 * Refresh our state to match the snapshot state. 667 * Refresh our state to match the snapshot state.
682 */ 668 */
683 void refresh() 669 void refresh()
684 { 670 {
685 pid_set.clear() ; 671 pid_set.clear() ;
686 update() ; 672 update() ;
687 } 673 }
688 674
689 bool is_running() { return ! pid_set.empty() ; } ; 675 bool is_running() { return ! pid_set.empty() ; } ;
690 676
691 bool contains( DWORD pid ) const { return pid_set.find( pid ) != pid_set.end() ; } ; 677 bool contains( DWORD pid ) const { return pid_set.find( pid ) != pid_set.end() ; } ;
692 678
693 template< class F > 679 template< class F >
694 bool iterate_our_windows( F f ) 680 bool iterate_our_windows( F f )
695 { 681 {
696 only_our_processes< F > g( * this, f ) ; 682 only_our_processes< F > g( * this, f ) ;
697 return enumerate_windows( g ) ; 683 return enumerate_windows( g ) ;
698 } 684 }
699 685
700 /* 686 /*
701 * Shut down every process in the pid_set. 687 * Shut down every process in the pid_set.
702 */ 688 */
703 bool shut_down() ; 689 bool shut_down() ;
704 690
705 } ; 691 } ;
706 692
707 #endif 693 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld