Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Side by Side Diff: ipc/mojo/async_handle_waiter.cc

Issue 848533003: Move WeakPtrFactory to the end of AsyncHandleWaiter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ipc/mojo/async_handle_waiter.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ipc/mojo/async_handle_waiter.h" 5 #include "ipc/mojo/async_handle_waiter.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 // A weak reference. Note that |waiter_| must be touched only from the 44 // A weak reference. Note that |waiter_| must be touched only from the
45 // original thread. 45 // original thread.
46 const base::WeakPtr<AsyncHandleWaiter> waiter_; 46 const base::WeakPtr<AsyncHandleWaiter> waiter_;
47 const scoped_refptr<base::TaskRunner> runner_; 47 const scoped_refptr<base::TaskRunner> runner_;
48 MojoResult last_result_; 48 MojoResult last_result_;
49 49
50 DISALLOW_COPY_AND_ASSIGN(Context); 50 DISALLOW_COPY_AND_ASSIGN(Context);
51 }; 51 };
52 52
53 AsyncHandleWaiter::AsyncHandleWaiter(base::Callback<void(MojoResult)> callback) 53 AsyncHandleWaiter::AsyncHandleWaiter(base::Callback<void(MojoResult)> callback)
54 : weak_factory_(this), 54 : callback_(callback),
55 context_(new Context(base::MessageLoop::current()->task_runner(), 55 weak_factory_(this) {
56 weak_factory_.GetWeakPtr())), 56 context_ = new Context(base::MessageLoop::current()->task_runner(),
57 callback_(callback) { 57 weak_factory_.GetWeakPtr());
58 } 58 }
59 59
60 AsyncHandleWaiter::~AsyncHandleWaiter() { 60 AsyncHandleWaiter::~AsyncHandleWaiter() {
61 } 61 }
62 62
63 MojoResult AsyncHandleWaiter::Wait(MojoHandle handle, 63 MojoResult AsyncHandleWaiter::Wait(MojoHandle handle,
64 MojoHandleSignals signals) { 64 MojoHandleSignals signals) {
65 return mojo::embedder::AsyncWait( 65 return mojo::embedder::AsyncWait(
66 handle, signals, base::Bind(&Context::HandleIsReady, context_)); 66 handle, signals, base::Bind(&Context::HandleIsReady, context_));
67 } 67 }
68 68
69 void AsyncHandleWaiter::InvokeCallback(MojoResult result) { 69 void AsyncHandleWaiter::InvokeCallback(MojoResult result) {
70 callback_.Run(result); 70 callback_.Run(result);
71 } 71 }
72 72
73 } // namespace internal 73 } // namespace internal
74 } // namespace IPC 74 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/mojo/async_handle_waiter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698