Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_SYSTEM_UTIL_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_SYSTEM_UTIL_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_SYSTEM_UTIL_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_SYSTEM_UTIL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 11 #include "base/platform_file.h" | 12 #include "base/platform_file.h" |
| 12 #include "chrome/browser/chromeos/drive/drive_file_error.h" | 13 #include "chrome/browser/chromeos/drive/drive_file_error.h" |
| 13 #include "chrome/browser/google_apis/gdata_errorcode.h" | 14 #include "chrome/browser/google_apis/gdata_errorcode.h" |
| 14 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
| 15 | 16 |
| 16 class Profile; | 17 class Profile; |
| 17 | 18 |
| 18 namespace base { | 19 namespace base { |
| 19 class FilePath; | 20 class FilePath; |
| 20 } | 21 } |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 void ConvertProtoToPlatformFileInfo(const PlatformFileInfoProto& proto, | 133 void ConvertProtoToPlatformFileInfo(const PlatformFileInfoProto& proto, |
| 133 base::PlatformFileInfo* file_info); | 134 base::PlatformFileInfo* file_info); |
| 134 | 135 |
| 135 // Converts the platform file info to the proto representation. | 136 // Converts the platform file info to the proto representation. |
| 136 void ConvertPlatformFileInfoToProto(const base::PlatformFileInfo& file_info, | 137 void ConvertPlatformFileInfoToProto(const base::PlatformFileInfo& file_info, |
| 137 PlatformFileInfoProto* proto); | 138 PlatformFileInfoProto* proto); |
| 138 | 139 |
| 139 // Does nothing with |error|. Used with functions taking FileOperationCallback. | 140 // Does nothing with |error|. Used with functions taking FileOperationCallback. |
| 140 void EmptyFileOperationCallback(DriveFileError error); | 141 void EmptyFileOperationCallback(DriveFileError error); |
| 141 | 142 |
| 143 // Helper to destroy objects which needs Destroy() to be called on destruction. | |
| 144 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.
| |
| 145 struct DestroyHelper { | |
| 146 // scoped_ptr for T which calls Destroy() on destruction. | |
| 147 typedef scoped_ptr<T, DestroyHelper<T> > scoped_ptr; | |
| 148 | |
| 149 void operator()(T* object) const { | |
| 150 if (object) | |
| 151 object->Destroy(); | |
| 152 } | |
| 153 }; | |
| 154 | |
| 142 } // namespace util | 155 } // namespace util |
| 143 } // namespace drive | 156 } // namespace drive |
| 144 | 157 |
| 145 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_SYSTEM_UTIL_H_ | 158 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_SYSTEM_UTIL_H_ |
| OLD | NEW |