Bug 1426284 - Remove TransportDIB files. r=jld
PluginMessageUtils.h was bootlegging base/shared_memory.h via transport_dib.h
MozReview-Commit-ID: CPGxu2lpdj0
--- a/dom/plugins/ipc/PluginMessageUtils.h
+++ b/dom/plugins/ipc/PluginMessageUtils.h
@@ -4,16 +4,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef DOM_PLUGINS_PLUGINMESSAGEUTILS_H
#define DOM_PLUGINS_PLUGINMESSAGEUTILS_H
#include "ipc/IPCMessageUtils.h"
#include "base/message_loop.h"
+#include "base/shared_memory.h"
#include "mozilla/ipc/CrossProcessMutex.h"
#include "mozilla/ipc/MessageChannel.h"
#include "mozilla/ipc/ProtocolUtils.h"
#include "mozilla/UniquePtr.h"
#include "gfxipc/ShadowLayerUtils.h"
#include "npapi.h"
--- a/ipc/chromium/moz.build
+++ b/ipc/chromium/moz.build
@@ -47,17 +47,16 @@ if os_win:
'src/base/sys_info_win.cc',
'src/base/sys_string_conversions_win.cc',
'src/base/thread_local_win.cc',
'src/base/time_win.cc',
'src/base/waitable_event_win.cc',
'src/base/win_util.cc',
'src/chrome/common/ipc_channel_win.cc',
'src/chrome/common/process_watcher_win.cc',
- 'src/chrome/common/transport_dib_win.cc',
]
elif not CONFIG['MOZ_SYSTEM_LIBEVENT']:
DIRS += ['src/third_party']
if os_posix:
UNIFIED_SOURCES += [
'src/base/condition_variable_posix.cc',
@@ -86,17 +85,16 @@ if os_macosx:
'src/base/message_pump_mac.mm',
'src/base/process_util_mac.mm',
'src/base/scoped_nsautorelease_pool.mm',
'src/base/sys_info_mac.cc',
'src/base/sys_string_conversions_mac.mm',
'src/base/time_mac.cc',
'src/chrome/common/mach_ipc_mac.mm',
'src/chrome/common/mach_message_source_mac.cc',
- 'src/chrome/common/transport_dib_mac.cc',
]
SOURCES += [
# This file cannot be built in unified mode because of the redefinition
# of NoOp.
'src/base/platform_thread_mac.mm',
]
if os_bsd:
--- a/ipc/chromium/src/chrome/common/ipc_message_utils.h
+++ b/ipc/chromium/src/chrome/common/ipc_message_utils.h
@@ -15,17 +15,16 @@
#include "base/string_util.h"
#include "base/string16.h"
#include "base/time.h"
#if defined(OS_POSIX)
#include "chrome/common/file_descriptor_set_posix.h"
#endif
#include "chrome/common/ipc_message.h"
-#include "chrome/common/transport_dib.h"
namespace IPC {
//-----------------------------------------------------------------------------
// An iterator class for reading the fields contained within a Message.
class MessageIterator {
public:
@@ -476,38 +475,16 @@ struct ParamTraitsIPC<base::FileDescript
l->append(StringPrintf(L"FD(%d auto-close)", p.fd));
} else {
l->append(StringPrintf(L"FD(%d)", p.fd));
}
}
};
#endif // defined(OS_POSIX)
-#if defined(OS_WIN)
-template<>
-struct ParamTraitsIPC<TransportDIB::Id> {
- typedef TransportDIB::Id param_type;
- static void Write(Message* m, const param_type& p) {
- WriteParam(m, p.handle);
- WriteParam(m, p.sequence_num);
- }
- static bool Read(const Message* m, PickleIterator* iter, param_type* r) {
- return (ReadParam(m, iter, &r->handle) &&
- ReadParam(m, iter, &r->sequence_num));
- }
- static void Log(const param_type& p, std::wstring* l) {
- l->append(L"TransportDIB(");
- LogParam(p.handle, l);
- l->append(L", ");
- LogParam(p.sequence_num, l);
- l->append(L")");
- }
-};
-#endif
-
// Mozilla-specific types.
template <class P>
struct ParamTraitsMozilla : ParamTraitsIPC<P> {};
template <>
struct ParamTraitsMozilla<nsresult> {
typedef nsresult param_type;
deleted file mode 100644
--- a/ipc/chromium/src/chrome/common/transport_dib.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_COMMON_TRANSPORT_DIB_H_
-#define CHROME_COMMON_TRANSPORT_DIB_H_
-
-#include "base/basictypes.h"
-
-#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_BSD)
-#include "base/shared_memory.h"
-#endif
-
-#if defined(OS_WIN)
-#include <windows.h>
-#elif defined(OS_LINUX) || defined(OS_SOLARIS)
-#include "chrome/common/x11_util.h"
-#endif
-
-// -----------------------------------------------------------------------------
-// A TransportDIB is a block of memory that is used to transport pixels
-// between processes: from the renderer process to the browser, and
-// between renderer and plugin processes.
-// -----------------------------------------------------------------------------
-class 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.
-#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_t seq_num)
- : handle(h),
- sequence_num(seq_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_t sequence_num;
- };
- typedef HandleAndSequenceNum Id;
-#elif defined(OS_MACOSX) || defined(OS_BSD)
- typedef base::SharedMemoryHandle Handle;
- // On Mac, the inode number of the backing file is used as an id.
- typedef base::SharedMemoryId Id;
-#elif defined(OS_LINUX) || defined(OS_SOLARIS)
- typedef int Handle; // These two ints are SysV IPC shared memory keys
- typedef int Id;
-#endif
-
- // Create a new TransportDIB
- // size: the minimum size, in bytes
- // epoch: Windows only: a global counter. See comment above.
- // returns: NULL on failure
- static TransportDIB* Create(size_t size, uint32_t sequence_num);
-
- // Map the referenced transport DIB. Returns NULL on failure.
- static TransportDIB* Map(Handle transport_dib);
-
- // Return a pointer to the shared memory
- void* memory() const;
-
- // Return the maximum size of the shared memory. This is not the amount of
- // data which is valid, you have to know that via other means, this is simply
- // 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;
-
-#if defined(OS_LINUX) || defined(OS_SOLARIS)
- // Map the shared memory into the X server and return an id for the shared
- // segment.
- XID MapToX(Display* connection);
-#endif
-
- private:
- TransportDIB();
-#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_BSD)
- explicit TransportDIB(base::SharedMemoryHandle dib);
- base::SharedMemory shared_memory_;
-#elif defined(OS_LINUX) || defined(OS_SOLARIS)
- int key_; // SysV shared memory id
- void* address_; // mapped address
- XID x_shm_; // X id for the shared segment
- Display* display_; // connection to the X server
-#endif
-#ifdef OS_WIN
- uint32_t sequence_num_;
-#endif
- size_t size_; // length, in bytes
-};
-
-class MessageLoop;
-
-#endif // CHROME_COMMON_TRANSPORT_DIB_H_
deleted file mode 100644
--- a/ipc/chromium/src/chrome/common/transport_dib_mac.cc
+++ /dev/null
@@ -1,67 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/common/transport_dib.h"
-
-#include <unistd.h>
-#include <sys/stat.h>
-
-#include "base/eintr_wrapper.h"
-#include "base/shared_memory.h"
-
-TransportDIB::TransportDIB()
- : size_(0) {
-}
-
-TransportDIB::TransportDIB(TransportDIB::Handle dib)
- : shared_memory_(dib, false /* read write */),
- size_(0) {
-}
-
-TransportDIB::~TransportDIB() {
-}
-
-// static
-TransportDIB* TransportDIB::Create(size_t size, uint32_t sequence_num) {
- TransportDIB* dib = new TransportDIB;
- if (!dib->shared_memory_.Create("", false /* read write */,
- false /* do not open existing */, size)) {
- delete dib;
- return NULL;
- }
-
- dib->size_ = size;
- return dib;
-}
-
-// static
-TransportDIB* TransportDIB::Map(TransportDIB::Handle handle) {
- TransportDIB* dib = new TransportDIB(handle);
- struct stat st;
- fstat(handle.fd, &st);
-
- if (!dib->shared_memory_.Map(st.st_size)) {
- delete dib;
- HANDLE_EINTR(close(handle.fd));
- return nullptr;
- }
-
- dib->size_ = st.st_size;
-
- return dib;
-}
-
-void* TransportDIB::memory() const {
- return shared_memory_.memory();
-}
-
-TransportDIB::Id TransportDIB::id() const {
- return shared_memory_.id();
-}
-
-TransportDIB::Handle TransportDIB::handle() const {
- return shared_memory_.handle();
-}
deleted file mode 100644
--- a/ipc/chromium/src/chrome/common/transport_dib_win.cc
+++ /dev/null
@@ -1,74 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <limits>
-#include <windows.h>
-
-#include "base/logging.h"
-#include "base/sys_info.h"
-#include "chrome/common/transport_dib.h"
-
-TransportDIB::TransportDIB() {
-}
-
-TransportDIB::~TransportDIB() {
-}
-
-TransportDIB::TransportDIB(HANDLE handle)
- : shared_memory_(handle, false /* read write */) {
-}
-
-// static
-TransportDIB* TransportDIB::Create(size_t size, uint32_t sequence_num) {
- size_t allocation_granularity = base::SysInfo::VMAllocationGranularity();
- size = size / allocation_granularity + 1;
- size = size * allocation_granularity;
-
- TransportDIB* dib = new TransportDIB;
-
- if (!dib->shared_memory_.Create("", false /* read write */,
- true /* open existing */, size)) {
- delete dib;
- return NULL;
- }
-
- dib->size_ = size;
- dib->sequence_num_ = sequence_num;
-
- return dib;
-}
-
-// static
-TransportDIB* TransportDIB::Map(TransportDIB::Handle handle) {
- TransportDIB* dib = new TransportDIB(handle);
- if (!dib->shared_memory_.Map(0 /* map whole shared memory segment */)) {
- CHROMIUM_LOG(ERROR) << "Failed to map transport DIB"
- << " handle:" << handle
- << " error:" << GetLastError();
- delete dib;
- return NULL;
- }
-
- // There doesn't seem to be any way to find the size of the shared memory
- // region! GetFileSize indicates that the handle is invalid. Thus, we
- // conservatively set the size to the maximum and hope that the renderer
- // isn't about to ask us to read off the end of the array.
- dib->size_ = std::numeric_limits<size_t>::max();
-
- return dib;
-}
-
-void* TransportDIB::memory() const {
- return shared_memory_.memory();
-}
-
-TransportDIB::Handle TransportDIB::handle() const {
- return shared_memory_.handle();
-}
-
-TransportDIB::Id TransportDIB::id() const {
- return Id(shared_memory_.handle(), sequence_num_);
-}