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

Side by Side Diff: tools/android/forwarder2/device_controller.cc

Issue 555093002: Fix WeakPtrFactory ordering problems in src/tools (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added the comment explaining WeakPtrFactory ordering Created 6 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "tools/android/forwarder2/device_controller.h" 5 #include "tools/android/forwarder2/device_controller.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 29 matching lines...) Expand all
40 DeviceController::~DeviceController() { 40 DeviceController::~DeviceController() {
41 DCHECK(construction_task_runner_->RunsTasksOnCurrentThread()); 41 DCHECK(construction_task_runner_->RunsTasksOnCurrentThread());
42 } 42 }
43 43
44 void DeviceController::Start() { 44 void DeviceController::Start() {
45 AcceptHostCommandSoon(); 45 AcceptHostCommandSoon();
46 } 46 }
47 47
48 DeviceController::DeviceController(scoped_ptr<Socket> host_socket, 48 DeviceController::DeviceController(scoped_ptr<Socket> host_socket,
49 int exit_notifier_fd) 49 int exit_notifier_fd)
50 : weak_ptr_factory_(this), 50 : host_socket_(host_socket.Pass()),
51 host_socket_(host_socket.Pass()),
52 exit_notifier_fd_(exit_notifier_fd), 51 exit_notifier_fd_(exit_notifier_fd),
53 construction_task_runner_(base::MessageLoopProxy::current()) { 52 construction_task_runner_(base::MessageLoopProxy::current()),
53 weak_ptr_factory_(this) {
54 host_socket_->AddEventFd(exit_notifier_fd); 54 host_socket_->AddEventFd(exit_notifier_fd);
55 } 55 }
56 56
57 void DeviceController::AcceptHostCommandSoon() { 57 void DeviceController::AcceptHostCommandSoon() {
58 base::MessageLoopProxy::current()->PostTask( 58 base::MessageLoopProxy::current()->PostTask(
59 FROM_HERE, 59 FROM_HERE,
60 base::Bind(&DeviceController::AcceptHostCommandInternal, 60 base::Bind(&DeviceController::AcceptHostCommandInternal,
61 base::Unretained(this))); 61 base::Unretained(this)));
62 } 62 }
63 63
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 return; 149 return;
150 } 150 }
151 DCHECK(controller->construction_task_runner_->RunsTasksOnCurrentThread()); 151 DCHECK(controller->construction_task_runner_->RunsTasksOnCurrentThread());
152 bool listener_did_exist = DeleteRefCountedValueInMap( 152 bool listener_did_exist = DeleteRefCountedValueInMap(
153 listener->listener_port(), &controller->listeners_); 153 listener->listener_port(), &controller->listeners_);
154 DCHECK(listener_did_exist); 154 DCHECK(listener_did_exist);
155 // Note that |listener| was deleted by DeleteRefCountedValueInMap(). 155 // Note that |listener| was deleted by DeleteRefCountedValueInMap().
156 } 156 }
157 157
158 } // namespace forwarder 158 } // namespace forwarder
OLDNEW
« no previous file with comments | « tools/android/forwarder2/device_controller.h ('k') | tools/android/forwarder2/self_deleter_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698