AttachAsUserData now can assume the existence of wrapper
This commit is contained in:
parent
1505a46ed0
commit
846ec5ba49
3 changed files with 6 additions and 15 deletions
|
@ -29,7 +29,7 @@ class IDUserData : public base::SupportsUserData::Data {
|
|||
} // namespace
|
||||
|
||||
TrackableObjectBase::TrackableObjectBase()
|
||||
: weak_map_id_(0), wrapped_(nullptr), weak_factory_(this) {
|
||||
: weak_map_id_(0), weak_factory_(this) {
|
||||
cleanup_ = RegisterDestructionCallback(GetDestroyClosure());
|
||||
}
|
||||
|
||||
|
@ -46,14 +46,7 @@ void TrackableObjectBase::Destroy() {
|
|||
}
|
||||
|
||||
void TrackableObjectBase::AttachAsUserData(base::SupportsUserData* wrapped) {
|
||||
if (weak_map_id_ != 0) {
|
||||
wrapped->SetUserData(kTrackedObjectKey, new IDUserData(weak_map_id_));
|
||||
wrapped_ = nullptr;
|
||||
} else {
|
||||
// If the TrackableObjectBase is not ready yet then delay SetUserData until
|
||||
// AfterInit is called.
|
||||
wrapped_ = wrapped;
|
||||
}
|
||||
wrapped->SetUserData(kTrackedObjectKey, new IDUserData(weak_map_id_));
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue