diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-24 22:27:04 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-24 22:27:04 +0000 |
commit | 8ceb44c74fc375df749b60acc6fc01b5327c6d18 (patch) | |
tree | 0512ef018e445f45d142e8a79ed4a19b9390b6d3 /base | |
parent | c16b5958cc9a47992e6c24473258582773036af5 (diff) | |
download | chromium_src-8ceb44c74fc375df749b60acc6fc01b5327c6d18.zip chromium_src-8ceb44c74fc375df749b60acc6fc01b5327c6d18.tar.gz chromium_src-8ceb44c74fc375df749b60acc6fc01b5327c6d18.tar.bz2 |
I just put the code that does not compile on ARM. Trybots will fail because I had to remove these from the CL to make gcl upload properly accept it.
A + base\scoped_open_process.h
A + chrome\plugin\command_buffer_stub_win.cc
TEST=try
BUG=none
Review URL: http://codereview.chromium.org/661022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39937 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/base.gypi | 1 | ||||
-rw-r--r-- | base/scoped_open_process.h | 49 |
2 files changed, 50 insertions, 0 deletions
diff --git a/base/base.gypi b/base/base.gypi index aee1361..1d4b3e0 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -179,6 +179,7 @@ 'scoped_nsautorelease_pool.mm', 'scoped_nsdisable_screen_updates.h', 'scoped_nsobject.h', + 'scoped_open_process.h', 'scoped_ptr.h', 'scoped_temp_dir.cc', 'scoped_temp_dir.h', diff --git a/base/scoped_open_process.h b/base/scoped_open_process.h new file mode 100644 index 0000000..9badc76 --- /dev/null +++ b/base/scoped_open_process.h @@ -0,0 +1,49 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef BASE_SCOPED_OPEN_PROCESS_H_ +#define BASE_SCOPED_OPEN_PROCESS_H_ + +#include "base/process.h" +#include "base/process_util.h" + +namespace base { + +// A class that opens a process from its process id and closes it when the +// instance goes out of scope. +class ScopedOpenProcess { + public: + ScopedOpenProcess() : handle_(kNullProcessHandle) { + } + + // Automatically close the process. + ~ScopedOpenProcess() { + Close(); + } + + // Open a new process by pid. Closes any previously opened process (even if + // opening the new one fails). + bool Open(ProcessId pid) { + Close(); + return OpenProcessHandle(pid, &handle_); + } + + // Close the previously opened process. + void Close() { + if (handle_ == kNullProcessHandle) + return; + + CloseProcessHandle(handle_); + handle_ = kNullProcessHandle; + } + + ProcessHandle handle() const { return handle_; } + + private: + ProcessHandle handle_; + DISALLOW_COPY_AND_ASSIGN(ScopedOpenProcess); +}; +} // namespace base + +#endif // BASE_SCOPED_OPEN_PROCESS_H_ |