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 #include "chrome/browser/chromeos/drive/drive_test_util.h" | 5 #include "chrome/browser/chromeos/drive/drive_test_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 | 195 |
196 void CopyResultsFromCloseFileCallbackAndQuit(DriveFileError* out_error, | 196 void CopyResultsFromCloseFileCallbackAndQuit(DriveFileError* out_error, |
197 DriveFileError error) { | 197 DriveFileError error) { |
198 *out_error = error; | 198 *out_error = error; |
199 MessageLoop::current()->Quit(); | 199 MessageLoop::current()->Quit(); |
200 } | 200 } |
201 | 201 |
202 bool LoadChangeFeed(const std::string& relative_path, | 202 bool LoadChangeFeed(const std::string& relative_path, |
203 ChangeListLoader* change_list_loader, | 203 ChangeListLoader* change_list_loader, |
204 bool is_delta_feed, | 204 bool is_delta_feed, |
205 std::string root_resource_id, | |
hidehiko
2013/03/18 07:09:50
const std::string& ?
Haruki Sato
2013/03/18 07:31:17
Done. Thanks!
| |
205 int64 root_feed_changestamp) { | 206 int64 root_feed_changestamp) { |
206 scoped_ptr<Value> document = | 207 scoped_ptr<Value> document = |
207 google_apis::test_util::LoadJSONFile(relative_path); | 208 google_apis::test_util::LoadJSONFile(relative_path); |
208 if (!document.get()) | 209 if (!document.get()) |
209 return false; | 210 return false; |
210 if (document->GetType() != Value::TYPE_DICTIONARY) | 211 if (document->GetType() != Value::TYPE_DICTIONARY) |
211 return false; | 212 return false; |
212 | 213 |
213 scoped_ptr<google_apis::ResourceList> document_feed( | 214 scoped_ptr<google_apis::ResourceList> document_feed( |
214 google_apis::ResourceList::ExtractAndParse(*document)); | 215 google_apis::ResourceList::ExtractAndParse(*document)); |
215 if (!document_feed.get()) | 216 if (!document_feed.get()) |
216 return false; | 217 return false; |
217 | 218 |
218 ScopedVector<google_apis::ResourceList> feed_list; | 219 ScopedVector<google_apis::ResourceList> feed_list; |
219 feed_list.push_back(document_feed.release()); | 220 feed_list.push_back(document_feed.release()); |
220 | 221 |
222 scoped_ptr<google_apis::AboutResource> about_resource( | |
223 new google_apis::AboutResource); | |
224 about_resource->set_largest_change_id(root_feed_changestamp); | |
225 about_resource->set_root_folder_id(root_resource_id); | |
226 | |
221 change_list_loader->UpdateFromFeed( | 227 change_list_loader->UpdateFromFeed( |
228 about_resource.Pass(), | |
222 feed_list, | 229 feed_list, |
223 is_delta_feed, | 230 is_delta_feed, |
224 root_feed_changestamp, | |
225 base::Bind(&base::DoNothing)); | 231 base::Bind(&base::DoNothing)); |
226 // ChangeListLoader::UpdateFromFeed is asynchronous, so wait for it to finish. | 232 // ChangeListLoader::UpdateFromFeed is asynchronous, so wait for it to finish. |
227 google_apis::test_util::RunBlockingPoolTask(); | 233 google_apis::test_util::RunBlockingPoolTask(); |
228 | 234 |
229 return true; | 235 return true; |
230 } | 236 } |
231 | 237 |
232 void DeleteDriveCache(DriveCache* drive_cache) { | 238 void DeleteDriveCache(DriveCache* drive_cache) { |
233 DCHECK(drive_cache); | 239 DCHECK(drive_cache); |
234 drive_cache->Destroy(); | 240 drive_cache->Destroy(); |
235 // The cache destruction requires to post a task to the blocking pool. | 241 // The cache destruction requires to post a task to the blocking pool. |
236 google_apis::test_util::RunBlockingPoolTask(); | 242 google_apis::test_util::RunBlockingPoolTask(); |
237 } | 243 } |
238 | 244 |
239 } // namespace test_util | 245 } // namespace test_util |
240 } // namespace drive | 246 } // namespace drive |
OLD | NEW |