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

Unified Diff: ui/surface/transport_dib_posix.cc

Issue 1143243007: Extract some logic from transport_dib into shared_memory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix inverted conditional. Created 5 years, 7 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 | « base/memory/shared_memory_posix.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/surface/transport_dib_posix.cc
diff --git a/ui/surface/transport_dib_posix.cc b/ui/surface/transport_dib_posix.cc
index 284ed33034dfc0145d4e9dbfc3527a5e57f3c564..e26fdb2d7c6e4a93c6932e071616ce5eae68f5a4 100644
--- a/ui/surface/transport_dib_posix.cc
+++ b/ui/surface/transport_dib_posix.cc
@@ -51,7 +51,7 @@ TransportDIB* TransportDIB::CreateWithHandle(Handle handle) {
// static
bool TransportDIB::is_valid_handle(Handle dib) {
- return dib.fd >= 0;
+ return base::SharedMemory::IsHandleValid(dib);
}
// static
@@ -66,7 +66,7 @@ bool TransportDIB::is_valid_id(Id id) {
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);
}
@@ -82,13 +82,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;
}
« no previous file with comments | « base/memory/shared_memory_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698