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/gdata/gdata_wapi_feed_loader.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_wapi_feed_loader.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 // Currently the UI update is stopped. Start UI periodic callback. | 616 // Currently the UI update is stopped. Start UI periodic callback. |
617 MessageLoop::current()->PostTask( | 617 MessageLoop::current()->PostTask( |
618 FROM_HERE, | 618 FROM_HERE, |
619 base::Bind(&GDataWapiFeedLoader::OnNotifyDocumentFeedFetched, | 619 base::Bind(&GDataWapiFeedLoader::OnNotifyDocumentFeedFetched, |
620 weak_ptr_factory_.GetWeakPtr(), | 620 weak_ptr_factory_.GetWeakPtr(), |
621 ui_state->weak_ptr_factory.GetWeakPtr())); | 621 ui_state->weak_ptr_factory.GetWeakPtr())); |
622 } | 622 } |
623 ui_state->num_fetched_documents = num_accumulated_entries; | 623 ui_state->num_fetched_documents = num_accumulated_entries; |
624 ui_state->feed_fetching_elapsed_time = base::TimeTicks::Now() - start_time; | 624 ui_state->feed_fetching_elapsed_time = base::TimeTicks::Now() - start_time; |
625 | 625 |
626 // Kick of the remaining part of the feeds. | 626 // Kick off the remaining part of the feeds. |
627 documents_service_->GetDocuments( | 627 documents_service_->GetDocuments( |
628 next_feed_url, | 628 next_feed_url, |
629 params->start_changestamp, | 629 params->start_changestamp, |
630 params->search_query, | 630 params->search_query, |
631 params->directory_resource_id, | 631 params->directory_resource_id, |
632 base::Bind(&GDataWapiFeedLoader::OnGetDocuments, | 632 base::Bind(&GDataWapiFeedLoader::OnGetDocuments, |
633 weak_ptr_factory_.GetWeakPtr(), | 633 weak_ptr_factory_.GetWeakPtr(), |
634 initial_origin, | 634 initial_origin, |
635 callback, | 635 callback, |
636 base::Owned( | 636 base::Owned( |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 // Currently the UI update is stopped. Start UI periodic callback. | 733 // Currently the UI update is stopped. Start UI periodic callback. |
734 MessageLoop::current()->PostTask( | 734 MessageLoop::current()->PostTask( |
735 FROM_HERE, | 735 FROM_HERE, |
736 base::Bind(&GDataWapiFeedLoader::OnNotifyDocumentFeedFetched, | 736 base::Bind(&GDataWapiFeedLoader::OnNotifyDocumentFeedFetched, |
737 weak_ptr_factory_.GetWeakPtr(), | 737 weak_ptr_factory_.GetWeakPtr(), |
738 ui_state->weak_ptr_factory.GetWeakPtr())); | 738 ui_state->weak_ptr_factory.GetWeakPtr())); |
739 } | 739 } |
740 ui_state->num_fetched_documents = num_accumulated_entries; | 740 ui_state->num_fetched_documents = num_accumulated_entries; |
741 ui_state->feed_fetching_elapsed_time = base::TimeTicks::Now() - start_time; | 741 ui_state->feed_fetching_elapsed_time = base::TimeTicks::Now() - start_time; |
742 | 742 |
743 // Kick of the remaining part of the feeds. | 743 // Kick off the remaining part of the feeds. |
744 documents_service_->GetChangelist( | 744 documents_service_->GetChangelist( |
745 current_feed->next_link(), | 745 current_feed->next_link(), |
746 params->start_changestamp, | 746 params->start_changestamp, |
747 base::Bind(&GDataWapiFeedLoader::OnGetChangelist, | 747 base::Bind(&GDataWapiFeedLoader::OnGetChangelist, |
748 weak_ptr_factory_.GetWeakPtr(), | 748 weak_ptr_factory_.GetWeakPtr(), |
749 initial_origin, | 749 initial_origin, |
750 callback, | 750 callback, |
751 base::Owned( | 751 base::Owned( |
752 new GetDocumentsParams( | 752 new GetDocumentsParams( |
753 params->start_changestamp, | 753 params->start_changestamp, |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 // By default, if directory content is not yet initialized, restore content | 887 // By default, if directory content is not yet initialized, restore content |
888 // origin to UNINITIALIZED in case of failure. | 888 // origin to UNINITIALIZED in case of failure. |
889 ContentOrigin initial_origin = UNINITIALIZED; | 889 ContentOrigin initial_origin = UNINITIALIZED; |
890 if (directory_service_->origin() != INITIALIZING) { | 890 if (directory_service_->origin() != INITIALIZING) { |
891 // If directory content is already initialized, restore content origin | 891 // If directory content is already initialized, restore content origin |
892 // to FROM_CACHE in case of failure. | 892 // to FROM_CACHE in case of failure. |
893 initial_origin = FROM_CACHE; | 893 initial_origin = FROM_CACHE; |
894 directory_service_->set_origin(REFRESHING); | 894 directory_service_->set_origin(REFRESHING); |
895 } | 895 } |
896 | 896 |
897 // Kick of the retrieval of the feed from server. If we have previously | 897 // Kick off the retrieval of the feed from server. If we have previously |
898 // |reported| to the original callback, then we just need to refresh the | 898 // |reported| to the original callback, then we just need to refresh the |
899 // content without continuing search upon operation completion. | 899 // content without continuing search upon operation completion. |
900 ReloadFromServerIfNeeded(initial_origin, | 900 ReloadFromServerIfNeeded(initial_origin, |
901 directory_service_->largest_changestamp(), | 901 directory_service_->largest_changestamp(), |
902 callback); | 902 callback); |
903 } | 903 } |
904 | 904 |
905 void GDataWapiFeedLoader::SaveFileSystem() { | 905 void GDataWapiFeedLoader::SaveFileSystem() { |
906 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 906 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
907 | 907 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
952 dir_iter != changed_dirs.end(); ++dir_iter) { | 952 dir_iter != changed_dirs.end(); ++dir_iter) { |
953 FOR_EACH_OBSERVER(Observer, observers_, | 953 FOR_EACH_OBSERVER(Observer, observers_, |
954 OnDirectoryChanged(*dir_iter)); | 954 OnDirectoryChanged(*dir_iter)); |
955 } | 955 } |
956 } | 956 } |
957 | 957 |
958 return error; | 958 return error; |
959 } | 959 } |
960 | 960 |
961 } // namespace gdata | 961 } // namespace gdata |
OLD | NEW |