summaryrefslogtreecommitdiff
path: root/chromium/ui/surface
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-08-14 11:38:45 +0200
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-08-14 17:16:47 +0000
commit3a97ca8dd9b96b599ae2d33e40df0dd2f7ea5859 (patch)
tree43cc572ba067417c7341db81f71ae7cc6e0fcc3e /chromium/ui/surface
parentf61ab1ac7f855cd281809255c0aedbb1895e1823 (diff)
downloadqtwebengine-chromium-3a97ca8dd9b96b599ae2d33e40df0dd2f7ea5859.tar.gz
BASELINE: Update chromium to 45.0.2454.40
Change-Id: Id2121d9f11a8fc633677236c65a3e41feef589e4 Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
Diffstat (limited to 'chromium/ui/surface')
-rw-r--r--chromium/ui/surface/transport_dib.cc3
-rw-r--r--chromium/ui/surface/transport_dib.h66
-rw-r--r--chromium/ui/surface/transport_dib_posix.cc36
-rw-r--r--chromium/ui/surface/transport_dib_win.cc17
4 files changed, 19 insertions, 103 deletions
diff --git a/chromium/ui/surface/transport_dib.cc b/chromium/ui/surface/transport_dib.cc
index ba72f91e6d4..3cbd90c7077 100644
--- a/chromium/ui/surface/transport_dib.cc
+++ b/chromium/ui/surface/transport_dib.cc
@@ -19,3 +19,6 @@ bool TransportDIB::VerifyCanvasSize(int w, int h) {
return (stride * h) <= size_;
}
+base::SharedMemory* TransportDIB::shared_memory() {
+ return &shared_memory_;
+}
diff --git a/chromium/ui/surface/transport_dib.h b/chromium/ui/surface/transport_dib.h
index fa2d13283e1..c2321448df3 100644
--- a/chromium/ui/surface/transport_dib.h
+++ b/chromium/ui/surface/transport_dib.h
@@ -24,63 +24,19 @@ class SURFACE_EXPORT TransportDIB {
public:
~TransportDIB();
- // Two typedefs are defined. A Handle is the type which can be sent over
- // the wire so that the remote side can map the transport DIB. The Id typedef
- // is sufficient to identify the transport DIB when you know that the remote
- // side already may have it mapped.
+// A Handle is the type which can be sent over the wire so that the remote
+// side can map the transport DIB.
#if defined(OS_WIN)
typedef HANDLE Handle;
- // On Windows, the Id type includes a sequence number (epoch) to solve an ABA
- // issue:
- // 1) Process A creates a transport DIB with HANDLE=1 and sends to B.
- // 2) Process B maps the transport DIB and caches 1 -> DIB.
- // 3) Process A closes the transport DIB and creates a new one. The new DIB
- // is also assigned HANDLE=1.
- // 4) Process A sends the Handle to B, but B incorrectly believes that it
- // already has it cached.
- struct HandleAndSequenceNum {
- HandleAndSequenceNum()
- : handle(NULL),
- sequence_num(0) {
- }
-
- HandleAndSequenceNum(HANDLE h, uint32 seq_num)
- : handle(h),
- sequence_num(seq_num) {
- }
-
- bool operator==(const HandleAndSequenceNum& other) const {
- return other.handle == handle && other.sequence_num == sequence_num;
- }
-
- bool operator<(const HandleAndSequenceNum& other) const {
- // Use the lexicographic order on the tuple <handle, sequence_num>.
- if (other.handle != handle)
- return other.handle < handle;
- return other.sequence_num < sequence_num;
- }
-
- HANDLE handle;
- uint32 sequence_num;
- };
- typedef HandleAndSequenceNum Id;
-
- // Returns a default, invalid handle, that is meant to indicate a missing
- // Transport DIB.
- static Handle DefaultHandleValue() { return NULL; }
#else // OS_POSIX
typedef base::SharedMemoryHandle Handle;
- // On POSIX, the inode number of the backing file is used as an id.
-#if defined(OS_ANDROID)
- typedef base::SharedMemoryHandle Id;
-#else
- typedef base::SharedMemoryId Id;
#endif
// Returns a default, invalid handle, that is meant to indicate a missing
// Transport DIB.
- static Handle DefaultHandleValue() { return Handle(); }
-#endif
+ static Handle DefaultHandleValue() {
+ return base::SharedMemory::NULLHandle();
+ }
// Create a new TransportDIB, returning NULL on failure.
//
@@ -104,9 +60,6 @@ class SURFACE_EXPORT TransportDIB {
// Returns true if the handle is valid.
static bool is_valid_handle(Handle dib);
- // Returns true if the ID refers to a valid dib.
- static bool is_valid_id(Id id);
-
// Returns a canvas using the memory of this TransportDIB. The returned
// pointer will be owned by the caller. The bitmap will be of the given size,
// which should fit inside this memory.
@@ -131,13 +84,8 @@ class SURFACE_EXPORT TransportDIB {
// the maximum amount that /could/ be valid.
size_t size() const { return size_; }
- // Return the identifier which can be used to refer to this shared memory
- // on the wire.
- Id id() const;
-
- // Return a handle to the underlying shared memory. This can be sent over the
- // wire to give this transport DIB to another process.
- Handle handle() const;
+ // Returns a pointer to the SharedMemory object that backs the transport dib.
+ base::SharedMemory* shared_memory();
private:
TransportDIB();
diff --git a/chromium/ui/surface/transport_dib_posix.cc b/chromium/ui/surface/transport_dib_posix.cc
index 284ed33034d..0a55dbdb0b7 100644
--- a/chromium/ui/surface/transport_dib_posix.cc
+++ b/chromium/ui/surface/transport_dib_posix.cc
@@ -51,28 +51,19 @@ TransportDIB* TransportDIB::CreateWithHandle(Handle handle) {
// static
bool TransportDIB::is_valid_handle(Handle dib) {
- return dib.fd >= 0;
-}
-
-// static
-bool TransportDIB::is_valid_id(Id id) {
-#if defined(OS_ANDROID)
- return is_valid_handle(id);
-#else
- return id != 0;
-#endif
+ return base::SharedMemory::IsHandleValid(dib);
}
skia::PlatformCanvas* TransportDIB::GetPlatformCanvas(int w, int h) {
if ((!memory() && !Map()) || !VerifyCanvasSize(w, h))
return NULL;
- return skia::CreatePlatformCanvas(w, h, true,
+ return skia::CreatePlatformCanvas(w, h, true,
reinterpret_cast<uint8_t*>(memory()),
skia::RETURN_NULL_ON_FAILURE);
}
bool TransportDIB::Map() {
- if (!is_valid_handle(handle()))
+ if (!is_valid_handle(shared_memory_.handle()))
return false;
#if defined(OS_ANDROID)
if (!shared_memory_.Map(0))
@@ -82,13 +73,12 @@ bool TransportDIB::Map() {
if (memory())
return true;
- struct stat st;
- if ((fstat(shared_memory_.handle().fd, &st) != 0) ||
- (!shared_memory_.Map(st.st_size))) {
+ int size = base::SharedMemory::GetSizeFromSharedMemoryHandle(
+ shared_memory_.handle());
+ if (size == -1 || !shared_memory_.Map(size))
return false;
- }
- size_ = st.st_size;
+ size_ = size;
#endif
return true;
}
@@ -96,15 +86,3 @@ bool TransportDIB::Map() {
void* TransportDIB::memory() const {
return shared_memory_.memory();
}
-
-TransportDIB::Id TransportDIB::id() const {
-#if defined(OS_ANDROID)
- return handle();
-#else
- return shared_memory_.id();
-#endif
-}
-
-TransportDIB::Handle TransportDIB::handle() const {
- return shared_memory_.handle();
-}
diff --git a/chromium/ui/surface/transport_dib_win.cc b/chromium/ui/surface/transport_dib_win.cc
index a664266dae6..e8d36adbd5a 100644
--- a/chromium/ui/surface/transport_dib_win.cc
+++ b/chromium/ui/surface/transport_dib_win.cc
@@ -58,11 +58,6 @@ bool TransportDIB::is_valid_handle(Handle dib) {
return dib != NULL;
}
-// static
-bool TransportDIB::is_valid_id(TransportDIB::Id id) {
- return is_valid_handle(id.handle);
-}
-
skia::PlatformCanvas* TransportDIB::GetPlatformCanvas(int w, int h) {
// This DIB already mapped the file into this process, but PlatformCanvas
// will map it again.
@@ -72,7 +67,7 @@ skia::PlatformCanvas* TransportDIB::GetPlatformCanvas(int w, int h) {
// Windows will fail to map the section if the dimensions of the canvas
// are too large.
skia::PlatformCanvas* canvas =
- skia::CreatePlatformCanvas(w, h, true, handle(),
+ skia::CreatePlatformCanvas(w, h, true, shared_memory_.handle(),
skia::RETURN_NULL_ON_FAILURE);
// Calculate the size for the memory region backing the canvas.
@@ -83,7 +78,7 @@ skia::PlatformCanvas* TransportDIB::GetPlatformCanvas(int w, int h) {
}
bool TransportDIB::Map() {
- if (!is_valid_handle(handle()))
+ if (!is_valid_handle(shared_memory_.handle()))
return false;
if (memory())
return true;
@@ -102,11 +97,3 @@ bool TransportDIB::Map() {
void* TransportDIB::memory() const {
return shared_memory_.memory();
}
-
-TransportDIB::Handle TransportDIB::handle() const {
- return shared_memory_.handle();
-}
-
-TransportDIB::Id TransportDIB::id() const {
- return Id(handle(), sequence_num_);
-}