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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 int64 local_changestamp, | 235 int64 local_changestamp, |
236 const FileOperationCallback& callback) { | 236 const FileOperationCallback& callback) { |
237 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 237 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
238 | 238 |
239 DVLOG(1) << "ReloadFeedFromServerIfNeeded local_changestamp=" | 239 DVLOG(1) << "ReloadFeedFromServerIfNeeded local_changestamp=" |
240 << local_changestamp << ", initial_origin=" << initial_origin; | 240 << local_changestamp << ", initial_origin=" << initial_origin; |
241 | 241 |
242 // First fetch the latest changestamp to see if there were any new changes | 242 // First fetch the latest changestamp to see if there were any new changes |
243 // there at all. | 243 // there at all. |
244 if (gdata::util::IsDriveV2ApiEnabled()) { | 244 if (gdata::util::IsDriveV2ApiEnabled()) { |
245 documents_service_->GetAboutResource( | 245 documents_service_->GetAccountMetadata( |
246 base::Bind(&GDataWapiFeedLoader::OnGetAboutResource, | 246 base::Bind(&GDataWapiFeedLoader::OnGetAboutResource, |
247 weak_ptr_factory_.GetWeakPtr(), | 247 weak_ptr_factory_.GetWeakPtr(), |
248 initial_origin, | 248 initial_origin, |
249 local_changestamp, | 249 local_changestamp, |
250 callback)); | 250 callback)); |
251 // Drive v2 needs a separate application list fetch operation. | 251 // Drive v2 needs a separate application list fetch operation. |
252 // TODO(kochi): Application list rarely changes and do not necessarily | 252 // TODO(kochi): Application list rarely changes and do not necessarily |
253 // refresed as often as files. | 253 // refresed as often as files. |
254 documents_service_->GetApplicationList( | 254 documents_service_->GetApplicationInfo( |
255 base::Bind(&GDataWapiFeedLoader::OnGetApplicationList, | 255 base::Bind(&GDataWapiFeedLoader::OnGetApplicationList, |
256 weak_ptr_factory_.GetWeakPtr())); | 256 weak_ptr_factory_.GetWeakPtr())); |
257 return; | 257 return; |
258 } | 258 } |
259 | 259 |
260 documents_service_->GetAccountMetadata( | 260 documents_service_->GetAccountMetadata( |
261 base::Bind(&GDataWapiFeedLoader::OnGetAccountMetadata, | 261 base::Bind(&GDataWapiFeedLoader::OnGetAccountMetadata, |
262 weak_ptr_factory_.GetWeakPtr(), | 262 weak_ptr_factory_.GetWeakPtr(), |
263 initial_origin, | 263 initial_origin, |
264 local_changestamp, | 264 local_changestamp, |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 464 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
465 DCHECK(!feed_load_callback.is_null()); | 465 DCHECK(!feed_load_callback.is_null()); |
466 | 466 |
467 // |feed_list| will contain the list of all collected feed updates that | 467 // |feed_list| will contain the list of all collected feed updates that |
468 // we will receive through calls of DocumentsService::GetDocuments(). | 468 // we will receive through calls of DocumentsService::GetDocuments(). |
469 scoped_ptr<std::vector<DocumentFeed*> > feed_list( | 469 scoped_ptr<std::vector<DocumentFeed*> > feed_list( |
470 new std::vector<DocumentFeed*>); | 470 new std::vector<DocumentFeed*>); |
471 const base::TimeTicks start_time = base::TimeTicks::Now(); | 471 const base::TimeTicks start_time = base::TimeTicks::Now(); |
472 | 472 |
473 if (gdata::util::IsDriveV2ApiEnabled()) { | 473 if (gdata::util::IsDriveV2ApiEnabled()) { |
474 documents_service_->GetChangelist( | 474 documents_service_->GetDocuments( |
475 feed_to_load, | 475 feed_to_load, |
476 start_changestamp, | 476 start_changestamp, |
| 477 std::string(), |
| 478 std::string(), |
477 base::Bind(&GDataWapiFeedLoader::OnGetChangelist, | 479 base::Bind(&GDataWapiFeedLoader::OnGetChangelist, |
478 weak_ptr_factory_.GetWeakPtr(), | 480 weak_ptr_factory_.GetWeakPtr(), |
479 initial_origin, | 481 initial_origin, |
480 feed_load_callback, | 482 feed_load_callback, |
481 base::Owned(new GetDocumentsParams( | 483 base::Owned(new GetDocumentsParams( |
482 start_changestamp, | 484 start_changestamp, |
483 root_feed_changestamp, | 485 root_feed_changestamp, |
484 feed_list.release(), | 486 feed_list.release(), |
485 should_fetch_multiple_feeds, | 487 should_fetch_multiple_feeds, |
486 search_query, | 488 search_query, |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 MessageLoop::current()->PostTask( | 736 MessageLoop::current()->PostTask( |
735 FROM_HERE, | 737 FROM_HERE, |
736 base::Bind(&GDataWapiFeedLoader::OnNotifyDocumentFeedFetched, | 738 base::Bind(&GDataWapiFeedLoader::OnNotifyDocumentFeedFetched, |
737 weak_ptr_factory_.GetWeakPtr(), | 739 weak_ptr_factory_.GetWeakPtr(), |
738 ui_state->weak_ptr_factory.GetWeakPtr())); | 740 ui_state->weak_ptr_factory.GetWeakPtr())); |
739 } | 741 } |
740 ui_state->num_fetched_documents = num_accumulated_entries; | 742 ui_state->num_fetched_documents = num_accumulated_entries; |
741 ui_state->feed_fetching_elapsed_time = base::TimeTicks::Now() - start_time; | 743 ui_state->feed_fetching_elapsed_time = base::TimeTicks::Now() - start_time; |
742 | 744 |
743 // Kick off the remaining part of the feeds. | 745 // Kick off the remaining part of the feeds. |
744 documents_service_->GetChangelist( | 746 documents_service_->GetDocuments( |
745 current_feed->next_link(), | 747 current_feed->next_link(), |
746 params->start_changestamp, | 748 params->start_changestamp, |
| 749 std::string(), |
| 750 std::string(), |
747 base::Bind(&GDataWapiFeedLoader::OnGetChangelist, | 751 base::Bind(&GDataWapiFeedLoader::OnGetChangelist, |
748 weak_ptr_factory_.GetWeakPtr(), | 752 weak_ptr_factory_.GetWeakPtr(), |
749 initial_origin, | 753 initial_origin, |
750 callback, | 754 callback, |
751 base::Owned( | 755 base::Owned( |
752 new GetDocumentsParams( | 756 new GetDocumentsParams( |
753 params->start_changestamp, | 757 params->start_changestamp, |
754 params->root_feed_changestamp, | 758 params->root_feed_changestamp, |
755 params->feed_list.release(), | 759 params->feed_list.release(), |
756 params->should_fetch_multiple_feeds, | 760 params->should_fetch_multiple_feeds, |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
952 dir_iter != changed_dirs.end(); ++dir_iter) { | 956 dir_iter != changed_dirs.end(); ++dir_iter) { |
953 FOR_EACH_OBSERVER(Observer, observers_, | 957 FOR_EACH_OBSERVER(Observer, observers_, |
954 OnDirectoryChanged(*dir_iter)); | 958 OnDirectoryChanged(*dir_iter)); |
955 } | 959 } |
956 } | 960 } |
957 | 961 |
958 return error; | 962 return error; |
959 } | 963 } |
960 | 964 |
961 } // namespace gdata | 965 } // namespace gdata |
OLD | NEW |