Commit bead29c2 authored by anujk.sharma's avatar anujk.sharma Committed by Commit bot

Fix WeakPtrFactory member ordering in device

Changing in the intialization order of WeakPtrFactory such that all
member variables should appear before the WeakPtrFactory to ensure
that any WeakPtrs to Controller are invalidated before its members
variable's destructors are executed, rendering them invalid.

BUG=303818

Review URL: https://codereview.chromium.org/791743006

Cr-Commit-Position: refs/heads/master@{#308090}
parent 91086220
...@@ -479,8 +479,8 @@ UsbDeviceHandleImpl::UsbDeviceHandleImpl(scoped_refptr<UsbContext> context, ...@@ -479,8 +479,8 @@ UsbDeviceHandleImpl::UsbDeviceHandleImpl(scoped_refptr<UsbContext> context,
handle_(handle), handle_(handle),
config_(config), config_(config),
context_(context), context_(context),
weak_factory_(this), task_runner_(base::ThreadTaskRunnerHandle::Get()),
task_runner_(base::ThreadTaskRunnerHandle::Get()) { weak_factory_(this) {
DCHECK(handle) << "Cannot create device with NULL handle."; DCHECK(handle) << "Cannot create device with NULL handle.";
} }
......
...@@ -149,10 +149,10 @@ class UsbDeviceHandleImpl : public UsbDeviceHandle { ...@@ -149,10 +149,10 @@ class UsbDeviceHandleImpl : public UsbDeviceHandle {
// before this handle. // before this handle.
scoped_refptr<UsbContext> context_; scoped_refptr<UsbContext> context_;
base::WeakPtrFactory<UsbDeviceHandleImpl> weak_factory_;
scoped_refptr<base::SingleThreadTaskRunner> task_runner_; scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
base::ThreadChecker thread_checker_; base::ThreadChecker thread_checker_;
base::WeakPtrFactory<UsbDeviceHandleImpl> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(UsbDeviceHandleImpl); DISALLOW_COPY_AND_ASSIGN(UsbDeviceHandleImpl);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment