mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1063318: Switch Chromium IPC code to Mozilla's ref/auto ptr types. Also fix thread safety bug. r=nfroyd
This commit is contained in:
parent
8c37e87d30
commit
1b3d3f7c47
@ -10,7 +10,6 @@
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "base/basictypes.h"
|
||||
#include "base/file_path.h"
|
||||
#include "base/scoped_ptr.h"
|
||||
#include "base/thread.h"
|
||||
#include "base/waitable_event.h"
|
||||
#include "chrome/common/child_process_host.h"
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "base/basictypes.h"
|
||||
|
||||
#include "base/file_path.h"
|
||||
#include "base/scoped_ptr.h"
|
||||
#include "base/thread.h"
|
||||
#include "base/waitable_event.h"
|
||||
#include "chrome/common/child_process_host.h"
|
||||
|
@ -50,7 +50,6 @@ UNIFIED_SOURCES += [
|
||||
'src/base/non_thread_safe.cc',
|
||||
'src/base/pickle.cc',
|
||||
'src/base/rand_util.cc',
|
||||
'src/base/ref_counted.cc',
|
||||
'src/base/revocable_store.cc',
|
||||
'src/base/scoped_temp_dir.cc',
|
||||
'src/base/string_piece.cc',
|
||||
|
@ -1,63 +0,0 @@
|
||||
// Copyright (c) 2006-2008 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.
|
||||
|
||||
// This is a low level implementation of atomic semantics for reference
|
||||
// counting. Please use base/ref_counted.h directly instead.
|
||||
|
||||
#ifndef BASE_ATOMIC_REF_COUNT_H_
|
||||
#define BASE_ATOMIC_REF_COUNT_H_
|
||||
|
||||
#include "base/atomicops.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
typedef subtle::Atomic32 AtomicRefCount;
|
||||
|
||||
// Increment a reference count by "increment", which must exceed 0.
|
||||
inline void AtomicRefCountIncN(volatile AtomicRefCount *ptr,
|
||||
AtomicRefCount increment) {
|
||||
subtle::NoBarrier_AtomicIncrement(ptr, increment);
|
||||
}
|
||||
|
||||
// Decrement a reference count by "decrement", which must exceed 0,
|
||||
// and return whether the result is non-zero.
|
||||
// Insert barriers to ensure that state written before the reference count
|
||||
// became zero will be visible to a thread that has just made the count zero.
|
||||
inline bool AtomicRefCountDecN(volatile AtomicRefCount *ptr,
|
||||
AtomicRefCount decrement) {
|
||||
return subtle::Barrier_AtomicIncrement(ptr, -decrement) != 0;
|
||||
}
|
||||
|
||||
// Increment a reference count by 1.
|
||||
inline void AtomicRefCountInc(volatile AtomicRefCount *ptr) {
|
||||
base::AtomicRefCountIncN(ptr, 1);
|
||||
}
|
||||
|
||||
// Decrement a reference count by 1 and return whether the result is non-zero.
|
||||
// Insert barriers to ensure that state written before the reference count
|
||||
// became zero will be visible to a thread that has just made the count zero.
|
||||
inline bool AtomicRefCountDec(volatile AtomicRefCount *ptr) {
|
||||
return base::AtomicRefCountDecN(ptr, 1);
|
||||
}
|
||||
|
||||
// Return whether the reference count is one. If the reference count is used
|
||||
// in the conventional way, a refrerence count of 1 implies that the current
|
||||
// thread owns the reference and no other thread shares it. This call performs
|
||||
// the test for a reference count of one, and performs the memory barrier
|
||||
// needed for the owning thread to act on the object, knowing that it has
|
||||
// exclusive access to the object.
|
||||
inline bool AtomicRefCountIsOne(volatile AtomicRefCount *ptr) {
|
||||
return subtle::Acquire_Load(ptr) == 1;
|
||||
}
|
||||
|
||||
// Return whether the reference count is zero. With conventional object
|
||||
// referencing counting, the object will be destroyed, so the reference count
|
||||
// should never be zero. Hence this is generally used for a debug check.
|
||||
inline bool AtomicRefCountIsZero(volatile AtomicRefCount *ptr) {
|
||||
return subtle::Acquire_Load(ptr) == 0;
|
||||
}
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // BASE_ATOMIC_REF_COUNT_H_
|
@ -1,30 +0,0 @@
|
||||
// Copyright (c) 2006-2008 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 BASE_ATOMIC_SEQUENCE_NUM_H_
|
||||
#define BASE_ATOMIC_SEQUENCE_NUM_H_
|
||||
|
||||
#include "base/atomicops.h"
|
||||
#include "base/basictypes.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
class AtomicSequenceNumber {
|
||||
public:
|
||||
AtomicSequenceNumber() : seq_(0) { }
|
||||
explicit AtomicSequenceNumber(base::LinkerInitialized x) { /* seq_ is 0 */ }
|
||||
|
||||
int GetNext() {
|
||||
return static_cast<int>(
|
||||
base::subtle::NoBarrier_AtomicIncrement(&seq_, 1) - 1);
|
||||
}
|
||||
|
||||
private:
|
||||
base::subtle::Atomic32 seq_;
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomicSequenceNumber);
|
||||
};
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // BASE_ATOMIC_SEQUENCE_NUM_H_
|
@ -27,7 +27,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "base/scoped_ptr.h"
|
||||
#include "base/file_path.h"
|
||||
|
||||
namespace file_util {
|
||||
|
@ -319,7 +319,7 @@ void MessageLoop::PostTask_Helper(
|
||||
// directly, as it could starve handling of foreign threads. Put every task
|
||||
// into this queue.
|
||||
|
||||
scoped_refptr<base::MessagePump> pump;
|
||||
nsRefPtr<base::MessagePump> pump;
|
||||
{
|
||||
AutoLock locked(incoming_queue_lock_);
|
||||
incoming_queue_.push(pending_task);
|
||||
|
@ -9,13 +9,11 @@
|
||||
#include <queue>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "base/lock.h"
|
||||
#include "base/message_pump.h"
|
||||
#include "base/observer_list.h"
|
||||
#include "base/ref_counted.h"
|
||||
#include "base/scoped_ptr.h"
|
||||
#include "base/task.h"
|
||||
#include "base/timer.h"
|
||||
|
||||
@ -27,6 +25,8 @@
|
||||
#include "base/message_pump_libevent.h"
|
||||
#endif
|
||||
|
||||
#include "nsAutoPtr.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
|
||||
@ -415,7 +415,7 @@ public:
|
||||
// once we're out of nested message loops.
|
||||
TaskQueue deferred_non_nestable_work_queue_;
|
||||
|
||||
scoped_refptr<base::MessagePump> pump_;
|
||||
nsRefPtr<base::MessagePump> pump_;
|
||||
|
||||
base::ObserverList<DestructionObserver> destruction_observers_;
|
||||
|
||||
|
@ -5,14 +5,16 @@
|
||||
#ifndef BASE_MESSAGE_PUMP_H_
|
||||
#define BASE_MESSAGE_PUMP_H_
|
||||
|
||||
#include "base/ref_counted.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
class TimeTicks;
|
||||
|
||||
class MessagePump : public RefCountedThreadSafe<MessagePump> {
|
||||
class MessagePump {
|
||||
public:
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MessagePump)
|
||||
|
||||
// Please see the comments above the Run method for an illustration of how
|
||||
// these delegate methods are used.
|
||||
class Delegate {
|
||||
@ -39,8 +41,6 @@ class MessagePump : public RefCountedThreadSafe<MessagePump> {
|
||||
virtual bool DoIdleWork() = 0;
|
||||
};
|
||||
|
||||
virtual ~MessagePump() {}
|
||||
|
||||
// The Run method is called to enter the message pump's run loop.
|
||||
//
|
||||
// Within the method, the message pump is responsible for processing native
|
||||
@ -123,6 +123,9 @@ class MessagePump : public RefCountedThreadSafe<MessagePump> {
|
||||
// cancelling any pending DoDelayedWork callback. This method may only be
|
||||
// used on the thread that called Run.
|
||||
virtual void ScheduleDelayedWork(const TimeTicks& delayed_work_time) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~MessagePump() {};
|
||||
};
|
||||
|
||||
} // namespace base
|
||||
|
@ -7,8 +7,8 @@
|
||||
|
||||
#include "base/message_pump.h"
|
||||
#include "base/observer_list.h"
|
||||
#include "base/scoped_ptr.h"
|
||||
#include "base/time.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
typedef union _GdkEvent GdkEvent;
|
||||
typedef struct _GMainContext GMainContext;
|
||||
@ -128,8 +128,8 @@ class MessagePumpForUI : public MessagePump {
|
||||
// Dispatch() will be called.
|
||||
int wakeup_pipe_read_;
|
||||
int wakeup_pipe_write_;
|
||||
// Use a scoped_ptr to avoid needing the definition of GPollFD in the header.
|
||||
scoped_ptr<GPollFD> wakeup_gpollfd_;
|
||||
// Use an autoptr to avoid needing the definition of GPollFD in the header.
|
||||
mozilla::UniquePtr<GPollFD> wakeup_gpollfd_;
|
||||
|
||||
// List of observers.
|
||||
ObserverList<Observer> observers_;
|
||||
|
@ -13,10 +13,10 @@
|
||||
#include "eintr_wrapper.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/scoped_nsautorelease_pool.h"
|
||||
#include "base/scoped_ptr.h"
|
||||
#include "base/time.h"
|
||||
#include "nsDependentSubstring.h"
|
||||
#include "third_party/libevent/event.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
// Lifecycle of struct event
|
||||
// Libevent uses two main data structures:
|
||||
@ -170,11 +170,11 @@ bool MessagePumpLibevent::WatchFileDescriptor(int fd,
|
||||
// If we're modifying an existing event and there's an error then we need to
|
||||
// tell libevent to clean it up via event_delete() before returning.
|
||||
bool should_delete_event = true;
|
||||
scoped_ptr<event> evt(controller->ReleaseEvent());
|
||||
mozilla::UniquePtr<event> evt(controller->ReleaseEvent());
|
||||
if (evt.get() == NULL) {
|
||||
should_delete_event = false;
|
||||
// Ownership is transferred to the controller.
|
||||
evt.reset(new event);
|
||||
evt = mozilla::MakeUnique<event>();
|
||||
}
|
||||
|
||||
// Set current interest mask and message pump for this event.
|
||||
@ -273,7 +273,7 @@ MessagePumpLibevent::CatchSignal(int sig,
|
||||
// needed at present
|
||||
DCHECK(NULL == sigevent->event_);
|
||||
|
||||
scoped_ptr<event> evt(new event);
|
||||
mozilla::UniquePtr<event> evt = mozilla::MakeUnique<event>();
|
||||
signal_set(evt.get(), sig, OnLibeventSignalNotification, delegate);
|
||||
|
||||
if (event_base_set(event_base_, evt.get()))
|
||||
|
@ -62,7 +62,6 @@ class MessagePumpLibevent : public MessagePump {
|
||||
};
|
||||
|
||||
MessagePumpLibevent();
|
||||
virtual ~MessagePumpLibevent();
|
||||
|
||||
enum Mode {
|
||||
WATCH_READ = 1 << 0,
|
||||
@ -139,6 +138,10 @@ class MessagePumpLibevent : public MessagePump {
|
||||
virtual void ScheduleWork();
|
||||
virtual void ScheduleDelayedWork(const TimeTicks& delayed_work_time);
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~MessagePumpLibevent();
|
||||
|
||||
private:
|
||||
|
||||
// Risky part of constructor. Returns true on success.
|
||||
|
@ -32,6 +32,8 @@
|
||||
|
||||
#include "base/message_pump.h"
|
||||
|
||||
#include "base/basictypes.h"
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <IOKit/IOKitLib.h>
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "base/logging.h"
|
||||
#include "base/string_tokenizer.h"
|
||||
#include "base/string_util.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
#if defined(_POSIX_SPAWN) && _POSIX_SPAWN > 0
|
||||
#define HAVE_POSIX_SPAWN 1
|
||||
@ -225,7 +226,7 @@ bool LaunchApp(const std::vector<std::string>& argv,
|
||||
ChildPrivileges privs,
|
||||
bool wait, ProcessHandle* process_handle,
|
||||
ProcessArchitecture arch) {
|
||||
scoped_array<char*> argv_cstr(new char*[argv.size() + 1]);
|
||||
mozilla::UniquePtr<char*[]> argv_cstr(new char*[argv.size() + 1]);
|
||||
// Illegal to allocate memory after fork and before execvp
|
||||
InjectiveMultimap fd_shuffle1, fd_shuffle2;
|
||||
fd_shuffle1.reserve(fds_to_remap.size());
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "base/string_tokenizer.h"
|
||||
#include "base/string_util.h"
|
||||
#include "nsLiteralString.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
#ifdef MOZ_B2G_LOADER
|
||||
#include "ProcessUtils.h"
|
||||
@ -207,13 +208,13 @@ LaunchAppProcLoader(const std::vector<std::string>& argv,
|
||||
ChildPrivileges privs,
|
||||
ProcessHandle* process_handle) {
|
||||
size_t i;
|
||||
scoped_array<char*> argv_cstr(new char*[argv.size() + 1]);
|
||||
mozilla::UniquePtr<char*[]> argv_cstr(new char*[argv.size() + 1]);
|
||||
for (i = 0; i < argv.size(); i++) {
|
||||
argv_cstr[i] = const_cast<char*>(argv[i].c_str());
|
||||
}
|
||||
argv_cstr[argv.size()] = nullptr;
|
||||
|
||||
scoped_array<char*> env_cstr(new char*[env_vars_to_set.size() + 1]);
|
||||
mozilla::UniquePtr<char*[]> env_cstr(new char*[env_vars_to_set.size() + 1]);
|
||||
i = 0;
|
||||
for (environment_map::const_iterator it = env_vars_to_set.begin();
|
||||
it != env_vars_to_set.end(); ++it) {
|
||||
@ -261,7 +262,7 @@ bool LaunchApp(const std::vector<std::string>& argv,
|
||||
}
|
||||
#endif // MOZ_B2G_LOADER
|
||||
|
||||
scoped_array<char*> argv_cstr(new char*[argv.size() + 1]);
|
||||
mozilla::UniquePtr<char*[]> argv_cstr(new char*[argv.size() + 1]);
|
||||
// Illegal to allocate memory after fork and before execvp
|
||||
InjectiveMultimap fd_shuffle1, fd_shuffle2;
|
||||
fd_shuffle1.reserve(fds_to_remap.size());
|
||||
|
@ -22,12 +22,13 @@
|
||||
#include "base/logging.h"
|
||||
#include "base/platform_thread.h"
|
||||
#include "base/process_util.h"
|
||||
#include "base/scoped_ptr.h"
|
||||
#include "base/sys_info.h"
|
||||
#include "base/time.h"
|
||||
#include "base/waitable_event.h"
|
||||
#include "base/dir_reader_posix.h"
|
||||
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
const int kMicrosecondsPerSecond = 1000000;
|
||||
|
||||
namespace base {
|
||||
@ -101,7 +102,7 @@ class ScopedDIRClose {
|
||||
}
|
||||
}
|
||||
};
|
||||
typedef scoped_ptr_malloc<DIR, ScopedDIRClose> ScopedDIR;
|
||||
typedef mozilla::UniquePtr<DIR, ScopedDIRClose> ScopedDIR;
|
||||
|
||||
|
||||
void CloseSuperfluousFds(const base::InjectiveMultimap& saved_mapping) {
|
||||
|
@ -14,8 +14,6 @@
|
||||
|
||||
#include "base/histogram.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/scoped_handle_win.h"
|
||||
#include "base/scoped_ptr.h"
|
||||
#include "base/win_util.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include "base/process.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/process_util.h"
|
||||
#include "base/scoped_ptr.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
|
@ -1,88 +0,0 @@
|
||||
// Copyright (c) 2006-2008 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 "base/ref_counted.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/thread_collision_warner.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
namespace subtle {
|
||||
|
||||
RefCountedBase::RefCountedBase() : ref_count_(0) {
|
||||
#ifndef NDEBUG
|
||||
in_dtor_ = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
RefCountedBase::~RefCountedBase() {
|
||||
#ifndef NDEBUG
|
||||
DCHECK(in_dtor_) << "RefCounted object deleted without calling Release()";
|
||||
#endif
|
||||
}
|
||||
|
||||
void RefCountedBase::AddRef() {
|
||||
// TODO(maruel): Add back once it doesn't assert 500 times/sec.
|
||||
// Current thread books the critical section "AddRelease" without release it.
|
||||
// DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_);
|
||||
#ifndef NDEBUG
|
||||
DCHECK(!in_dtor_);
|
||||
#endif
|
||||
++ref_count_;
|
||||
}
|
||||
|
||||
bool RefCountedBase::Release() {
|
||||
// TODO(maruel): Add back once it doesn't assert 500 times/sec.
|
||||
// Current thread books the critical section "AddRelease" without release it.
|
||||
// DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_);
|
||||
#ifndef NDEBUG
|
||||
DCHECK(!in_dtor_);
|
||||
#endif
|
||||
if (--ref_count_ == 0) {
|
||||
#ifndef NDEBUG
|
||||
in_dtor_ = true;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
RefCountedThreadSafeBase::RefCountedThreadSafeBase() : ref_count_(0) {
|
||||
#ifndef NDEBUG
|
||||
in_dtor_ = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
RefCountedThreadSafeBase::~RefCountedThreadSafeBase() {
|
||||
#ifndef NDEBUG
|
||||
DCHECK(in_dtor_) << "RefCountedThreadSafe object deleted without "
|
||||
"calling Release()";
|
||||
#endif
|
||||
}
|
||||
|
||||
void RefCountedThreadSafeBase::AddRef() {
|
||||
#ifndef NDEBUG
|
||||
DCHECK(!in_dtor_);
|
||||
#endif
|
||||
AtomicRefCountInc(&ref_count_);
|
||||
}
|
||||
|
||||
bool RefCountedThreadSafeBase::Release() {
|
||||
#ifndef NDEBUG
|
||||
DCHECK(!in_dtor_);
|
||||
DCHECK(!AtomicRefCountIsZero(&ref_count_));
|
||||
#endif
|
||||
if (!AtomicRefCountDec(&ref_count_)) {
|
||||
#ifndef NDEBUG
|
||||
in_dtor_ = true;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace subtle
|
||||
|
||||
} // namespace base
|
@ -1,231 +0,0 @@
|
||||
// Copyright (c) 2006-2008 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 BASE_REF_COUNTED_H_
|
||||
#define BASE_REF_COUNTED_H_
|
||||
|
||||
#include "base/atomic_ref_count.h"
|
||||
#include "base/thread_collision_warner.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
namespace subtle {
|
||||
|
||||
class RefCountedBase {
|
||||
protected:
|
||||
RefCountedBase();
|
||||
~RefCountedBase();
|
||||
|
||||
void AddRef();
|
||||
|
||||
// Returns true if the object should self-delete.
|
||||
bool Release();
|
||||
|
||||
private:
|
||||
int ref_count_;
|
||||
#ifndef NDEBUG
|
||||
bool in_dtor_;
|
||||
#endif
|
||||
|
||||
DFAKE_MUTEX(add_release_)
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(RefCountedBase);
|
||||
};
|
||||
|
||||
class RefCountedThreadSafeBase {
|
||||
protected:
|
||||
RefCountedThreadSafeBase();
|
||||
~RefCountedThreadSafeBase();
|
||||
|
||||
void AddRef();
|
||||
|
||||
// Returns true if the object should self-delete.
|
||||
bool Release();
|
||||
|
||||
private:
|
||||
AtomicRefCount ref_count_;
|
||||
#ifndef NDEBUG
|
||||
bool in_dtor_;
|
||||
#endif
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(RefCountedThreadSafeBase);
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace subtle
|
||||
|
||||
//
|
||||
// A base class for reference counted classes. Otherwise, known as a cheap
|
||||
// knock-off of WebKit's RefCounted<T> class. To use this guy just extend your
|
||||
// class from it like so:
|
||||
//
|
||||
// class MyFoo : public base::RefCounted<MyFoo> {
|
||||
// ...
|
||||
// };
|
||||
//
|
||||
template <class T>
|
||||
class RefCounted : public subtle::RefCountedBase {
|
||||
public:
|
||||
RefCounted() { }
|
||||
~RefCounted() { }
|
||||
|
||||
void AddRef() {
|
||||
subtle::RefCountedBase::AddRef();
|
||||
}
|
||||
|
||||
void Release() {
|
||||
if (subtle::RefCountedBase::Release()) {
|
||||
delete static_cast<T*>(this);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(RefCounted<T>);
|
||||
};
|
||||
|
||||
//
|
||||
// A thread-safe variant of RefCounted<T>
|
||||
//
|
||||
// class MyFoo : public base::RefCountedThreadSafe<MyFoo> {
|
||||
// ...
|
||||
// };
|
||||
//
|
||||
template <class T>
|
||||
class RefCountedThreadSafe : public subtle::RefCountedThreadSafeBase {
|
||||
public:
|
||||
RefCountedThreadSafe() { }
|
||||
~RefCountedThreadSafe() { }
|
||||
|
||||
void AddRef() {
|
||||
subtle::RefCountedThreadSafeBase::AddRef();
|
||||
}
|
||||
|
||||
void Release() {
|
||||
if (subtle::RefCountedThreadSafeBase::Release()) {
|
||||
delete static_cast<T*>(this);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(RefCountedThreadSafe<T>);
|
||||
};
|
||||
|
||||
//
|
||||
// A wrapper for some piece of data so we can place other things in
|
||||
// scoped_refptrs<>.
|
||||
//
|
||||
template<typename T>
|
||||
class RefCountedData : public base::RefCounted< base::RefCountedData<T> > {
|
||||
public:
|
||||
RefCountedData() : data() {}
|
||||
explicit RefCountedData(const T& in_value) : data(in_value) {}
|
||||
|
||||
T data;
|
||||
};
|
||||
|
||||
} // namespace base
|
||||
|
||||
//
|
||||
// A smart pointer class for reference counted objects. Use this class instead
|
||||
// of calling AddRef and Release manually on a reference counted object to
|
||||
// avoid common memory leaks caused by forgetting to Release an object
|
||||
// reference. Sample usage:
|
||||
//
|
||||
// class MyFoo : public RefCounted<MyFoo> {
|
||||
// ...
|
||||
// };
|
||||
//
|
||||
// void some_function() {
|
||||
// scoped_refptr<MyFoo> foo = new MyFoo();
|
||||
// foo->Method(param);
|
||||
// // |foo| is released when this function returns
|
||||
// }
|
||||
//
|
||||
// void some_other_function() {
|
||||
// scoped_refptr<MyFoo> foo = new MyFoo();
|
||||
// ...
|
||||
// foo = NULL; // explicitly releases |foo|
|
||||
// ...
|
||||
// if (foo)
|
||||
// foo->Method(param);
|
||||
// }
|
||||
//
|
||||
// The above examples show how scoped_refptr<T> acts like a pointer to T.
|
||||
// Given two scoped_refptr<T> classes, it is also possible to exchange
|
||||
// references between the two objects, like so:
|
||||
//
|
||||
// {
|
||||
// scoped_refptr<MyFoo> a = new MyFoo();
|
||||
// scoped_refptr<MyFoo> b;
|
||||
//
|
||||
// b.swap(a);
|
||||
// // now, |b| references the MyFoo object, and |a| references NULL.
|
||||
// }
|
||||
//
|
||||
// To make both |a| and |b| in the above example reference the same MyFoo
|
||||
// object, simply use the assignment operator:
|
||||
//
|
||||
// {
|
||||
// scoped_refptr<MyFoo> a = new MyFoo();
|
||||
// scoped_refptr<MyFoo> b;
|
||||
//
|
||||
// b = a;
|
||||
// // now, |a| and |b| each own a reference to the same MyFoo object.
|
||||
// }
|
||||
//
|
||||
template <class T>
|
||||
class scoped_refptr {
|
||||
public:
|
||||
scoped_refptr() : ptr_(NULL) {
|
||||
}
|
||||
|
||||
MOZ_IMPLICIT scoped_refptr(T* p) : ptr_(p) {
|
||||
if (ptr_)
|
||||
ptr_->AddRef();
|
||||
}
|
||||
|
||||
scoped_refptr(const scoped_refptr<T>& r) : ptr_(r.ptr_) {
|
||||
if (ptr_)
|
||||
ptr_->AddRef();
|
||||
}
|
||||
|
||||
~scoped_refptr() {
|
||||
if (ptr_)
|
||||
ptr_->Release();
|
||||
}
|
||||
|
||||
T* get() const { return ptr_; }
|
||||
operator T*() const { return ptr_; }
|
||||
T* operator->() const { return ptr_; }
|
||||
|
||||
scoped_refptr<T>& operator=(T* p) {
|
||||
// AddRef first so that self assignment should work
|
||||
if (p)
|
||||
p->AddRef();
|
||||
if (ptr_ )
|
||||
ptr_ ->Release();
|
||||
ptr_ = p;
|
||||
return *this;
|
||||
}
|
||||
|
||||
scoped_refptr<T>& operator=(const scoped_refptr<T>& r) {
|
||||
return *this = r.ptr_;
|
||||
}
|
||||
|
||||
void swap(T** pp) {
|
||||
T* p = ptr_;
|
||||
ptr_ = *pp;
|
||||
*pp = p;
|
||||
}
|
||||
|
||||
void swap(scoped_refptr<T>& r) {
|
||||
swap(&r.ptr_);
|
||||
}
|
||||
|
||||
protected:
|
||||
T* ptr_;
|
||||
};
|
||||
|
||||
#endif // BASE_REF_COUNTED_H_
|
@ -5,7 +5,9 @@
|
||||
#ifndef BASE_REVOCABLE_STORE_H_
|
||||
#define BASE_REVOCABLE_STORE_H_
|
||||
|
||||
#include "base/ref_counted.h"
|
||||
#include "base/basictypes.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "nsAutoPtr.h"
|
||||
|
||||
// |RevocableStore| is a container of items that can be removed from the store.
|
||||
class RevocableStore {
|
||||
@ -15,13 +17,16 @@ class RevocableStore {
|
||||
// store wishes to revoke its items, it sets |store_| to null. Items are
|
||||
// permitted to release their reference to the |StoreRef| when they no longer
|
||||
// require the store.
|
||||
class StoreRef : public base::RefCounted<StoreRef> {
|
||||
class StoreRef MOZ_FINAL {
|
||||
public:
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(StoreRef)
|
||||
explicit StoreRef(RevocableStore* store) : store_(store) { }
|
||||
|
||||
void set_store(RevocableStore* store) { store_ = store; }
|
||||
RevocableStore* store() const { return store_; }
|
||||
|
||||
protected:
|
||||
~StoreRef() {}
|
||||
private:
|
||||
RevocableStore* store_;
|
||||
|
||||
@ -41,7 +46,7 @@ class RevocableStore {
|
||||
private:
|
||||
// We hold a reference to the store through this ref pointer. We release
|
||||
// this reference on destruction.
|
||||
scoped_refptr<StoreRef> store_reference_;
|
||||
nsRefPtr<StoreRef> store_reference_;
|
||||
|
||||
DISALLOW_EVIL_CONSTRUCTORS(Revocable);
|
||||
};
|
||||
@ -63,7 +68,7 @@ class RevocableStore {
|
||||
void Add(Revocable* item);
|
||||
|
||||
// This is the reference the unrevoked items in the store hold.
|
||||
scoped_refptr<StoreRef> owning_reference_;
|
||||
nsRefPtr<StoreRef> owning_reference_;
|
||||
|
||||
// The number of unrevoked items in the store.
|
||||
int count_;
|
||||
|
@ -1,380 +0,0 @@
|
||||
// Copyright (c) 2006-2008 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.
|
||||
|
||||
// Scopers help you manage ownership of a pointer, helping you easily manage the
|
||||
// a pointer within a scope, and automatically destroying the pointer at the
|
||||
// end of a scope. There are two main classes you will use, which coorespond
|
||||
// to the operators new/delete and new[]/delete[].
|
||||
//
|
||||
// Example usage (scoped_ptr):
|
||||
// {
|
||||
// scoped_ptr<Foo> foo(new Foo("wee"));
|
||||
// } // foo goes out of scope, releasing the pointer with it.
|
||||
//
|
||||
// {
|
||||
// scoped_ptr<Foo> foo; // No pointer managed.
|
||||
// foo.reset(new Foo("wee")); // Now a pointer is managed.
|
||||
// foo.reset(new Foo("wee2")); // Foo("wee") was destroyed.
|
||||
// foo.reset(new Foo("wee3")); // Foo("wee2") was destroyed.
|
||||
// foo->Method(); // Foo::Method() called.
|
||||
// foo.get()->Method(); // Foo::Method() called.
|
||||
// SomeFunc(foo.Release()); // SomeFunc takes owernship, foo no longer
|
||||
// // manages a pointer.
|
||||
// foo.reset(new Foo("wee4")); // foo manages a pointer again.
|
||||
// foo.reset(); // Foo("wee4") destroyed, foo no longer
|
||||
// // manages a pointer.
|
||||
// } // foo wasn't managing a pointer, so nothing was destroyed.
|
||||
//
|
||||
// Example usage (scoped_array):
|
||||
// {
|
||||
// scoped_array<Foo> foo(new Foo[100]);
|
||||
// foo.get()->Method(); // Foo::Method on the 0th element.
|
||||
// foo[10].Method(); // Foo::Method on the 10th element.
|
||||
// }
|
||||
|
||||
#ifndef BASE_SCOPED_PTR_H_
|
||||
#define BASE_SCOPED_PTR_H_
|
||||
|
||||
// This is an implementation designed to match the anticipated future TR2
|
||||
// implementation of the scoped_ptr class, and its closely-related brethren,
|
||||
// scoped_array, scoped_ptr_malloc.
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <cstddef>
|
||||
|
||||
// A scoped_ptr<T> is like a T*, except that the destructor of scoped_ptr<T>
|
||||
// automatically deletes the pointer it holds (if any).
|
||||
// That is, scoped_ptr<T> owns the T object that it points to.
|
||||
// Like a T*, a scoped_ptr<T> may hold either NULL or a pointer to a T object.
|
||||
// Also like T*, scoped_ptr<T> is thread-compatible, and once you
|
||||
// dereference it, you get the threadsafety guarantees of T.
|
||||
//
|
||||
// The size of a scoped_ptr is small:
|
||||
// sizeof(scoped_ptr<C>) == sizeof(C*)
|
||||
template <class C>
|
||||
class scoped_ptr {
|
||||
public:
|
||||
|
||||
// The element type
|
||||
typedef C element_type;
|
||||
|
||||
// Constructor. Defaults to intializing with NULL.
|
||||
// There is no way to create an uninitialized scoped_ptr.
|
||||
// The input parameter must be allocated with new.
|
||||
explicit scoped_ptr(C* p = NULL) : ptr_(p) { }
|
||||
|
||||
// Destructor. If there is a C object, delete it.
|
||||
// We don't need to test ptr_ == NULL because C++ does that for us.
|
||||
~scoped_ptr() {
|
||||
enum { type_must_be_complete = sizeof(C) };
|
||||
delete ptr_;
|
||||
}
|
||||
|
||||
// Reset. Deletes the current owned object, if any.
|
||||
// Then takes ownership of a new object, if given.
|
||||
// this->reset(this->get()) works.
|
||||
void reset(C* p = NULL) {
|
||||
if (p != ptr_) {
|
||||
enum { type_must_be_complete = sizeof(C) };
|
||||
delete ptr_;
|
||||
ptr_ = p;
|
||||
}
|
||||
}
|
||||
|
||||
// Accessors to get the owned object.
|
||||
// operator* and operator-> will assert() if there is no current object.
|
||||
C& operator*() const {
|
||||
assert(ptr_ != NULL);
|
||||
return *ptr_;
|
||||
}
|
||||
C* operator->() const {
|
||||
assert(ptr_ != NULL);
|
||||
return ptr_;
|
||||
}
|
||||
C* get() const { return ptr_; }
|
||||
|
||||
// Comparison operators.
|
||||
// These return whether two scoped_ptr refer to the same object, not just to
|
||||
// two different but equal objects.
|
||||
bool operator==(C* p) const { return ptr_ == p; }
|
||||
bool operator!=(C* p) const { return ptr_ != p; }
|
||||
|
||||
// Swap two scoped pointers.
|
||||
void swap(scoped_ptr& p2) {
|
||||
C* tmp = ptr_;
|
||||
ptr_ = p2.ptr_;
|
||||
p2.ptr_ = tmp;
|
||||
}
|
||||
|
||||
// Release a pointer.
|
||||
// The return value is the current pointer held by this object.
|
||||
// If this object holds a NULL pointer, the return value is NULL.
|
||||
// After this operation, this object will hold a NULL pointer,
|
||||
// and will not own the object any more.
|
||||
C* release() {
|
||||
C* retVal = ptr_;
|
||||
ptr_ = NULL;
|
||||
return retVal;
|
||||
}
|
||||
|
||||
private:
|
||||
C* ptr_;
|
||||
|
||||
// Forbid comparison of scoped_ptr types. If C2 != C, it totally doesn't
|
||||
// make sense, and if C2 == C, it still doesn't make sense because you should
|
||||
// never have the same object owned by two different scoped_ptrs.
|
||||
template <class C2> bool operator==(scoped_ptr<C2> const& p2) const;
|
||||
template <class C2> bool operator!=(scoped_ptr<C2> const& p2) const;
|
||||
|
||||
// Disallow evil constructors
|
||||
scoped_ptr(const scoped_ptr&);
|
||||
void operator=(const scoped_ptr&);
|
||||
};
|
||||
|
||||
// Free functions
|
||||
template <class C>
|
||||
void swap(scoped_ptr<C>& p1, scoped_ptr<C>& p2) {
|
||||
p1.swap(p2);
|
||||
}
|
||||
|
||||
template <class C>
|
||||
bool operator==(C* p1, const scoped_ptr<C>& p2) {
|
||||
return p1 == p2.get();
|
||||
}
|
||||
|
||||
template <class C>
|
||||
bool operator!=(C* p1, const scoped_ptr<C>& p2) {
|
||||
return p1 != p2.get();
|
||||
}
|
||||
|
||||
// scoped_array<C> is like scoped_ptr<C>, except that the caller must allocate
|
||||
// with new [] and the destructor deletes objects with delete [].
|
||||
//
|
||||
// As with scoped_ptr<C>, a scoped_array<C> either points to an object
|
||||
// or is NULL. A scoped_array<C> owns the object that it points to.
|
||||
// scoped_array<T> is thread-compatible, and once you index into it,
|
||||
// the returned objects have only the threadsafety guarantees of T.
|
||||
//
|
||||
// Size: sizeof(scoped_array<C>) == sizeof(C*)
|
||||
template <class C>
|
||||
class scoped_array {
|
||||
public:
|
||||
|
||||
// The element type
|
||||
typedef C element_type;
|
||||
|
||||
// Constructor. Defaults to intializing with NULL.
|
||||
// There is no way to create an uninitialized scoped_array.
|
||||
// The input parameter must be allocated with new [].
|
||||
explicit scoped_array(C* p = NULL) : array_(p) { }
|
||||
|
||||
// Destructor. If there is a C object, delete it.
|
||||
// We don't need to test ptr_ == NULL because C++ does that for us.
|
||||
~scoped_array() {
|
||||
enum { type_must_be_complete = sizeof(C) };
|
||||
delete[] array_;
|
||||
}
|
||||
|
||||
// Reset. Deletes the current owned object, if any.
|
||||
// Then takes ownership of a new object, if given.
|
||||
// this->reset(this->get()) works.
|
||||
void reset(C* p = NULL) {
|
||||
if (p != array_) {
|
||||
enum { type_must_be_complete = sizeof(C) };
|
||||
delete[] array_;
|
||||
array_ = p;
|
||||
}
|
||||
}
|
||||
|
||||
// Get one element of the current object.
|
||||
// Will assert() if there is no current object, or index i is negative.
|
||||
C& operator[](std::ptrdiff_t i) const {
|
||||
assert(i >= 0);
|
||||
assert(array_ != NULL);
|
||||
return array_[i];
|
||||
}
|
||||
|
||||
// Get a pointer to the zeroth element of the current object.
|
||||
// If there is no current object, return NULL.
|
||||
C* get() const {
|
||||
return array_;
|
||||
}
|
||||
|
||||
// Comparison operators.
|
||||
// These return whether two scoped_array refer to the same object, not just to
|
||||
// two different but equal objects.
|
||||
bool operator==(C* p) const { return array_ == p; }
|
||||
bool operator!=(C* p) const { return array_ != p; }
|
||||
|
||||
// Swap two scoped arrays.
|
||||
void swap(scoped_array& p2) {
|
||||
C* tmp = array_;
|
||||
array_ = p2.array_;
|
||||
p2.array_ = tmp;
|
||||
}
|
||||
|
||||
// Release an array.
|
||||
// The return value is the current pointer held by this object.
|
||||
// If this object holds a NULL pointer, the return value is NULL.
|
||||
// After this operation, this object will hold a NULL pointer,
|
||||
// and will not own the object any more.
|
||||
C* release() {
|
||||
C* retVal = array_;
|
||||
array_ = NULL;
|
||||
return retVal;
|
||||
}
|
||||
|
||||
private:
|
||||
C* array_;
|
||||
|
||||
// Forbid comparison of different scoped_array types.
|
||||
template <class C2> bool operator==(scoped_array<C2> const& p2) const;
|
||||
template <class C2> bool operator!=(scoped_array<C2> const& p2) const;
|
||||
|
||||
// Disallow evil constructors
|
||||
scoped_array(const scoped_array&);
|
||||
void operator=(const scoped_array&);
|
||||
};
|
||||
|
||||
// Free functions
|
||||
template <class C>
|
||||
void swap(scoped_array<C>& p1, scoped_array<C>& p2) {
|
||||
p1.swap(p2);
|
||||
}
|
||||
|
||||
template <class C>
|
||||
bool operator==(C* p1, const scoped_array<C>& p2) {
|
||||
return p1 == p2.get();
|
||||
}
|
||||
|
||||
template <class C>
|
||||
bool operator!=(C* p1, const scoped_array<C>& p2) {
|
||||
return p1 != p2.get();
|
||||
}
|
||||
|
||||
// This class wraps the c library function free() in a class that can be
|
||||
// passed as a template argument to scoped_ptr_malloc below.
|
||||
class ScopedPtrMallocFree {
|
||||
public:
|
||||
inline void operator()(void* x) const {
|
||||
free(x);
|
||||
}
|
||||
};
|
||||
|
||||
// scoped_ptr_malloc<> is similar to scoped_ptr<>, but it accepts a
|
||||
// second template argument, the functor used to free the object.
|
||||
|
||||
template<class C, class FreeProc = ScopedPtrMallocFree>
|
||||
class scoped_ptr_malloc {
|
||||
public:
|
||||
|
||||
// The element type
|
||||
typedef C element_type;
|
||||
|
||||
// Constructor. Defaults to intializing with NULL.
|
||||
// There is no way to create an uninitialized scoped_ptr.
|
||||
// The input parameter must be allocated with an allocator that matches the
|
||||
// Free functor. For the default Free functor, this is malloc, calloc, or
|
||||
// realloc.
|
||||
explicit scoped_ptr_malloc(C* p = NULL): ptr_(p) {}
|
||||
|
||||
// Destructor. If there is a C object, call the Free functor.
|
||||
~scoped_ptr_malloc() {
|
||||
free_(ptr_);
|
||||
}
|
||||
|
||||
// Reset. Calls the Free functor on the current owned object, if any.
|
||||
// Then takes ownership of a new object, if given.
|
||||
// this->reset(this->get()) works.
|
||||
void reset(C* p = NULL) {
|
||||
if (ptr_ != p) {
|
||||
free_(ptr_);
|
||||
ptr_ = p;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the current object.
|
||||
// operator* and operator-> will cause an assert() failure if there is
|
||||
// no current object.
|
||||
C& operator*() const {
|
||||
assert(ptr_ != NULL);
|
||||
return *ptr_;
|
||||
}
|
||||
|
||||
C* operator->() const {
|
||||
assert(ptr_ != NULL);
|
||||
return ptr_;
|
||||
}
|
||||
|
||||
C* get() const {
|
||||
return ptr_;
|
||||
}
|
||||
|
||||
// Comparison operators.
|
||||
// These return whether a scoped_ptr_malloc and a plain pointer refer
|
||||
// to the same object, not just to two different but equal objects.
|
||||
// For compatibility wwith the boost-derived implementation, these
|
||||
// take non-const arguments.
|
||||
bool operator==(C* p) const {
|
||||
return ptr_ == p;
|
||||
}
|
||||
|
||||
bool operator!=(C* p) const {
|
||||
return ptr_ != p;
|
||||
}
|
||||
|
||||
// Swap two scoped pointers.
|
||||
void swap(scoped_ptr_malloc & b) {
|
||||
C* tmp = b.ptr_;
|
||||
b.ptr_ = ptr_;
|
||||
ptr_ = tmp;
|
||||
}
|
||||
|
||||
// Release a pointer.
|
||||
// The return value is the current pointer held by this object.
|
||||
// If this object holds a NULL pointer, the return value is NULL.
|
||||
// After this operation, this object will hold a NULL pointer,
|
||||
// and will not own the object any more.
|
||||
C* release() {
|
||||
C* tmp = ptr_;
|
||||
ptr_ = NULL;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
private:
|
||||
C* ptr_;
|
||||
|
||||
// no reason to use these: each scoped_ptr_malloc should have its own object
|
||||
template <class C2, class GP>
|
||||
bool operator==(scoped_ptr_malloc<C2, GP> const& p) const;
|
||||
template <class C2, class GP>
|
||||
bool operator!=(scoped_ptr_malloc<C2, GP> const& p) const;
|
||||
|
||||
static FreeProc const free_;
|
||||
|
||||
// Disallow evil constructors
|
||||
scoped_ptr_malloc(const scoped_ptr_malloc&);
|
||||
void operator=(const scoped_ptr_malloc&);
|
||||
};
|
||||
|
||||
template<class C, class FP>
|
||||
FP const scoped_ptr_malloc<C, FP>::free_ = FP();
|
||||
|
||||
template<class C, class FP> inline
|
||||
void swap(scoped_ptr_malloc<C, FP>& a, scoped_ptr_malloc<C, FP>& b) {
|
||||
a.swap(b);
|
||||
}
|
||||
|
||||
template<class C, class FP> inline
|
||||
bool operator==(C* p, const scoped_ptr_malloc<C, FP>& b) {
|
||||
return p == b.get();
|
||||
}
|
||||
|
||||
template<class C, class FP> inline
|
||||
bool operator!=(C* p, const scoped_ptr_malloc<C, FP>& b) {
|
||||
return p != b.get();
|
||||
}
|
||||
|
||||
#endif // BASE_SCOPED_PTR_H_
|
@ -14,6 +14,7 @@
|
||||
#include "base/logging.h"
|
||||
#include "base/platform_thread.h"
|
||||
#include "base/string_util.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
@ -142,7 +143,7 @@ class ScopedFILEClose {
|
||||
}
|
||||
};
|
||||
|
||||
typedef scoped_ptr_malloc<FILE, ScopedFILEClose> ScopedFILE;
|
||||
typedef mozilla::UniquePtr<FILE, ScopedFILEClose> ScopedFILE;
|
||||
|
||||
}
|
||||
|
||||
|
@ -7,8 +7,8 @@
|
||||
#include <windows.h>
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/scoped_ptr.h"
|
||||
#include "base/string_util.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
@ -57,7 +57,7 @@ std::wstring SysInfo::GetEnvVar(const wchar_t* var) {
|
||||
if (value_length == 0) {
|
||||
return L"";
|
||||
}
|
||||
scoped_array<wchar_t> value(new wchar_t[value_length]);
|
||||
mozilla::UniquePtr<wchar_t[]> value(new wchar_t[value_length]);
|
||||
GetEnvironmentVariable(var, value.get(), value_length);
|
||||
return std::wstring(value.get());
|
||||
}
|
||||
|
@ -16,7 +16,8 @@
|
||||
#include <utility>
|
||||
#include "base/condition_variable.h"
|
||||
#include "base/lock.h"
|
||||
#include "base/ref_counted.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#endif
|
||||
|
||||
#include "base/message_loop.h"
|
||||
@ -140,9 +141,9 @@ class WaitableEvent {
|
||||
// so we have a kernel of the WaitableEvent, which is reference counted.
|
||||
// WaitableEventWatchers may then take a reference and thus match the Windows
|
||||
// behaviour.
|
||||
struct WaitableEventKernel :
|
||||
public RefCountedThreadSafe<WaitableEventKernel> {
|
||||
struct WaitableEventKernel MOZ_FINAL {
|
||||
public:
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(WaitableEventKernel)
|
||||
WaitableEventKernel(bool manual_reset, bool initially_signaled)
|
||||
: manual_reset_(manual_reset),
|
||||
signaled_(initially_signaled) {
|
||||
@ -154,9 +155,11 @@ class WaitableEvent {
|
||||
const bool manual_reset_;
|
||||
bool signaled_;
|
||||
std::list<Waiter*> waiters_;
|
||||
protected:
|
||||
~WaitableEventKernel() {}
|
||||
};
|
||||
|
||||
scoped_refptr<WaitableEventKernel> kernel_;
|
||||
nsRefPtr<WaitableEventKernel> kernel_;
|
||||
|
||||
bool SignalAll();
|
||||
bool SignalOne();
|
||||
|
@ -12,6 +12,7 @@
|
||||
#else
|
||||
#include "base/message_loop.h"
|
||||
#include "base/waitable_event.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#endif
|
||||
|
||||
namespace base {
|
||||
@ -141,10 +142,10 @@ class WaitableEventWatcher
|
||||
void WillDestroyCurrentMessageLoop();
|
||||
|
||||
MessageLoop* message_loop_;
|
||||
scoped_refptr<Flag> cancel_flag_;
|
||||
nsRefPtr<Flag> cancel_flag_;
|
||||
AsyncWaiter* waiter_;
|
||||
AsyncCallbackTask* callback_task_;
|
||||
scoped_refptr<WaitableEvent::WaitableEventKernel> kernel_;
|
||||
nsRefPtr<WaitableEvent::WaitableEventKernel> kernel_;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include "base/message_loop.h"
|
||||
#include "base/waitable_event.h"
|
||||
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
namespace base {
|
||||
@ -29,8 +31,9 @@ namespace base {
|
||||
// -----------------------------------------------------------------------------
|
||||
// A thread-safe, reference-counted, write-once flag.
|
||||
// -----------------------------------------------------------------------------
|
||||
class Flag : public RefCountedThreadSafe<Flag> {
|
||||
class Flag MOZ_FINAL {
|
||||
public:
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(Flag)
|
||||
Flag() { flag_ = false; }
|
||||
|
||||
void Set() {
|
||||
@ -43,6 +46,8 @@ class Flag : public RefCountedThreadSafe<Flag> {
|
||||
return flag_;
|
||||
}
|
||||
|
||||
protected:
|
||||
~Flag() {}
|
||||
private:
|
||||
mutable Lock lock_;
|
||||
bool flag_;
|
||||
@ -85,7 +90,7 @@ class AsyncWaiter MOZ_FINAL : public WaitableEvent::Waiter {
|
||||
private:
|
||||
MessageLoop *const message_loop_;
|
||||
Task *const cb_task_;
|
||||
scoped_refptr<Flag> flag_;
|
||||
nsRefPtr<Flag> flag_;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -115,7 +120,7 @@ class AsyncCallbackTask : public Task {
|
||||
}
|
||||
|
||||
private:
|
||||
scoped_refptr<Flag> flag_;
|
||||
nsRefPtr<Flag> flag_;
|
||||
WaitableEventWatcher::Delegate *const delegate_;
|
||||
WaitableEvent *const event_;
|
||||
};
|
||||
|
@ -9,8 +9,6 @@
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/registry.h"
|
||||
#include "base/scoped_handle.h"
|
||||
#include "base/scoped_ptr.h"
|
||||
#include "base/singleton.h"
|
||||
#include "base/string_util.h"
|
||||
#include "base/tracked.h"
|
||||
|
@ -9,8 +9,8 @@
|
||||
#include <vector>
|
||||
#include "base/basictypes.h"
|
||||
#include "base/message_loop.h"
|
||||
#include "base/scoped_ptr.h"
|
||||
#include "base/waitable_event.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
class ChildThread;
|
||||
|
||||
@ -51,7 +51,7 @@ class ChildProcess {
|
||||
private:
|
||||
// NOTE: make sure that child_thread_ is listed before shutdown_event_, since
|
||||
// it depends on it (indirectly through IPC::SyncChannel).
|
||||
scoped_ptr<ChildThread> child_thread_;
|
||||
mozilla::UniquePtr<ChildThread> child_thread_;
|
||||
|
||||
int ref_count_;
|
||||
|
||||
|
@ -10,10 +10,10 @@
|
||||
#include <list>
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "base/scoped_ptr.h"
|
||||
#include "base/waitable_event_watcher.h"
|
||||
#include "chrome/common/child_process_info.h"
|
||||
#include "chrome/common/ipc_channel.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
@ -116,7 +116,7 @@ class ChildProcessHost :
|
||||
bool opening_channel_;
|
||||
|
||||
// The IPC::Channel.
|
||||
scoped_ptr<IPC::Channel> channel_;
|
||||
mozilla::UniquePtr<IPC::Channel> channel_;
|
||||
|
||||
// IPC Channel's id.
|
||||
std::wstring channel_id_;
|
||||
@ -124,7 +124,7 @@ class ChildProcessHost :
|
||||
// Used to watch the child process handle.
|
||||
base::WaitableEventWatcher watcher_;
|
||||
|
||||
scoped_ptr<base::WaitableEvent> process_event_;
|
||||
mozilla::UniquePtr<base::WaitableEvent> process_event_;
|
||||
};
|
||||
|
||||
#endif // CHROME_COMMON_CHILD_PROCESS_HOST_H_
|
||||
|
@ -89,9 +89,9 @@ ChildThread* ChildThread::current() {
|
||||
}
|
||||
|
||||
void ChildThread::Init() {
|
||||
channel_.reset(new IPC::Channel(channel_name_,
|
||||
IPC::Channel::MODE_CLIENT,
|
||||
this));
|
||||
channel_ = mozilla::MakeUnique<IPC::Channel>(channel_name_,
|
||||
IPC::Channel::MODE_CLIENT,
|
||||
this);
|
||||
|
||||
#ifdef IPC_MESSAGE_LOG_ENABLED
|
||||
IPC::Logging::current()->SetIPCSender(this);
|
||||
@ -104,7 +104,7 @@ void ChildThread::CleanUp() {
|
||||
#endif
|
||||
// Need to destruct the SyncChannel to the browser before we go away because
|
||||
// it caches a pointer to this thread.
|
||||
channel_.reset();
|
||||
channel_ = nullptr;
|
||||
}
|
||||
|
||||
void ChildThread::OnProcessFinalRelease() {
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "base/thread.h"
|
||||
#include "chrome/common/ipc_sync_channel.h"
|
||||
#include "chrome/common/message_router.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
class ResourceDispatcher;
|
||||
|
||||
@ -69,7 +70,7 @@ class ChildThread : public IPC::Channel::Listener,
|
||||
MessageLoop* owner_loop_;
|
||||
|
||||
std::wstring channel_name_;
|
||||
scoped_ptr<IPC::Channel> channel_;
|
||||
mozilla::UniquePtr<IPC::Channel> channel_;
|
||||
|
||||
// Used only on the background render thread to implement message routing
|
||||
// functionality to the consumers of the ChildThread.
|
||||
|
@ -9,17 +9,17 @@
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "base/file_descriptor_posix.h"
|
||||
#include "base/ref_counted.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// A FileDescriptorSet is an ordered set of POSIX file descriptors. These are
|
||||
// associated with IPC messages so that descriptors can be transmitted over a
|
||||
// UNIX domain socket.
|
||||
// -----------------------------------------------------------------------------
|
||||
class FileDescriptorSet : public base::RefCountedThreadSafe<FileDescriptorSet> {
|
||||
class FileDescriptorSet {
|
||||
public:
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FileDescriptorSet)
|
||||
FileDescriptorSet();
|
||||
~FileDescriptorSet();
|
||||
|
||||
// Mac and Linux both limit the number of file descriptors per message to
|
||||
// slightly more than 250.
|
||||
@ -84,6 +84,8 @@ class FileDescriptorSet : public base::RefCountedThreadSafe<FileDescriptorSet> {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
private:
|
||||
~FileDescriptorSet();
|
||||
|
||||
// A vector of descriptors and close flags. If this message is sent, then
|
||||
// these descriptors are sent as control data. After sending, any descriptors
|
||||
// with a true flag are closed. If this message has been received, then these
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "base/lock.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/process_util.h"
|
||||
#include "base/scoped_ptr.h"
|
||||
#include "base/string_util.h"
|
||||
#include "base/singleton.h"
|
||||
#include "chrome/common/chrome_switches.h"
|
||||
@ -30,6 +29,7 @@
|
||||
#include "chrome/common/ipc_logging.h"
|
||||
#include "chrome/common/ipc_message_utils.h"
|
||||
#include "mozilla/ipc/ProtocolUtils.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
#ifdef MOZ_TASK_TRACER
|
||||
#include "GeckoTaskTracerImpl.h"
|
||||
@ -371,9 +371,9 @@ void Channel::ChannelImpl::ResetFileDescriptor(int fd) {
|
||||
}
|
||||
|
||||
bool Channel::ChannelImpl::EnqueueHelloMessage() {
|
||||
scoped_ptr<Message> msg(new Message(MSG_ROUTING_NONE,
|
||||
HELLO_MESSAGE_TYPE,
|
||||
IPC::Message::PRIORITY_NORMAL));
|
||||
mozilla::UniquePtr<Message> msg(new Message(MSG_ROUTING_NONE,
|
||||
HELLO_MESSAGE_TYPE,
|
||||
IPC::Message::PRIORITY_NORMAL));
|
||||
if (!msg->WriteInt(base::GetCurrentProcId())) {
|
||||
Close();
|
||||
return false;
|
||||
|
@ -17,6 +17,8 @@
|
||||
#include "base/message_loop.h"
|
||||
#include "chrome/common/file_descriptor_set_posix.h"
|
||||
|
||||
#include "nsAutoPtr.h"
|
||||
|
||||
namespace IPC {
|
||||
|
||||
// An implementation of ChannelImpl for POSIX systems that works via
|
||||
@ -146,7 +148,7 @@ class Channel::ChannelImpl : public MessageLoopForIO::Watcher {
|
||||
#if defined(OS_MACOSX)
|
||||
struct PendingDescriptors {
|
||||
uint32_t id;
|
||||
scoped_refptr<FileDescriptorSet> fds;
|
||||
nsRefPtr<FileDescriptorSet> fds;
|
||||
|
||||
PendingDescriptors() : id(0) { }
|
||||
PendingDescriptors(uint32_t id, FileDescriptorSet *fds)
|
||||
|
@ -7,8 +7,9 @@
|
||||
|
||||
#include <vector>
|
||||
#include "base/lock.h"
|
||||
#include "base/ref_counted.h"
|
||||
#include "chrome/common/ipc_channel.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "nsAutoPtr.h"
|
||||
|
||||
class MessageLoop;
|
||||
|
||||
@ -46,9 +47,9 @@ class ChannelProxy : public Message::Sender {
|
||||
public:
|
||||
// A class that receives messages on the thread where the IPC channel is
|
||||
// running. It can choose to prevent the default action for an IPC message.
|
||||
class MessageFilter : public base::RefCountedThreadSafe<MessageFilter> {
|
||||
class MessageFilter {
|
||||
public:
|
||||
virtual ~MessageFilter() {}
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MessageFilter)
|
||||
|
||||
// Called on the background thread to provide the filter with access to the
|
||||
// channel. Called when the IPC channel is initialized or when AddFilter
|
||||
@ -77,6 +78,8 @@ class ChannelProxy : public Message::Sender {
|
||||
virtual bool OnMessageReceived(const Message& message) {
|
||||
return false;
|
||||
}
|
||||
protected:
|
||||
virtual ~MessageFilter() {}
|
||||
};
|
||||
|
||||
// Initializes a channel proxy. The channel_id and mode parameters are
|
||||
@ -134,12 +137,11 @@ class ChannelProxy : public Message::Sender {
|
||||
bool create_pipe_now);
|
||||
|
||||
// Used internally to hold state that is referenced on the IPC thread.
|
||||
class Context : public base::RefCountedThreadSafe<Context>,
|
||||
public Channel::Listener {
|
||||
class Context : public Channel::Listener {
|
||||
public:
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(Context)
|
||||
Context(Channel::Listener* listener, MessageFilter* filter,
|
||||
MessageLoop* ipc_thread);
|
||||
virtual ~Context() { }
|
||||
MessageLoop* ipc_message_loop() const { return ipc_message_loop_; }
|
||||
const std::wstring& channel_id() const { return channel_id_; }
|
||||
|
||||
@ -147,6 +149,8 @@ class ChannelProxy : public Message::Sender {
|
||||
void OnDispatchMessage(const Message& message);
|
||||
|
||||
protected:
|
||||
virtual ~Context() {}
|
||||
|
||||
// IPC::Channel::Listener methods:
|
||||
virtual void OnMessageReceived(const Message& message);
|
||||
virtual void OnChannelConnected(int32_t peer_pid);
|
||||
@ -184,7 +188,7 @@ class ChannelProxy : public Message::Sender {
|
||||
Channel::Listener* listener_;
|
||||
|
||||
// List of filters. This is only accessed on the IPC thread.
|
||||
std::vector<scoped_refptr<MessageFilter> > filters_;
|
||||
std::vector<nsRefPtr<MessageFilter> > filters_;
|
||||
MessageLoop* ipc_message_loop_;
|
||||
Channel* channel_;
|
||||
std::wstring channel_id_;
|
||||
@ -201,7 +205,7 @@ class ChannelProxy : public Message::Sender {
|
||||
// By maintaining this indirection (ref-counted) to our internal state, we
|
||||
// can safely be destroyed while the background thread continues to do stuff
|
||||
// that involves this data.
|
||||
scoped_refptr<Context> context_;
|
||||
nsRefPtr<Context> context_;
|
||||
};
|
||||
|
||||
} // namespace IPC
|
||||
|
@ -201,9 +201,9 @@ bool Channel::ChannelImpl::CreatePipe(const std::wstring& channel_id,
|
||||
}
|
||||
|
||||
bool Channel::ChannelImpl::EnqueueHelloMessage() {
|
||||
scoped_ptr<Message> m(new Message(MSG_ROUTING_NONE,
|
||||
HELLO_MESSAGE_TYPE,
|
||||
IPC::Message::PRIORITY_NORMAL));
|
||||
mozilla::UniquePtr<Message> m = mozilla::MakeUnique<Message>(MSG_ROUTING_NONE,
|
||||
HELLO_MESSAGE_TYPE,
|
||||
IPC::Message::PRIORITY_NORMAL);
|
||||
if (!m->WriteInt(GetCurrentProcessId())) {
|
||||
CloseHandle(pipe_);
|
||||
pipe_ = INVALID_HANDLE_VALUE;
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "base/message_loop.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
class NonThreadSafe;
|
||||
|
||||
@ -107,7 +108,7 @@ class Channel::ChannelImpl : public MessageLoopForIO::IOHandler {
|
||||
|
||||
ScopedRunnableMethodFactory<ChannelImpl> factory_;
|
||||
|
||||
scoped_ptr<NonThreadSafe> thread_check_;
|
||||
mozilla::UniquePtr<NonThreadSafe> thread_check_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ChannelImpl);
|
||||
};
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "base/singleton.h"
|
||||
#include "base/waitable_event_watcher.h"
|
||||
#include "chrome/common/ipc_message_utils.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
class MessageLoop;
|
||||
|
||||
@ -91,8 +92,8 @@ class Logging : public base::WaitableEventWatcher::Delegate,
|
||||
|
||||
base::WaitableEventWatcher watcher_;
|
||||
|
||||
scoped_ptr<base::WaitableEvent> logging_event_on_;
|
||||
scoped_ptr<base::WaitableEvent> logging_event_off_;
|
||||
mozilla::UniquePtr<base::WaitableEvent> logging_event_on_;
|
||||
mozilla::UniquePtr<base::WaitableEvent> logging_event_off_;
|
||||
bool enabled_;
|
||||
|
||||
std::vector<LogData> queued_logs_;
|
||||
|
@ -19,7 +19,7 @@
|
||||
#endif
|
||||
|
||||
#if defined(OS_POSIX)
|
||||
#include "base/ref_counted.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#endif
|
||||
|
||||
namespace base {
|
||||
@ -362,7 +362,7 @@ class Message : public Pickle {
|
||||
|
||||
#if defined(OS_POSIX)
|
||||
// The set of file descriptors associated with this message.
|
||||
scoped_refptr<FileDescriptorSet> file_descriptor_set_;
|
||||
nsRefPtr<FileDescriptorSet> file_descriptor_set_;
|
||||
|
||||
// Ensure that a FileDescriptorSet is allocated
|
||||
void EnsureFileDescriptorSet();
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "base/waitable_event.h"
|
||||
#include "base/waitable_event_watcher.h"
|
||||
#include "chrome/common/ipc_sync_message.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
|
||||
using base::TimeDelta;
|
||||
using base::TimeTicks;
|
||||
@ -34,9 +35,9 @@ namespace IPC {
|
||||
// SyncChannel objects on the same thread (since one object can receive a
|
||||
// sync message while another one is blocked).
|
||||
|
||||
class SyncChannel::ReceivedSyncMsgQueue :
|
||||
public base::RefCountedThreadSafe<ReceivedSyncMsgQueue> {
|
||||
class SyncChannel::ReceivedSyncMsgQueue {
|
||||
public:
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SyncChannel::ReceivedSyncMsgQueue)
|
||||
// Returns the ReceivedSyncMsgQueue instance for this thread, creating one
|
||||
// if necessary. Call RemoveContext on the same thread when done.
|
||||
static ReceivedSyncMsgQueue* AddContext() {
|
||||
@ -51,9 +52,6 @@ class SyncChannel::ReceivedSyncMsgQueue :
|
||||
return rv;
|
||||
}
|
||||
|
||||
~ReceivedSyncMsgQueue() {
|
||||
}
|
||||
|
||||
// Called on IPC thread when a synchronous message or reply arrives.
|
||||
void QueueMessage(const Message& msg, SyncChannel::SyncContext* context) {
|
||||
bool was_task_pending;
|
||||
@ -92,7 +90,7 @@ class SyncChannel::ReceivedSyncMsgQueue :
|
||||
void DispatchMessages() {
|
||||
while (true) {
|
||||
Message* message;
|
||||
scoped_refptr<SyncChannel::SyncContext> context;
|
||||
nsRefPtr<SyncChannel::SyncContext> context;
|
||||
{
|
||||
AutoLock auto_lock(message_lock_);
|
||||
if (message_queue_.empty())
|
||||
@ -148,6 +146,9 @@ class SyncChannel::ReceivedSyncMsgQueue :
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
~ReceivedSyncMsgQueue() {}
|
||||
|
||||
private:
|
||||
// See the comment in SyncChannel::SyncChannel for why this event is created
|
||||
// as manual reset.
|
||||
@ -162,7 +163,7 @@ class SyncChannel::ReceivedSyncMsgQueue :
|
||||
struct QueuedMessage {
|
||||
QueuedMessage(Message* m, SyncContext* c) : message(m), context(c) { }
|
||||
Message* message;
|
||||
scoped_refptr<SyncChannel::SyncContext> context;
|
||||
nsRefPtr<SyncChannel::SyncContext> context;
|
||||
};
|
||||
|
||||
typedef std::deque<QueuedMessage> SyncMessageQueue;
|
||||
@ -368,7 +369,7 @@ bool SyncChannel::SendWithTimeout(Message* message, int timeout_ms) {
|
||||
}
|
||||
|
||||
// *this* might get deleted in WaitForReply.
|
||||
scoped_refptr<SyncContext> context(sync_context());
|
||||
nsRefPtr<SyncContext> context(sync_context());
|
||||
if (context->shutdown_event()->IsSignaled()) {
|
||||
delete message;
|
||||
return false;
|
||||
|
@ -9,12 +9,13 @@
|
||||
#include <deque>
|
||||
#include "base/basictypes.h"
|
||||
#include "base/lock.h"
|
||||
#include "base/ref_counted.h"
|
||||
#include "base/scoped_handle.h"
|
||||
#include "base/waitable_event.h"
|
||||
#include "base/waitable_event_watcher.h"
|
||||
#include "chrome/common/ipc_channel_proxy.h"
|
||||
|
||||
#include "nsAutoPtr.h"
|
||||
|
||||
namespace IPC {
|
||||
|
||||
class SyncMessage;
|
||||
@ -123,7 +124,7 @@ class SyncChannel : public ChannelProxy,
|
||||
PendingSyncMessageQueue deserializers_;
|
||||
Lock deserializers_lock_;
|
||||
|
||||
scoped_refptr<ReceivedSyncMsgQueue> received_sync_msgs_;
|
||||
nsRefPtr<ReceivedSyncMsgQueue> received_sync_msgs_;
|
||||
|
||||
base::WaitableEvent* shutdown_event_;
|
||||
base::WaitableEventWatcher shutdown_watcher_;
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
#include "base/file_path.h"
|
||||
#include "base/process_util.h"
|
||||
#include "base/scoped_ptr.h"
|
||||
#include "base/waitable_event.h"
|
||||
#include "chrome/common/child_process_host.h"
|
||||
|
||||
|
@ -743,7 +743,7 @@ class B2GOptions(MochitestOptions):
|
||||
defaults["testPath"] = ""
|
||||
defaults["extensionsToExclude"] = ["specialpowers"]
|
||||
# See dependencies of bug 1038943.
|
||||
defaults["leakThreshold"] = 5116
|
||||
defaults["leakThreshold"] = 5180
|
||||
self.set_defaults(**defaults)
|
||||
|
||||
def verifyRemoteOptions(self, options):
|
||||
|
@ -131,6 +131,7 @@ extern nsresult nsStringInputStreamConstructor(nsISupports*, REFNSIID, void**);
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/CountingAllocatorBase.h"
|
||||
#include "mozilla/SystemMemoryReporter.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
#include "mozilla/ipc/GeckoChildProcessHost.h"
|
||||
|
||||
@ -522,8 +523,7 @@ NS_InitXPCOM2(nsIServiceManager** aResult,
|
||||
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Default &&
|
||||
!BrowserProcessSubThread::GetMessageLoop(BrowserProcessSubThread::IO)) {
|
||||
scoped_ptr<BrowserProcessSubThread> ioThread(
|
||||
new BrowserProcessSubThread(BrowserProcessSubThread::IO));
|
||||
UniquePtr<BrowserProcessSubThread> ioThread = MakeUnique<BrowserProcessSubThread>(BrowserProcessSubThread::IO);
|
||||
|
||||
base::Thread::Options options;
|
||||
options.message_loop_type = MessageLoop::TYPE_IO;
|
||||
|
Loading…
Reference in New Issue
Block a user