Skip to content

Commit

Permalink
Declaring the weak_ptr_factory in proper order.
Browse files Browse the repository at this point in the history
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}
  • Loading branch information
anujk.sharma authored and Commit bot committed Aug 28, 2014
1 parent 884ad19 commit 0184ced
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Anish Patankar <anish.p@samsung.com>
Ankit Kumar <ankit2.kumar@samsung.com>
Anssi Hannula <anssi.hannula@iki.fi>
Antonio Gomes <a1.gomes@sisa.samsung.com>
Anuj Kumar Sharma <anujk.sharma@samsung.com>
Arnaud Renevier <a.renevier@samsung.com>
Arpita Bahuguna <a.bah@samsung.com>
Arthur Lussos <developer0420@gmail.com>
Expand Down
4 changes: 1 addition & 3 deletions ipc/ipc_channel_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,8 @@ class ChannelWin : public Channel,
// compatability with existing clients that don't validate the channel.)
int32 client_secret_;


base::WeakPtrFactory<ChannelWin> weak_factory_;

scoped_ptr<base::ThreadChecker> thread_check_;
base::WeakPtrFactory<ChannelWin> weak_factory_;

DISALLOW_COPY_AND_ASSIGN(ChannelWin);
};
Expand Down
6 changes: 3 additions & 3 deletions ipc/mojo/ipc_channel_mojo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,10 @@ scoped_ptr<ChannelFactory> ChannelMojo::CreateFactory(
ChannelMojo::ChannelMojo(
scoped_ptr<Channel> bootstrap, Mode mode, Listener* listener,
scoped_refptr<base::TaskRunner> 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 {
Expand Down
3 changes: 2 additions & 1 deletion ipc/mojo/ipc_channel_mojo.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ class IPC_MOJO_EXPORT ChannelMojo : public Channel {

void InitOnIOThread();

base::WeakPtrFactory<ChannelMojo> weak_factory_;
scoped_ptr<Channel> bootstrap_;
Mode mode_;
Listener* listener_;
Expand All @@ -120,6 +119,8 @@ class IPC_MOJO_EXPORT ChannelMojo : public Channel {
scoped_ptr<MessageReader, ReaderDeleter> message_reader_;
ScopedVector<Message> pending_messages_;

base::WeakPtrFactory<ChannelMojo> weak_factory_;

DISALLOW_COPY_AND_ASSIGN(ChannelMojo);
};

Expand Down

0 comments on commit 0184ced

Please sign in to comment.