| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_COMMON_TRANSPORT_DIB_H_ | 5 #ifndef CHROME_COMMON_TRANSPORT_DIB_H_ |
| 6 #define CHROME_COMMON_TRANSPORT_DIB_H_ | 6 #define CHROME_COMMON_TRANSPORT_DIB_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 | 9 |
| 10 #if defined(OS_WIN) || defined(OS_MACOSX) | 10 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 11 #include "base/shared_memory.h" | 11 #include "base/shared_memory.h" |
| 12 #endif | 12 #endif |
| 13 | 13 |
| 14 #if defined(OS_WIN) | 14 #if defined(OS_WIN) |
| 15 #include <windows.h> | 15 #include <windows.h> |
| 16 #elif defined(OS_LINUX) | 16 #elif defined(USE_X11) |
| 17 #include "chrome/common/x11_util.h" | 17 #include "chrome/common/x11_util.h" |
| 18 #endif | 18 #endif |
| 19 | 19 |
| 20 namespace gfx { | 20 namespace gfx { |
| 21 class Size; | 21 class Size; |
| 22 } | 22 } |
| 23 namespace skia { | 23 namespace skia { |
| 24 class PlatformCanvas; | 24 class PlatformCanvas; |
| 25 } | 25 } |
| 26 | 26 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 // Transport DIB. | 74 // Transport DIB. |
| 75 static Handle DefaultHandleValue() { return NULL; } | 75 static Handle DefaultHandleValue() { return NULL; } |
| 76 #elif defined(OS_MACOSX) | 76 #elif defined(OS_MACOSX) |
| 77 typedef base::SharedMemoryHandle Handle; | 77 typedef base::SharedMemoryHandle Handle; |
| 78 // On Mac, the inode number of the backing file is used as an id. | 78 // On Mac, the inode number of the backing file is used as an id. |
| 79 typedef base::SharedMemoryId Id; | 79 typedef base::SharedMemoryId Id; |
| 80 | 80 |
| 81 // Returns a default, invalid handle, that is meant to indicate a missing | 81 // Returns a default, invalid handle, that is meant to indicate a missing |
| 82 // Transport DIB. | 82 // Transport DIB. |
| 83 static Handle DefaultHandleValue() { return Handle(); } | 83 static Handle DefaultHandleValue() { return Handle(); } |
| 84 #elif defined(OS_LINUX) | 84 #elif defined(USE_X11) |
| 85 typedef int Handle; // These two ints are SysV IPC shared memory keys | 85 typedef int Handle; // These two ints are SysV IPC shared memory keys |
| 86 typedef int Id; | 86 typedef int Id; |
| 87 | 87 |
| 88 // Returns a default, invalid handle, that is meant to indicate a missing | 88 // Returns a default, invalid handle, that is meant to indicate a missing |
| 89 // Transport DIB. | 89 // Transport DIB. |
| 90 static Handle DefaultHandleValue() { return -1; } | 90 static Handle DefaultHandleValue() { return -1; } |
| 91 #endif | 91 #endif |
| 92 | 92 |
| 93 // Create a new TransportDIB | 93 // Create a new TransportDIB |
| 94 // size: the minimum size, in bytes | 94 // size: the minimum size, in bytes |
| (...skipping 21 matching lines...) Expand all Loading... |
| 116 size_t size() const { return size_; } | 116 size_t size() const { return size_; } |
| 117 | 117 |
| 118 // Return the identifier which can be used to refer to this shared memory | 118 // Return the identifier which can be used to refer to this shared memory |
| 119 // on the wire. | 119 // on the wire. |
| 120 Id id() const; | 120 Id id() const; |
| 121 | 121 |
| 122 // Return a handle to the underlying shared memory. This can be sent over the | 122 // Return a handle to the underlying shared memory. This can be sent over the |
| 123 // wire to give this transport DIB to another process. | 123 // wire to give this transport DIB to another process. |
| 124 Handle handle() const; | 124 Handle handle() const; |
| 125 | 125 |
| 126 #if defined(OS_LINUX) | 126 #if defined(USE_X11) |
| 127 // Map the shared memory into the X server and return an id for the shared | 127 // Map the shared memory into the X server and return an id for the shared |
| 128 // segment. | 128 // segment. |
| 129 XID MapToX(Display* connection); | 129 XID MapToX(Display* connection); |
| 130 #endif | 130 #endif |
| 131 | 131 |
| 132 private: | 132 private: |
| 133 TransportDIB(); | 133 TransportDIB(); |
| 134 #if defined(OS_WIN) || defined(OS_MACOSX) | 134 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 135 explicit TransportDIB(base::SharedMemoryHandle dib); | 135 explicit TransportDIB(base::SharedMemoryHandle dib); |
| 136 base::SharedMemory shared_memory_; | 136 base::SharedMemory shared_memory_; |
| 137 uint32 sequence_num_; | 137 uint32 sequence_num_; |
| 138 #elif defined(OS_LINUX) | 138 #elif defined(USE_X11) |
| 139 int key_; // SysV shared memory id | 139 int key_; // SysV shared memory id |
| 140 void* address_; // mapped address | 140 void* address_; // mapped address |
| 141 XID x_shm_; // X id for the shared segment | 141 XID x_shm_; // X id for the shared segment |
| 142 Display* display_; // connection to the X server | 142 Display* display_; // connection to the X server |
| 143 #endif | 143 #endif |
| 144 size_t size_; // length, in bytes | 144 size_t size_; // length, in bytes |
| 145 | 145 |
| 146 DISALLOW_COPY_AND_ASSIGN(TransportDIB); | 146 DISALLOW_COPY_AND_ASSIGN(TransportDIB); |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 class MessageLoop; | 149 class MessageLoop; |
| 150 | 150 |
| 151 #endif // CHROME_COMMON_TRANSPORT_DIB_H_ | 151 #endif // CHROME_COMMON_TRANSPORT_DIB_H_ |
| OLD | NEW |