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" | 10 #include "base/bind.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
14 #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" |
15 #include "chrome/browser/sync_file_system/sync_status_code.h" | 15 #include "chrome/browser/sync_file_system/sync_status_code.h" |
16 #include "google_apis/drive/gdata_errorcode.h" | 16 #include "google_apis/drive/gdata_errorcode.h" |
17 #include "webkit/common/blob/scoped_file.h" | 17 #include "webkit/common/blob/scoped_file.h" |
18 | 18 |
19 namespace google_apis { | 19 namespace google_apis { |
20 class ChangeResource; | 20 class ChangeResource; |
21 class FileResource; | 21 class FileResource; |
22 class ResourceEntry; | 22 class ResourceEntry; |
23 } | 23 } |
24 | 24 |
25 namespace leveldb { | 25 namespace leveldb { |
| 26 class DB; |
26 class WriteBatch; | 27 class WriteBatch; |
27 } | 28 } |
28 | 29 |
29 namespace sync_file_system { | 30 namespace sync_file_system { |
30 namespace drive_backend { | 31 namespace drive_backend { |
31 | 32 |
32 void PutServiceMetadataToBatch(const ServiceMetadata& service_metadata, | 33 void PutServiceMetadataToBatch(const ServiceMetadata& service_metadata, |
33 leveldb::WriteBatch* batch); | 34 leveldb::WriteBatch* batch); |
34 void PutFileMetadataToBatch(const FileMetadata& file, | 35 void PutFileMetadataToBatch(const FileMetadata& file, |
35 leveldb::WriteBatch* batch); | 36 leveldb::WriteBatch* batch); |
(...skipping 12 matching lines...) Expand all Loading... |
48 std::string GetTrackerTitle(const FileTracker& tracker); | 49 std::string GetTrackerTitle(const FileTracker& tracker); |
49 | 50 |
50 SyncStatusCode GDataErrorCodeToSyncStatusCode( | 51 SyncStatusCode GDataErrorCodeToSyncStatusCode( |
51 google_apis::GDataErrorCode error); | 52 google_apis::GDataErrorCode error); |
52 | 53 |
53 // Returns true if |str| starts with |prefix|, and removes |prefix| from |str|. | 54 // Returns true if |str| starts with |prefix|, and removes |prefix| from |str|. |
54 // If |out| is not NULL, the result is stored in it. | 55 // If |out| is not NULL, the result is stored in it. |
55 bool RemovePrefix(const std::string& str, const std::string& prefix, | 56 bool RemovePrefix(const std::string& str, const std::string& prefix, |
56 std::string* out); | 57 std::string* out); |
57 | 58 |
| 59 scoped_ptr<ServiceMetadata> InitializeServiceMetadata(leveldb::DB* db); |
| 60 |
58 template <typename Src, typename Dest> | 61 template <typename Src, typename Dest> |
59 void AppendContents(const Src& src, Dest* dest) { | 62 void AppendContents(const Src& src, Dest* dest) { |
60 dest->insert(dest->end(), src.begin(), src.end()); | 63 dest->insert(dest->end(), src.begin(), src.end()); |
61 } | 64 } |
62 | 65 |
63 template <typename Container> | 66 template <typename Container> |
64 const typename Container::mapped_type& LookUpMap( | 67 const typename Container::mapped_type& LookUpMap( |
65 const Container& container, | 68 const Container& container, |
66 const typename Container::key_type& key, | 69 const typename Container::key_type& key, |
67 const typename Container::mapped_type& default_value) { | 70 const typename Container::mapped_type& default_value) { |
(...skipping 13 matching lines...) Expand all Loading... |
81 base::Callback<R()> CreateComposedFunction( | 84 base::Callback<R()> CreateComposedFunction( |
82 const base::Callback<T()>& g, | 85 const base::Callback<T()>& g, |
83 const base::Callback<R(S)>& f) { | 86 const base::Callback<R(S)>& f) { |
84 return base::Bind(&ComposeFunction<R, S, T>, g, f); | 87 return base::Bind(&ComposeFunction<R, S, T>, g, f); |
85 } | 88 } |
86 | 89 |
87 } // namespace drive_backend | 90 } // namespace drive_backend |
88 } // namespace sync_file_system | 91 } // namespace sync_file_system |
89 | 92 |
90 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_DRIVE_BACKEND_UTIL_H_ | 93 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_DRIVE_BACKEND_UTIL_H_ |
OLD | NEW |