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_feed_loader.h" | 5 #include "chrome/browser/chromeos/drive/drive_feed_loader.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 } | 303 } |
304 | 304 |
305 scoped_ptr<google_apis::AccountMetadataFeed> account_metadata; | 305 scoped_ptr<google_apis::AccountMetadataFeed> account_metadata; |
306 if (feed_data.get()) { | 306 if (feed_data.get()) { |
307 account_metadata = google_apis::AccountMetadataFeed::CreateFrom(*feed_data); | 307 account_metadata = google_apis::AccountMetadataFeed::CreateFrom(*feed_data); |
308 #ifndef NDEBUG | 308 #ifndef NDEBUG |
309 // Save account metadata feed for analysis. | 309 // Save account metadata feed for analysis. |
310 const FilePath path = | 310 const FilePath path = |
311 cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_META).Append( | 311 cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_META).Append( |
312 kAccountMetadataFile); | 312 kAccountMetadataFile); |
313 google_apis::util::PostBlockingPoolSequencedTask( | 313 blocking_task_runner_->PostTask( |
314 FROM_HERE, | 314 FROM_HERE, |
315 blocking_task_runner_, | |
316 base::Bind(&SaveFeedOnBlockingPoolForDebugging, | 315 base::Bind(&SaveFeedOnBlockingPoolForDebugging, |
317 path, base::Passed(&feed_data))); | 316 path, base::Passed(&feed_data))); |
318 #endif | 317 #endif |
319 } | 318 } |
320 | 319 |
321 if (!account_metadata.get()) { | 320 if (!account_metadata.get()) { |
322 LoadFromServer(params.Pass()); | 321 LoadFromServer(params.Pass()); |
323 return; | 322 return; |
324 } | 323 } |
325 | 324 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 error = DRIVE_FILE_ERROR_FAILED; | 506 error = DRIVE_FILE_ERROR_FAILED; |
508 } | 507 } |
509 | 508 |
510 if (error != DRIVE_FILE_OK) { | 509 if (error != DRIVE_FILE_OK) { |
511 RunFeedLoadCallback(params.Pass(), error); | 510 RunFeedLoadCallback(params.Pass(), error); |
512 return; | 511 return; |
513 } | 512 } |
514 | 513 |
515 scoped_ptr<google_apis::DocumentFeed>* current_feed = | 514 scoped_ptr<google_apis::DocumentFeed>* current_feed = |
516 new scoped_ptr<google_apis::DocumentFeed>; | 515 new scoped_ptr<google_apis::DocumentFeed>; |
517 google_apis::util::PostBlockingPoolSequencedTaskAndReply( | 516 blocking_task_runner_->PostTaskAndReply( |
518 FROM_HERE, | 517 FROM_HERE, |
519 blocking_task_runner_, | |
520 base::Bind(&ParseFeedOnBlockingPool, | 518 base::Bind(&ParseFeedOnBlockingPool, |
521 base::Passed(&data), | 519 base::Passed(&data), |
522 current_feed), | 520 current_feed), |
523 base::Bind(&DriveFeedLoader::OnParseFeed, | 521 base::Bind(&DriveFeedLoader::OnParseFeed, |
524 weak_ptr_factory_.GetWeakPtr(), | 522 weak_ptr_factory_.GetWeakPtr(), |
525 base::Passed(¶ms), | 523 base::Passed(¶ms), |
526 start_time, | 524 start_time, |
527 base::Owned(current_feed))); | 525 base::Owned(current_feed))); |
528 } | 526 } |
529 | 527 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 RunFeedLoadCallback(params.Pass(), DRIVE_FILE_ERROR_FAILED); | 628 RunFeedLoadCallback(params.Pass(), DRIVE_FILE_ERROR_FAILED); |
631 return; | 629 return; |
632 } | 630 } |
633 const bool has_next_feed = !current_feed->next_page_token().empty(); | 631 const bool has_next_feed = !current_feed->next_page_token().empty(); |
634 | 632 |
635 #ifndef NDEBUG | 633 #ifndef NDEBUG |
636 // Save initial root feed for analysis. | 634 // Save initial root feed for analysis. |
637 std::string file_name = | 635 std::string file_name = |
638 base::StringPrintf("DEBUG_changelist_%" PRId64 ".json", | 636 base::StringPrintf("DEBUG_changelist_%" PRId64 ".json", |
639 params->start_changestamp); | 637 params->start_changestamp); |
640 google_apis::util::PostBlockingPoolSequencedTask( | 638 blocking_task_runner_->PostTask( |
641 FROM_HERE, | 639 FROM_HERE, |
642 blocking_task_runner_, | |
643 base::Bind(&SaveFeedOnBlockingPoolForDebugging, | 640 base::Bind(&SaveFeedOnBlockingPoolForDebugging, |
644 cache_->GetCacheDirectoryPath( | 641 cache_->GetCacheDirectoryPath( |
645 DriveCache::CACHE_TYPE_META).Append(file_name), | 642 DriveCache::CACHE_TYPE_META).Append(file_name), |
646 base::Passed(&data))); | 643 base::Passed(&data))); |
647 #endif | 644 #endif |
648 | 645 |
649 // Add the current feed to the list of collected feeds for this directory. | 646 // Add the current feed to the list of collected feeds for this directory. |
650 scoped_ptr<google_apis::DocumentFeed> feed = | 647 scoped_ptr<google_apis::DocumentFeed> feed = |
651 google_apis::DocumentFeed::CreateFromChangeList(*current_feed); | 648 google_apis::DocumentFeed::CreateFromChangeList(*current_feed); |
652 params->feed_list.push_back(feed.release()); | 649 params->feed_list.push_back(feed.release()); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 if (UseLevelDB()) { | 821 if (UseLevelDB()) { |
825 resource_metadata_->SaveToDB(); | 822 resource_metadata_->SaveToDB(); |
826 } else { | 823 } else { |
827 const FilePath path = | 824 const FilePath path = |
828 cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_META).Append( | 825 cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_META).Append( |
829 kFilesystemProtoFile); | 826 kFilesystemProtoFile); |
830 scoped_ptr<std::string> serialized_proto(new std::string()); | 827 scoped_ptr<std::string> serialized_proto(new std::string()); |
831 resource_metadata_->SerializeToString(serialized_proto.get()); | 828 resource_metadata_->SerializeToString(serialized_proto.get()); |
832 resource_metadata_->set_last_serialized(base::Time::Now()); | 829 resource_metadata_->set_last_serialized(base::Time::Now()); |
833 resource_metadata_->set_serialized_size(serialized_proto->size()); | 830 resource_metadata_->set_serialized_size(serialized_proto->size()); |
834 google_apis::util::PostBlockingPoolSequencedTask( | 831 blocking_task_runner_->PostTask( |
835 FROM_HERE, | 832 FROM_HERE, |
836 blocking_task_runner_, | |
837 base::Bind(&SaveProtoOnBlockingPool, path, | 833 base::Bind(&SaveProtoOnBlockingPool, path, |
838 base::Passed(serialized_proto.Pass()))); | 834 base::Passed(serialized_proto.Pass()))); |
839 } | 835 } |
840 } | 836 } |
841 | 837 |
842 void DriveFeedLoader::UpdateFromFeed( | 838 void DriveFeedLoader::UpdateFromFeed( |
843 const ScopedVector<google_apis::DocumentFeed>& feed_list, | 839 const ScopedVector<google_apis::DocumentFeed>& feed_list, |
844 int64 start_changestamp, | 840 int64 start_changestamp, |
845 int64 root_feed_changestamp, | 841 int64 root_feed_changestamp, |
846 const std::string& root_resource_id, | 842 const std::string& root_resource_id, |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 | 904 |
909 // Run the callback now that the filesystem is ready. | 905 // Run the callback now that the filesystem is ready. |
910 load_finished_callback.Run(DRIVE_FILE_OK); | 906 load_finished_callback.Run(DRIVE_FILE_OK); |
911 | 907 |
912 FOR_EACH_OBSERVER(DriveFeedLoaderObserver, | 908 FOR_EACH_OBSERVER(DriveFeedLoaderObserver, |
913 observers_, | 909 observers_, |
914 OnFeedFromServerLoaded()); | 910 OnFeedFromServerLoaded()); |
915 } | 911 } |
916 | 912 |
917 } // namespace drive | 913 } // namespace drive |
OLD | NEW |