Chromium Code Reviews| Index: chrome/browser/chromeos/drive/drive_file_system_util.h |
| diff --git a/chrome/browser/chromeos/drive/drive_file_system_util.h b/chrome/browser/chromeos/drive/drive_file_system_util.h |
| index 193cb8853da171c0a19f72695eab4ded15f458cb..eee73cbfecc04489a65a15ff89b893b253695f1b 100644 |
| --- a/chrome/browser/chromeos/drive/drive_file_system_util.h |
| +++ b/chrome/browser/chromeos/drive/drive_file_system_util.h |
| @@ -8,6 +8,7 @@ |
| #include <string> |
| #include "base/callback_forward.h" |
| +#include "base/memory/scoped_ptr.h" |
| #include "base/platform_file.h" |
| #include "chrome/browser/chromeos/drive/drive_file_error.h" |
| #include "chrome/browser/google_apis/gdata_errorcode.h" |
| @@ -139,6 +140,18 @@ void ConvertPlatformFileInfoToProto(const base::PlatformFileInfo& file_info, |
| // Does nothing with |error|. Used with functions taking FileOperationCallback. |
| void EmptyFileOperationCallback(DriveFileError error); |
| +// Helper to destroy objects which needs Destroy() to be called on destruction. |
| +template<typename T> |
|
hidehiko
2013/03/18 13:16:28
How about:
struct DestroyHelper {
template<type
hashimoto
2013/03/18 13:40:10
Looks beautiful, done.
|
| +struct DestroyHelper { |
| + // scoped_ptr for T which calls Destroy() on destruction. |
| + typedef scoped_ptr<T, DestroyHelper<T> > scoped_ptr; |
| + |
| + void operator()(T* object) const { |
| + if (object) |
| + object->Destroy(); |
| + } |
| +}; |
| + |
| } // namespace util |
| } // namespace drive |