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 #include "chrome/browser/sync_file_system/drive_backend/sync_engine_initializer.
h" | 5 #include "chrome/browser/sync_file_system/drive_backend/sync_engine_initializer.
h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 SyncStatusCode status) { | 100 SyncStatusCode status) { |
101 *status_out = status; | 101 *status_out = status; |
102 metadata_database_ = initializer->PassMetadataDatabase(); | 102 metadata_database_ = initializer->PassMetadataDatabase(); |
103 } | 103 } |
104 | 104 |
105 SyncStatusCode PopulateDatabase( | 105 SyncStatusCode PopulateDatabase( |
106 const google_apis::FileResource& sync_root, | 106 const google_apis::FileResource& sync_root, |
107 const google_apis::FileResource** app_roots, | 107 const google_apis::FileResource** app_roots, |
108 size_t app_roots_count) { | 108 size_t app_roots_count) { |
109 SyncStatusCode status = SYNC_STATUS_UNKNOWN; | 109 SyncStatusCode status = SYNC_STATUS_UNKNOWN; |
110 scoped_ptr<MetadataDatabase> database; | 110 scoped_ptr<MetadataDatabase> database = MetadataDatabase::Create( |
111 MetadataDatabase::Create( | 111 database_path(), in_memory_env_.get(), &status); |
112 database_path(), | |
113 in_memory_env_.get(), | |
114 CreateResultReceiver(&status, &database)); | |
115 base::RunLoop().RunUntilIdle(); | |
116 if (status != SYNC_STATUS_OK) | 112 if (status != SYNC_STATUS_OK) |
117 return status; | 113 return status; |
118 | 114 |
119 // |app_root_list| must not own the resources here. Be sure to call | 115 // |app_root_list| must not own the resources here. Be sure to call |
120 // weak_clear later. | 116 // weak_clear later. |
121 ScopedVector<google_apis::FileResource> app_root_list; | 117 ScopedVector<google_apis::FileResource> app_root_list; |
122 for (size_t i = 0; i < app_roots_count; ++i) { | 118 for (size_t i = 0; i < app_roots_count; ++i) { |
123 app_root_list.push_back( | 119 app_root_list.push_back( |
124 const_cast<google_apis::FileResource*>(app_roots[i])); | 120 const_cast<google_apis::FileResource*>(app_roots[i])); |
125 } | 121 } |
126 | 122 |
127 status = SYNC_STATUS_UNKNOWN; | 123 status = database->PopulateInitialData( |
128 database->PopulateInitialData(kInitialLargestChangeID, | 124 kInitialLargestChangeID, sync_root, app_root_list); |
129 sync_root, | |
130 app_root_list, | |
131 CreateResultReceiver(&status)); | |
132 base::RunLoop().RunUntilIdle(); | |
133 | 125 |
134 app_root_list.weak_clear(); | 126 app_root_list.weak_clear(); |
135 | 127 return status; |
136 return SYNC_STATUS_OK; | |
137 } | 128 } |
138 | 129 |
139 scoped_ptr<google_apis::FileResource> CreateRemoteFolder( | 130 scoped_ptr<google_apis::FileResource> CreateRemoteFolder( |
140 const std::string& parent_folder_id, | 131 const std::string& parent_folder_id, |
141 const std::string& title) { | 132 const std::string& title) { |
142 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; | 133 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; |
143 scoped_ptr<google_apis::FileResource> entry; | 134 scoped_ptr<google_apis::FileResource> entry; |
144 sync_context_->GetDriveService()->AddNewDirectory( | 135 sync_context_->GetDriveService()->AddNewDirectory( |
145 parent_folder_id, title, | 136 parent_folder_id, title, |
146 drive::DriveServiceInterface::AddNewDirectoryOptions(), | 137 drive::DriveServiceInterface::AddNewDirectoryOptions(), |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 | 340 |
350 EXPECT_EQ(0u, CountTrackersForFile(sync_root->file_id())); | 341 EXPECT_EQ(0u, CountTrackersForFile(sync_root->file_id())); |
351 EXPECT_FALSE(HasNoParent(sync_root->file_id())); | 342 EXPECT_FALSE(HasNoParent(sync_root->file_id())); |
352 | 343 |
353 EXPECT_EQ(1u, CountFileMetadata()); | 344 EXPECT_EQ(1u, CountFileMetadata()); |
354 EXPECT_EQ(1u, CountFileTracker()); | 345 EXPECT_EQ(1u, CountFileTracker()); |
355 } | 346 } |
356 | 347 |
357 } // namespace drive_backend | 348 } // namespace drive_backend |
358 } // namespace sync_file_system | 349 } // namespace sync_file_system |
OLD | NEW |