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

Unified Diff: chrome/common/transport_dib_linux.cc

Issue 27147: Linux: server side backing stores (Closed)
Patch Set: ... Created 11 years, 10 months 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 | « chrome/common/transport_dib.h ('k') | chrome/common/x11_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/transport_dib_linux.cc
diff --git a/chrome/common/transport_dib_linux.cc b/chrome/common/transport_dib_linux.cc
index adecf1d9862d658cf4d563b81a79109455aa3a4e..be673d908daeb116eaad02777c27f5d6ee91b25c 100644
--- a/chrome/common/transport_dib_linux.cc
+++ b/chrome/common/transport_dib_linux.cc
@@ -7,8 +7,10 @@
#include <sys/ipc.h>
#include <sys/shm.h>
+#include "base/gfx/size.h"
#include "base/logging.h"
#include "chrome/common/transport_dib.h"
+#include "chrome/common/x11_util.h"
// The shmat system call uses this as it's invalid return address
static void *const kInvalidAddress = (void*) -1;
@@ -16,6 +18,8 @@ static void *const kInvalidAddress = (void*) -1;
TransportDIB::TransportDIB()
: key_(-1),
address_(kInvalidAddress),
+ x_shm_(0),
+ display_(NULL),
size_(0) {
}
@@ -24,6 +28,11 @@ TransportDIB::~TransportDIB() {
shmdt(address_);
address_ = kInvalidAddress;
}
+
+ if (x_shm_) {
+ DCHECK(display_);
+ x11_util::DetachSharedMemory(display_, x_shm_);
+ }
}
// static
@@ -59,7 +68,7 @@ TransportDIB* TransportDIB::Map(Handle shmkey) {
if (shmctl(shmkey, IPC_STAT, &shmst) == -1)
return NULL;
- void* address = shmat(shmkey, NULL /* desired address */, 0 /* flags */);
+ void* address = shmat(shmkey, NULL /* desired address */, SHM_RDONLY);
if (address == kInvalidAddress)
return NULL;
@@ -83,3 +92,12 @@ TransportDIB::Id TransportDIB::id() const {
TransportDIB::Handle TransportDIB::handle() const {
return key_;
}
+
+XID TransportDIB::MapToX(Display* display) {
+ if (!x_shm_) {
+ x_shm_ = x11_util::AttachSharedMemory(display, key_);
+ display_ = display;
+ }
+
+ return x_shm_;
+}
« no previous file with comments | « chrome/common/transport_dib.h ('k') | chrome/common/x11_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698