diff options
author | dmichael <dmichael@chromium.org> | 2015-01-13 14:31:45 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-13 22:32:37 +0000 |
commit | e8841f47577c6c1b9eb7dc501762b5f2487bee42 (patch) | |
tree | 912e64d451574500831e7be89a66c3309ecb36d9 /ipc | |
parent | 14e6286ef36dbf5b703877f53f85a01e121e54ed (diff) | |
download | chromium_src-e8841f47577c6c1b9eb7dc501762b5f2487bee42.zip chromium_src-e8841f47577c6c1b9eb7dc501762b5f2487bee42.tar.gz chromium_src-e8841f47577c6c1b9eb7dc501762b5f2487bee42.tar.bz2 |
Move WeakPtrFactory to the end of AsyncHandleWaiter
This forces WeakPtrs to be invalidated before other members' destructors run.
See the bug or the documentation of WeakPtrFactory for more information. I'm
in the process of trying to turn on a clang check for this (see the bug).
BUG=303818
R=morrita@chromium.org
Review URL: https://codereview.chromium.org/848533003
Cr-Commit-Position: refs/heads/master@{#311349}
Diffstat (limited to 'ipc')
-rw-r--r-- | ipc/mojo/async_handle_waiter.cc | 8 | ||||
-rw-r--r-- | ipc/mojo/async_handle_waiter.h | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/ipc/mojo/async_handle_waiter.cc b/ipc/mojo/async_handle_waiter.cc index d8455ee..cf908a7 100644 --- a/ipc/mojo/async_handle_waiter.cc +++ b/ipc/mojo/async_handle_waiter.cc @@ -51,10 +51,10 @@ class AsyncHandleWaiter::Context }; AsyncHandleWaiter::AsyncHandleWaiter(base::Callback<void(MojoResult)> callback) - : weak_factory_(this), - context_(new Context(base::MessageLoop::current()->task_runner(), - weak_factory_.GetWeakPtr())), - callback_(callback) { + : callback_(callback), + weak_factory_(this) { + context_ = new Context(base::MessageLoop::current()->task_runner(), + weak_factory_.GetWeakPtr()); } AsyncHandleWaiter::~AsyncHandleWaiter() { diff --git a/ipc/mojo/async_handle_waiter.h b/ipc/mojo/async_handle_waiter.h index 187e2f6..c8515f1 100644 --- a/ipc/mojo/async_handle_waiter.h +++ b/ipc/mojo/async_handle_waiter.h @@ -32,9 +32,9 @@ class IPC_MOJO_EXPORT AsyncHandleWaiter { private: void InvokeCallback(MojoResult result); - base::WeakPtrFactory<AsyncHandleWaiter> weak_factory_; scoped_refptr<Context> context_; base::Callback<void(MojoResult)> callback_; + base::WeakPtrFactory<AsyncHandleWaiter> weak_factory_; DISALLOW_COPY_AND_ASSIGN(AsyncHandleWaiter); }; |