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/bind.h" |
| 11 #include "base/callback.h" |
10 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
12 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h" | 14 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h" |
13 #include "chrome/browser/sync_file_system/sync_status_code.h" | 15 #include "chrome/browser/sync_file_system/sync_status_code.h" |
14 #include "google_apis/drive/gdata_errorcode.h" | 16 #include "google_apis/drive/gdata_errorcode.h" |
15 #include "webkit/common/blob/scoped_file.h" | 17 #include "webkit/common/blob/scoped_file.h" |
16 | 18 |
17 namespace google_apis { | 19 namespace google_apis { |
18 class ChangeResource; | 20 class ChangeResource; |
19 class FileResource; | 21 class FileResource; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 const typename Container::mapped_type& LookUpMap( | 78 const typename Container::mapped_type& LookUpMap( |
77 const Container& container, | 79 const Container& container, |
78 const typename Container::key_type& key, | 80 const typename Container::key_type& key, |
79 const typename Container::mapped_type& default_value) { | 81 const typename Container::mapped_type& default_value) { |
80 typename Container::const_iterator found = container.find(key); | 82 typename Container::const_iterator found = container.find(key); |
81 if (found == container.end()) | 83 if (found == container.end()) |
82 return default_value; | 84 return default_value; |
83 return found->second; | 85 return found->second; |
84 } | 86 } |
85 | 87 |
| 88 template <typename R, typename S, typename T> |
| 89 R ComposeFunction(const base::Callback<T()>& g, |
| 90 const base::Callback<R(S)>& f) { |
| 91 return f.Run(g.Run()); |
| 92 } |
| 93 |
| 94 template <typename R, typename S, typename T> |
| 95 base::Callback<R()> CreateComposedFunction( |
| 96 const base::Callback<T()>& g, |
| 97 const base::Callback<R(S)>& f) { |
| 98 return base::Bind(&ComposeFunction<R, S, T>, g, f); |
| 99 } |
| 100 |
86 } // namespace drive_backend | 101 } // namespace drive_backend |
87 } // namespace sync_file_system | 102 } // namespace sync_file_system |
88 | 103 |
89 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_DRIVE_BACKEND_UTIL_H_ | 104 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_DRIVE_BACKEND_UTIL_H_ |
OLD | NEW |