diff options
author | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-05 19:16:07 +0000 |
---|---|---|
committer | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-05 19:16:07 +0000 |
commit | 8cc419448037675e5742586429bb6c00606ce8f9 (patch) | |
tree | 61cd63e10a4c4bd6c4515beb3c0f1489bba0b397 /base | |
parent | 39549bf8f876b17f481e753161166370064458bd (diff) | |
download | chromium_src-8cc419448037675e5742586429bb6c00606ce8f9.zip chromium_src-8cc419448037675e5742586429bb6c00606ce8f9.tar.gz chromium_src-8cc419448037675e5742586429bb6c00606ce8f9.tar.bz2 |
Implementation of single-module-per-logon-session-per-profile implementation for Chrome Frame.
BUG=61383
TEST=Run IE with version X of CF loaded. Register version Y of CF. Run a second IE process, notice that version Y when loaded defers to version X.
Review URL: http://codereview.chromium.org/4144008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65236 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/shared_memory.h | 13 | ||||
-rw-r--r-- | base/shared_memory_win.cc | 20 |
2 files changed, 31 insertions, 2 deletions
diff --git a/base/shared_memory.h b/base/shared_memory.h index 79ea8fd..719eb69 100644 --- a/base/shared_memory.h +++ b/base/shared_memory.h @@ -43,6 +43,13 @@ class SharedMemory { public: SharedMemory(); +#if defined(OS_WIN) + // Similar to the default constructor, except that this allows for + // calling Lock() to acquire the named mutex before either Create or Open + // are called on Windows. + explicit SharedMemory(const std::wstring& name); +#endif + // Create a new SharedMemory object from an existing, open // shared memory file. SharedMemory(SharedMemoryHandle handle, bool read_only); @@ -165,6 +172,12 @@ class SharedMemory { // across Mac and Linux. void Lock(); +#if defined(OS_WIN) + // A Lock() implementation with a timeout. Returns true if the Lock() has + // been acquired, false if the timeout was reached. + bool Lock(uint32 timeout_ms); +#endif + // Releases the shared memory lock. void Unlock(); diff --git a/base/shared_memory_win.cc b/base/shared_memory_win.cc index a0b2a5a..5f293fc 100644 --- a/base/shared_memory_win.cc +++ b/base/shared_memory_win.cc @@ -17,6 +17,15 @@ SharedMemory::SharedMemory() lock_(NULL) { } +SharedMemory::SharedMemory(const std::wstring& name) + : mapped_file_(NULL), + memory_(NULL), + read_only_(false), + created_size_(0), + lock_(NULL), + name_(name) { +} + SharedMemory::SharedMemory(SharedMemoryHandle handle, bool read_only) : mapped_file_(handle), memory_(NULL), @@ -188,6 +197,10 @@ void SharedMemory::Close() { } void SharedMemory::Lock() { + Lock(INFINITE); +} + +bool SharedMemory::Lock(uint32 timeout_ms) { if (lock_ == NULL) { std::wstring name = name_; name.append(L"lock"); @@ -195,10 +208,13 @@ void SharedMemory::Lock() { DCHECK(lock_ != NULL); if (lock_ == NULL) { DLOG(ERROR) << "Could not create mutex" << GetLastError(); - return; // there is nothing good we can do here. + return false; // there is nothing good we can do here. } } - WaitForSingleObject(lock_, INFINITE); + DWORD result = WaitForSingleObject(lock_, timeout_ms); + + // Return false for WAIT_ABANDONED, WAIT_TIMEOUT or WAIT_FAILED. + return (result == WAIT_OBJECT_0); } void SharedMemory::Unlock() { |