From 0184ced8d904d202ad7ab392ef8eca55d83d2937 Mon Sep 17 00:00:00 2001 From: "anujk.sharma" Date: Wed, 27 Aug 2014 23:49:02 -0700 Subject: Declaring the weak_ptr_factory in proper order. Cleaning up weak_ptr_factory destruction order in "src/ipc" module. WeakPtrFactory should remain the last member so it'll be destroyed and invalidate its weak pointers before any other members are destroyed. BUG=303818 Review URL: https://codereview.chromium.org/508903002 Cr-Commit-Position: refs/heads/master@{#292334} --- ipc/ipc_channel_win.h | 4 +--- ipc/mojo/ipc_channel_mojo.cc | 6 +++--- ipc/mojo/ipc_channel_mojo.h | 3 ++- 3 files changed, 6 insertions(+), 7 deletions(-) (limited to 'ipc') diff --git a/ipc/ipc_channel_win.h b/ipc/ipc_channel_win.h index 2bbb294..e976aa3 100644 --- a/ipc/ipc_channel_win.h +++ b/ipc/ipc_channel_win.h @@ -106,10 +106,8 @@ class ChannelWin : public Channel, // compatability with existing clients that don't validate the channel.) int32 client_secret_; - - base::WeakPtrFactory weak_factory_; - scoped_ptr thread_check_; + base::WeakPtrFactory weak_factory_; DISALLOW_COPY_AND_ASSIGN(ChannelWin); }; diff --git a/ipc/mojo/ipc_channel_mojo.cc b/ipc/mojo/ipc_channel_mojo.cc index 2ec9945..88034f1 100644 --- a/ipc/mojo/ipc_channel_mojo.cc +++ b/ipc/mojo/ipc_channel_mojo.cc @@ -484,10 +484,10 @@ scoped_ptr ChannelMojo::CreateFactory( ChannelMojo::ChannelMojo( scoped_ptr bootstrap, Mode mode, Listener* listener, scoped_refptr io_thread_task_runner) - : weak_factory_(this), - bootstrap_(bootstrap.Pass()), + : bootstrap_(bootstrap.Pass()), mode_(mode), listener_(listener), - peer_pid_(base::kNullProcessId) { + peer_pid_(base::kNullProcessId), + weak_factory_(this) { if (base::MessageLoopProxy::current() == io_thread_task_runner.get()) { InitOnIOThread(); } else { diff --git a/ipc/mojo/ipc_channel_mojo.h b/ipc/mojo/ipc_channel_mojo.h index a2fa587..4d4df63 100644 --- a/ipc/mojo/ipc_channel_mojo.h +++ b/ipc/mojo/ipc_channel_mojo.h @@ -108,7 +108,6 @@ class IPC_MOJO_EXPORT ChannelMojo : public Channel { void InitOnIOThread(); - base::WeakPtrFactory weak_factory_; scoped_ptr bootstrap_; Mode mode_; Listener* listener_; @@ -120,6 +119,8 @@ class IPC_MOJO_EXPORT ChannelMojo : public Channel { scoped_ptr message_reader_; ScopedVector pending_messages_; + base::WeakPtrFactory weak_factory_; + DISALLOW_COPY_AND_ASSIGN(ChannelMojo); }; -- cgit v1.1