diff options
author | kkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-20 19:18:30 +0000 |
---|---|---|
committer | kkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-20 19:18:30 +0000 |
commit | 36808add2cec1c95898ddf6037040a5637e6e846 (patch) | |
tree | c8234c82029df45fa62841644cc2b22cacc73fb5 /app/surface/transport_dib_linux.cc | |
parent | 38e13cb3da9cec27ae90430f7f9d95986ce3d90f (diff) | |
download | chromium_src-36808add2cec1c95898ddf6037040a5637e6e846.zip chromium_src-36808add2cec1c95898ddf6037040a5637e6e846.tar.gz chromium_src-36808add2cec1c95898ddf6037040a5637e6e846.tar.bz2 |
Revert 63232 - On Windows, create a new TransportDIB::Handle struct which includes the file
mapping HANDLE and the source process ID. Duplicating the handle for the
remote process is done in TransportDIB::Map, instead of in various #ifdefs
scattered across the code. Also on windows, remove the struct for the
TransportDIB::Id which contained both the sequence number and the HANDLE and
replace it with just the sequence number.
Fix ThumbnailGenerator by mapping the TransportDIB on Windows and adding
a method to duplicate the file mapping handle before sending across the
channel.
Also, add a ScopedHandle and fix some handle leaks.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/3834003
TBR=kkania@chromium.org
Review URL: http://codereview.chromium.org/3943002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63246 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/surface/transport_dib_linux.cc')
-rw-r--r-- | app/surface/transport_dib_linux.cc | 46 |
1 files changed, 10 insertions, 36 deletions
diff --git a/app/surface/transport_dib_linux.cc b/app/surface/transport_dib_linux.cc index ac8d71b..26cad3f 100644 --- a/app/surface/transport_dib_linux.cc +++ b/app/surface/transport_dib_linux.cc @@ -17,9 +17,6 @@ // The shmat system call uses this as it's invalid return address static void *const kInvalidAddress = (void*) -1; -void TransportDIB::ScopedHandle::Close() { -} - TransportDIB::TransportDIB() : key_(-1), address_(kInvalidAddress), @@ -68,57 +65,34 @@ TransportDIB* TransportDIB::Create(size_t size, uint32 sequence_num) { return dib; } -// static -TransportDIB* TransportDIB::Map(Handle handle) { - scoped_ptr<TransportDIB> dib(CreateWithHandle(handle)); - if (!dib->Map()) +TransportDIB* TransportDIB::Map(Handle shmkey) { + struct shmid_ds shmst; + if (shmctl(shmkey, IPC_STAT, &shmst) == -1) + return NULL; + + void* address = shmat(shmkey, NULL /* desired address */, 0 /* flags */); + if (address == kInvalidAddress) return NULL; - return dib.release(); -} -// static -TransportDIB* TransportDIB::CreateWithHandle(Handle shmkey) { TransportDIB* dib = new TransportDIB; + + dib->address_ = address; + dib->size_ = shmst.shm_segsz; dib->key_ = shmkey; return dib; } -// static bool TransportDIB::is_valid(Handle dib) { return dib >= 0; } skia::PlatformCanvas* TransportDIB::GetPlatformCanvas(int w, int h) { - if (address_ == kInvalidAddress && !Map()) - return NULL; scoped_ptr<skia::PlatformCanvas> canvas(new skia::PlatformCanvas); if (!canvas->initialize(w, h, true, reinterpret_cast<uint8_t*>(memory()))) return NULL; return canvas.release(); } -bool TransportDIB::Map() { - if (address_ != kInvalidAddress) - return true; - - struct shmid_ds shmst; - if (shmctl(key_, IPC_STAT, &shmst) == -1) - return false; - - void* address = shmat(key_, NULL /* desired address */, 0 /* flags */); - if (address == kInvalidAddress) - return false; - - address_ = address; - size_ = shmst.shm_segsz; - return true; -} - -TransportDIB::Handle TransportDIB::GetHandleForProcess( - base::ProcessHandle process_handle) const { - return handle(); -} - void* TransportDIB::memory() const { DCHECK_NE(address_, kInvalidAddress); return address_; |