| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_SYNC_FILE_SYSTEM_DRIVE_BACKEND_DRIVE_BACKEND_UTIL_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_DRIVE_BACKEND_UTIL_H_ |
| 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_DRIVE_BACKEND_UTIL_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_DRIVE_BACKEND_UTIL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 bool HasFileAsParent(const FileDetails& details, const std::string& file_id); | 61 bool HasFileAsParent(const FileDetails& details, const std::string& file_id); |
| 62 | 62 |
| 63 std::string GetMimeTypeFromTitle(const base::FilePath& title); | 63 std::string GetMimeTypeFromTitle(const base::FilePath& title); |
| 64 | 64 |
| 65 scoped_ptr<google_apis::ResourceEntry> GetOldestCreatedFolderResource( | 65 scoped_ptr<google_apis::ResourceEntry> GetOldestCreatedFolderResource( |
| 66 ScopedVector<google_apis::ResourceEntry> list); | 66 ScopedVector<google_apis::ResourceEntry> list); |
| 67 | 67 |
| 68 SyncStatusCode GDataErrorCodeToSyncStatusCode( | 68 SyncStatusCode GDataErrorCodeToSyncStatusCode( |
| 69 google_apis::GDataErrorCode error); | 69 google_apis::GDataErrorCode error); |
| 70 | 70 |
| 71 template <typename T> |
| 72 scoped_ptr<T> Clone(const T* obj) { |
| 73 if (!obj) |
| 74 return scoped_ptr<T>(); |
| 75 return scoped_ptr<T>(new T(*obj)); |
| 76 } |
| 77 |
| 71 template <typename Src, typename Dest> | 78 template <typename Src, typename Dest> |
| 72 void AppendContents(const Src& src, Dest* dest) { | 79 void AppendContents(const Src& src, Dest* dest) { |
| 73 dest->insert(dest->end(), src.begin(), src.end()); | 80 dest->insert(dest->end(), src.begin(), src.end()); |
| 74 } | 81 } |
| 75 | 82 |
| 76 template <typename Container> | 83 template <typename Container> |
| 77 const typename Container::mapped_type& LookUpMap( | 84 const typename Container::mapped_type& LookUpMap( |
| 78 const Container& container, | 85 const Container& container, |
| 79 const typename Container::key_type& key, | 86 const typename Container::key_type& key, |
| 80 const typename Container::mapped_type& default_value) { | 87 const typename Container::mapped_type& default_value) { |
| 81 typename Container::const_iterator found = container.find(key); | 88 typename Container::const_iterator found = container.find(key); |
| 82 if (found == container.end()) | 89 if (found == container.end()) |
| 83 return default_value; | 90 return default_value; |
| 84 return found->second; | 91 return found->second; |
| 85 } | 92 } |
| 86 | 93 |
| 87 } // namespace drive_backend | 94 } // namespace drive_backend |
| 88 } // namespace sync_file_system | 95 } // namespace sync_file_system |
| 89 | 96 |
| 90 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_DRIVE_BACKEND_UTIL_H_ | 97 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_DRIVE_BACKEND_UTIL_H_ |
| OLD | NEW |