Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: base/win/scoped_process_information.h

Issue 71013004: Base: Remove Receive() from ScopedHandle. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix delegate_execute for google_chrome_build Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/win/scoped_handle_unittest.cc ('k') | base/win/scoped_process_information.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef BASE_WIN_SCOPED_PROCESS_INFORMATION_H_ 5 #ifndef BASE_WIN_SCOPED_PROCESS_INFORMATION_H_
6 #define BASE_WIN_SCOPED_PROCESS_INFORMATION_H_ 6 #define BASE_WIN_SCOPED_PROCESS_INFORMATION_H_
7 7
8 #include <windows.h> 8 #include <windows.h>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/base_export.h" 11 #include "base/base_export.h"
12 #include "base/win/scoped_handle.h" 12 #include "base/win/scoped_handle.h"
13 13
14 namespace base { 14 namespace base {
15 namespace win { 15 namespace win {
16 16
17 // Manages the closing of process and thread handles from PROCESS_INFORMATION 17 // Manages the closing of process and thread handles from PROCESS_INFORMATION
18 // structures. Allows clients to take ownership of either handle independently. 18 // structures. Allows clients to take ownership of either handle independently.
19 class BASE_EXPORT ScopedProcessInformation { 19 class BASE_EXPORT ScopedProcessInformation {
20 public: 20 public:
21 // Helper object to contain the effect of Receive() to the funtion that needs
22 // a pointer.
23 class Receiver {
24 public:
25 explicit Receiver(ScopedProcessInformation* owner)
26 : info_(),
27 owner_(owner) {}
28 ~Receiver() { owner_->Set(info_); }
29
30 operator PROCESS_INFORMATION*() { return &info_; }
31
32 private:
33 PROCESS_INFORMATION info_;
34 ScopedProcessInformation* owner_;
35 };
36
37 ScopedProcessInformation(); 21 ScopedProcessInformation();
22 explicit ScopedProcessInformation(const PROCESS_INFORMATION& process_info);
38 ~ScopedProcessInformation(); 23 ~ScopedProcessInformation();
39 24
40 // Returns an object that may be passed to API calls such as CreateProcess.
41 // DCHECKs that the object is not currently holding any handles.
42 // HANDLEs stored in the returned PROCESS_INFORMATION will be owned by this
43 // instance.
44 // The intended use case is something like this:
45 // if (::CreateProcess(..., startup_info, scoped_proces_info.Receive()))
46 Receiver Receive();
47
48 // Returns true iff this instance is holding a thread and/or process handle. 25 // Returns true iff this instance is holding a thread and/or process handle.
49 bool IsValid() const; 26 bool IsValid() const;
50 27
51 // Closes the held thread and process handles, if any. 28 // Closes the held thread and process handles, if any.
52 void Close(); 29 void Close();
53 30
54 // Populates this instance with the provided |process_info|. 31 // Populates this instance with the provided |process_info|.
55 void Set(const PROCESS_INFORMATION& process_info); 32 void Set(const PROCESS_INFORMATION& process_info);
56 33
57 // Populates this instance with duplicate handles and the thread/process IDs 34 // Populates this instance with duplicate handles and the thread/process IDs
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 DWORD process_id_; 74 DWORD process_id_;
98 DWORD thread_id_; 75 DWORD thread_id_;
99 76
100 DISALLOW_COPY_AND_ASSIGN(ScopedProcessInformation); 77 DISALLOW_COPY_AND_ASSIGN(ScopedProcessInformation);
101 }; 78 };
102 79
103 } // namespace win 80 } // namespace win
104 } // namespace base 81 } // namespace base
105 82
106 #endif // BASE_WIN_SCOPED_PROCESS_INFORMATION_H_ 83 #endif // BASE_WIN_SCOPED_PROCESS_INFORMATION_H_
OLDNEW
« no previous file with comments | « base/win/scoped_handle_unittest.cc ('k') | base/win/scoped_process_information.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698