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" |
11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/stringprintf.h" | 14 #include "base/stringprintf.h" |
15 #include "base/threading/sequenced_worker_pool.h" | 15 #include "base/threading/sequenced_worker_pool.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "chrome/browser/chromeos/gdata/documents_service_interface.h" |
| 18 #include "chrome/browser/chromeos/gdata/drive_api_parser.h" |
17 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h" | 19 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h" |
18 #include "chrome/browser/chromeos/gdata/drive_api_parser.h" | |
19 #include "chrome/browser/chromeos/gdata/gdata_cache.h" | 20 #include "chrome/browser/chromeos/gdata/gdata_cache.h" |
20 #include "chrome/browser/chromeos/gdata/gdata_documents_service.h" | |
21 #include "chrome/browser/chromeos/gdata/gdata_util.h" | 21 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
22 #include "chrome/browser/chromeos/gdata/gdata_wapi_feed_processor.h" | 22 #include "chrome/browser/chromeos/gdata/gdata_wapi_feed_processor.h" |
23 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
24 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
25 | 25 |
26 using content::BrowserThread; | 26 using content::BrowserThread; |
27 | 27 |
28 namespace gdata { | 28 namespace gdata { |
29 | 29 |
30 namespace { | 30 namespace { |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 int64 local_changestamp, | 266 int64 local_changestamp, |
267 const FileOperationCallback& callback) { | 267 const FileOperationCallback& callback) { |
268 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 268 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
269 | 269 |
270 DVLOG(1) << "ReloadFeedFromServerIfNeeded local_changestamp=" | 270 DVLOG(1) << "ReloadFeedFromServerIfNeeded local_changestamp=" |
271 << local_changestamp << ", initial_origin=" << initial_origin; | 271 << local_changestamp << ", initial_origin=" << initial_origin; |
272 | 272 |
273 // First fetch the latest changestamp to see if there were any new changes | 273 // First fetch the latest changestamp to see if there were any new changes |
274 // there at all. | 274 // there at all. |
275 if (gdata::util::IsDriveV2ApiEnabled()) { | 275 if (gdata::util::IsDriveV2ApiEnabled()) { |
276 documents_service_->GetAboutResource( | 276 documents_service_->GetAccountMetadata( |
277 base::Bind(&GDataWapiFeedLoader::OnGetAboutResource, | 277 base::Bind(&GDataWapiFeedLoader::OnGetAboutResource, |
278 weak_ptr_factory_.GetWeakPtr(), | 278 weak_ptr_factory_.GetWeakPtr(), |
279 initial_origin, | 279 initial_origin, |
280 local_changestamp, | 280 local_changestamp, |
281 callback)); | 281 callback)); |
282 // Drive v2 needs a separate application list fetch operation. | 282 // Drive v2 needs a separate application list fetch operation. |
283 // TODO(kochi): Application list rarely changes and do not necessarily | 283 // TODO(kochi): Application list rarely changes and do not necessarily |
284 // refresed as often as files. | 284 // refresed as often as files. |
285 documents_service_->GetApplicationList( | 285 documents_service_->GetApplicationInfo( |
286 base::Bind(&GDataWapiFeedLoader::OnGetApplicationList, | 286 base::Bind(&GDataWapiFeedLoader::OnGetApplicationList, |
287 weak_ptr_factory_.GetWeakPtr())); | 287 weak_ptr_factory_.GetWeakPtr())); |
288 return; | 288 return; |
289 } | 289 } |
290 | 290 |
291 documents_service_->GetAccountMetadata( | 291 documents_service_->GetAccountMetadata( |
292 base::Bind(&GDataWapiFeedLoader::OnGetAccountMetadata, | 292 base::Bind(&GDataWapiFeedLoader::OnGetAccountMetadata, |
293 weak_ptr_factory_.GetWeakPtr(), | 293 weak_ptr_factory_.GetWeakPtr(), |
294 initial_origin, | 294 initial_origin, |
295 local_changestamp, | 295 local_changestamp, |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 void GDataWapiFeedLoader::LoadFromServer(const LoadFeedParams& params) { | 449 void GDataWapiFeedLoader::LoadFromServer(const LoadFeedParams& params) { |
450 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 450 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
451 | 451 |
452 // |feed_list| will contain the list of all collected feed updates that | 452 // |feed_list| will contain the list of all collected feed updates that |
453 // we will receive through calls of DocumentsService::GetDocuments(). | 453 // we will receive through calls of DocumentsService::GetDocuments(). |
454 scoped_ptr<std::vector<DocumentFeed*> > feed_list( | 454 scoped_ptr<std::vector<DocumentFeed*> > feed_list( |
455 new std::vector<DocumentFeed*>); | 455 new std::vector<DocumentFeed*>); |
456 const base::TimeTicks start_time = base::TimeTicks::Now(); | 456 const base::TimeTicks start_time = base::TimeTicks::Now(); |
457 | 457 |
458 if (gdata::util::IsDriveV2ApiEnabled()) { | 458 if (gdata::util::IsDriveV2ApiEnabled()) { |
459 documents_service_->GetChangelist( | 459 documents_service_->GetDocuments( |
460 params.feed_to_load, | 460 params.feed_to_load, |
461 params.start_changestamp, | 461 params.start_changestamp, |
| 462 std::string(), // No search query. |
| 463 std::string(), // No directory resource ID. |
462 base::Bind(&GDataWapiFeedLoader::OnGetChangelist, | 464 base::Bind(&GDataWapiFeedLoader::OnGetChangelist, |
463 weak_ptr_factory_.GetWeakPtr(), | 465 weak_ptr_factory_.GetWeakPtr(), |
464 params.initial_origin, | 466 params.initial_origin, |
465 params.feed_load_callback, | 467 params.feed_load_callback, |
466 base::Owned(new GetDocumentsParams( | 468 base::Owned(new GetDocumentsParams( |
467 params.start_changestamp, | 469 params.start_changestamp, |
468 params.root_feed_changestamp, | 470 params.root_feed_changestamp, |
469 feed_list.release(), | 471 feed_list.release(), |
470 params.search_query, | 472 params.search_query, |
471 params.directory_resource_id, | 473 params.directory_resource_id, |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 MessageLoop::current()->PostTask( | 738 MessageLoop::current()->PostTask( |
737 FROM_HERE, | 739 FROM_HERE, |
738 base::Bind(&GDataWapiFeedLoader::OnNotifyDocumentFeedFetched, | 740 base::Bind(&GDataWapiFeedLoader::OnNotifyDocumentFeedFetched, |
739 weak_ptr_factory_.GetWeakPtr(), | 741 weak_ptr_factory_.GetWeakPtr(), |
740 ui_state->weak_ptr_factory.GetWeakPtr())); | 742 ui_state->weak_ptr_factory.GetWeakPtr())); |
741 } | 743 } |
742 ui_state->num_fetched_documents = num_accumulated_entries; | 744 ui_state->num_fetched_documents = num_accumulated_entries; |
743 ui_state->feed_fetching_elapsed_time = base::TimeTicks::Now() - start_time; | 745 ui_state->feed_fetching_elapsed_time = base::TimeTicks::Now() - start_time; |
744 | 746 |
745 // Kick off the remaining part of the feeds. | 747 // Kick off the remaining part of the feeds. |
746 documents_service_->GetChangelist( | 748 documents_service_->GetDocuments( |
747 current_feed->next_link(), | 749 current_feed->next_link(), |
748 params->start_changestamp, | 750 params->start_changestamp, |
| 751 std::string(), // No search query. |
| 752 std::string(), // No directory resource ID. |
749 base::Bind(&GDataWapiFeedLoader::OnGetChangelist, | 753 base::Bind(&GDataWapiFeedLoader::OnGetChangelist, |
750 weak_ptr_factory_.GetWeakPtr(), | 754 weak_ptr_factory_.GetWeakPtr(), |
751 initial_origin, | 755 initial_origin, |
752 callback, | 756 callback, |
753 base::Owned( | 757 base::Owned( |
754 new GetDocumentsParams( | 758 new GetDocumentsParams( |
755 params->start_changestamp, | 759 params->start_changestamp, |
756 params->root_feed_changestamp, | 760 params->root_feed_changestamp, |
757 params->feed_list.release(), | 761 params->feed_list.release(), |
758 params->search_query, | 762 params->search_query, |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 dir_iter != changed_dirs.end(); ++dir_iter) { | 957 dir_iter != changed_dirs.end(); ++dir_iter) { |
954 FOR_EACH_OBSERVER(Observer, observers_, | 958 FOR_EACH_OBSERVER(Observer, observers_, |
955 OnDirectoryChanged(*dir_iter)); | 959 OnDirectoryChanged(*dir_iter)); |
956 } | 960 } |
957 } | 961 } |
958 | 962 |
959 return error; | 963 return error; |
960 } | 964 } |
961 | 965 |
962 } // namespace gdata | 966 } // namespace gdata |
OLD | NEW |