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

Unified Diff: base/win/scoped_process_information.h

Issue 92173002: Merge 237541 "Revert of https://codereview.chromium.org/71013004/" (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1721/src/
Patch Set: Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/win/scoped_handle_unittest.cc ('k') | base/win/scoped_process_information.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/win/scoped_process_information.h
===================================================================
--- base/win/scoped_process_information.h (revision 237598)
+++ base/win/scoped_process_information.h (working copy)
@@ -18,10 +18,33 @@
// structures. Allows clients to take ownership of either handle independently.
class BASE_EXPORT ScopedProcessInformation {
public:
+ // Helper object to contain the effect of Receive() to the funtion that needs
+ // a pointer.
+ class Receiver {
+ public:
+ explicit Receiver(ScopedProcessInformation* owner)
+ : info_(),
+ owner_(owner) {}
+ ~Receiver() { owner_->Set(info_); }
+
+ operator PROCESS_INFORMATION*() { return &info_; }
+
+ private:
+ PROCESS_INFORMATION info_;
+ ScopedProcessInformation* owner_;
+ };
+
ScopedProcessInformation();
- explicit ScopedProcessInformation(const PROCESS_INFORMATION& process_info);
~ScopedProcessInformation();
+ // Returns an object that may be passed to API calls such as CreateProcess.
+ // DCHECKs that the object is not currently holding any handles.
+ // HANDLEs stored in the returned PROCESS_INFORMATION will be owned by this
+ // instance.
+ // The intended use case is something like this:
+ // if (::CreateProcess(..., startup_info, scoped_proces_info.Receive()))
+ Receiver Receive();
+
// Returns true iff this instance is holding a thread and/or process handle.
bool IsValid() const;
« 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