| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/sync_file_system/drive_backend/callback_tracker.h" | 5 #include "chrome/browser/sync_file_system/drive_backend/callback_tracker.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 namespace sync_file_system { | 9 namespace sync_file_system { |
| 10 namespace drive_backend { | 10 namespace drive_backend { |
| 11 | 11 |
| 12 CallbackTracker::CallbackTracker() { | 12 CallbackTracker::CallbackTracker() { |
| 13 } | 13 } |
| 14 | 14 |
| 15 CallbackTracker::~CallbackTracker() { | 15 CallbackTracker::~CallbackTracker() { |
| 16 AbortAll(); | 16 AbortAll(); |
| 17 } | 17 } |
| 18 | 18 |
| 19 void CallbackTracker::AbortAll() { | 19 void CallbackTracker::AbortAll() { |
| 20 AbortClosureByHelper helpers; | 20 AbortClosureByHelper helpers; |
| 21 std::swap(helpers, helpers_); | 21 std::swap(helpers, helpers_); |
| 22 for (AbortClosureByHelper::iterator itr = helpers.begin(); | 22 for (AbortClosureByHelper::iterator itr = helpers.begin(); |
| 23 itr != helpers.end(); ++itr) { | 23 itr != helpers.end(); ++itr) { |
| 24 delete itr->first; | 24 delete itr->first; |
| 25 itr->second.Run(); | 25 itr->second.Run(); |
| 26 } | 26 } |
| 27 } | 27 } |
| 28 | 28 |
| 29 scoped_ptr<internal::AbortHelper> CallbackTracker::PassAbortHelper( | 29 std::unique_ptr<internal::AbortHelper> CallbackTracker::PassAbortHelper( |
| 30 internal::AbortHelper* helper) { | 30 internal::AbortHelper* helper) { |
| 31 if (helpers_.erase(helper) == 1) | 31 if (helpers_.erase(helper) == 1) |
| 32 return scoped_ptr<internal::AbortHelper>(helper); | 32 return std::unique_ptr<internal::AbortHelper>(helper); |
| 33 return nullptr; | 33 return nullptr; |
| 34 } | 34 } |
| 35 | 35 |
| 36 } // namespace drive_backend | 36 } // namespace drive_backend |
| 37 } // namespace sync_file_system | 37 } // namespace sync_file_system |
| OLD | NEW |