1// Copyright 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome/browser/sync_file_system/drive_backend/callback_tracker_internal.h"
6
7#include "chrome/browser/sync_file_system/drive_backend/callback_tracker.h"
8
9namespace sync_file_system {
10namespace drive_backend {
11namespace internal {
12
13AbortHelper::AbortHelper(CallbackTracker* tracker)
14    : tracker_(tracker), weak_ptr_factory_(this) {
15}
16
17AbortHelper::~AbortHelper() {}
18
19base::WeakPtr<AbortHelper> AbortHelper::AsWeakPtr() {
20  return weak_ptr_factory_.GetWeakPtr();
21}
22
23// static
24scoped_ptr<AbortHelper> AbortHelper::TakeOwnership(
25    const base::WeakPtr<AbortHelper>& abort_helper) {
26  if (!abort_helper)
27    return scoped_ptr<AbortHelper>();
28  scoped_ptr<AbortHelper> result =
29      abort_helper->tracker_->PassAbortHelper(abort_helper.get());
30  abort_helper->weak_ptr_factory_.InvalidateWeakPtrs();
31  return result.Pass();
32}
33
34}  // namespace internal
35}  // namespace drive_backend
36}  // namespace sync_file_system
37