Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_wapi_feed_loader.cc

Issue 10828385: Rename DocumentsServiceInterface to DriveServiceInterface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unnecessary includes. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_api_parser.h"
18 #include "chrome/browser/chromeos/gdata/drive_service_interface.h"
19 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h" 19 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h"
20 #include "chrome/browser/chromeos/gdata/gdata_cache.h" 20 #include "chrome/browser/chromeos/gdata/gdata_cache.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 {
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 base::TimeTicks start_time; 229 base::TimeTicks start_time;
230 230
231 // Time elapsed since the feed fetching was started. 231 // Time elapsed since the feed fetching was started.
232 base::TimeDelta feed_fetching_elapsed_time; 232 base::TimeDelta feed_fetching_elapsed_time;
233 233
234 base::WeakPtrFactory<GetDocumentsUiState> weak_ptr_factory; 234 base::WeakPtrFactory<GetDocumentsUiState> weak_ptr_factory;
235 }; 235 };
236 236
237 GDataWapiFeedLoader::GDataWapiFeedLoader( 237 GDataWapiFeedLoader::GDataWapiFeedLoader(
238 GDataDirectoryService* directory_service, 238 GDataDirectoryService* directory_service,
239 DocumentsServiceInterface* documents_service, 239 DriveServiceInterface* drive_service,
240 DriveWebAppsRegistryInterface* webapps_registry, 240 DriveWebAppsRegistryInterface* webapps_registry,
241 GDataCache* cache, 241 GDataCache* cache,
242 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) 242 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner)
243 : directory_service_(directory_service), 243 : directory_service_(directory_service),
244 documents_service_(documents_service), 244 drive_service_(drive_service),
245 webapps_registry_(webapps_registry), 245 webapps_registry_(webapps_registry),
246 cache_(cache), 246 cache_(cache),
247 blocking_task_runner_(blocking_task_runner), 247 blocking_task_runner_(blocking_task_runner),
248 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 248 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
249 } 249 }
250 250
251 GDataWapiFeedLoader::~GDataWapiFeedLoader() { 251 GDataWapiFeedLoader::~GDataWapiFeedLoader() {
252 } 252 }
253 253
254 void GDataWapiFeedLoader::AddObserver(Observer* observer) { 254 void GDataWapiFeedLoader::AddObserver(Observer* observer) {
(...skipping 11 matching lines...) Expand all
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_->GetAccountMetadata( 276 drive_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_->GetApplicationInfo( 285 drive_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 drive_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,
296 callback)); 296 callback));
297 } 297 }
298 298
299 void GDataWapiFeedLoader::OnGetAccountMetadata( 299 void GDataWapiFeedLoader::OnGetAccountMetadata(
300 ContentOrigin initial_origin, 300 ContentOrigin initial_origin,
301 int64 local_changestamp, 301 int64 local_changestamp,
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 VLOG(1) << "applist get success"; 443 VLOG(1) << "applist get success";
444 webapps_registry_->UpdateFromApplicationList(*applist.get()); 444 webapps_registry_->UpdateFromApplicationList(*applist.get());
445 } 445 }
446 } 446 }
447 } 447 }
448 448
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 GDataWapiService::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_->GetDocuments( 459 drive_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. 462 std::string(), // No search query.
463 std::string(), // No directory resource ID. 463 std::string(), // No directory resource ID.
464 base::Bind(&GDataWapiFeedLoader::OnGetChangelist, 464 base::Bind(&GDataWapiFeedLoader::OnGetChangelist,
465 weak_ptr_factory_.GetWeakPtr(), 465 weak_ptr_factory_.GetWeakPtr(),
466 params.initial_origin, 466 params.initial_origin,
467 params.feed_load_callback, 467 params.feed_load_callback,
468 base::Owned(new GetDocumentsParams( 468 base::Owned(new GetDocumentsParams(
469 params.start_changestamp, 469 params.start_changestamp,
470 params.root_feed_changestamp, 470 params.root_feed_changestamp,
471 feed_list.release(), 471 feed_list.release(),
472 params.search_query, 472 params.search_query,
473 params.directory_resource_id, 473 params.directory_resource_id,
474 params.load_finished_callback, 474 params.load_finished_callback,
475 NULL)), 475 NULL)),
476 start_time)); 476 start_time));
477 return; 477 return;
478 } 478 }
479 479
480 documents_service_->GetDocuments( 480 drive_service_->GetDocuments(
481 params.feed_to_load, 481 params.feed_to_load,
482 params.start_changestamp, 482 params.start_changestamp,
483 params.search_query, 483 params.search_query,
484 params.directory_resource_id, 484 params.directory_resource_id,
485 base::Bind(&GDataWapiFeedLoader::OnGetDocuments, 485 base::Bind(&GDataWapiFeedLoader::OnGetDocuments,
486 weak_ptr_factory_.GetWeakPtr(), 486 weak_ptr_factory_.GetWeakPtr(),
487 params.initial_origin, 487 params.initial_origin,
488 params.feed_load_callback, 488 params.feed_load_callback,
489 base::Owned( 489 base::Owned(
490 new GetDocumentsParams(params.start_changestamp, 490 new GetDocumentsParams(params.start_changestamp,
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 MessageLoop::current()->PostTask( 622 MessageLoop::current()->PostTask(
623 FROM_HERE, 623 FROM_HERE,
624 base::Bind(&GDataWapiFeedLoader::OnNotifyDocumentFeedFetched, 624 base::Bind(&GDataWapiFeedLoader::OnNotifyDocumentFeedFetched,
625 weak_ptr_factory_.GetWeakPtr(), 625 weak_ptr_factory_.GetWeakPtr(),
626 ui_state->weak_ptr_factory.GetWeakPtr())); 626 ui_state->weak_ptr_factory.GetWeakPtr()));
627 } 627 }
628 ui_state->num_fetched_documents = num_accumulated_entries; 628 ui_state->num_fetched_documents = num_accumulated_entries;
629 ui_state->feed_fetching_elapsed_time = base::TimeTicks::Now() - start_time; 629 ui_state->feed_fetching_elapsed_time = base::TimeTicks::Now() - start_time;
630 630
631 // Kick off the remaining part of the feeds. 631 // Kick off the remaining part of the feeds.
632 documents_service_->GetDocuments( 632 drive_service_->GetDocuments(
633 next_feed_url, 633 next_feed_url,
634 params->start_changestamp, 634 params->start_changestamp,
635 params->search_query, 635 params->search_query,
636 params->directory_resource_id, 636 params->directory_resource_id,
637 base::Bind(&GDataWapiFeedLoader::OnGetDocuments, 637 base::Bind(&GDataWapiFeedLoader::OnGetDocuments,
638 weak_ptr_factory_.GetWeakPtr(), 638 weak_ptr_factory_.GetWeakPtr(),
639 initial_origin, 639 initial_origin,
640 callback, 640 callback,
641 base::Owned( 641 base::Owned(
642 new GetDocumentsParams( 642 new GetDocumentsParams(
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 MessageLoop::current()->PostTask( 738 MessageLoop::current()->PostTask(
739 FROM_HERE, 739 FROM_HERE,
740 base::Bind(&GDataWapiFeedLoader::OnNotifyDocumentFeedFetched, 740 base::Bind(&GDataWapiFeedLoader::OnNotifyDocumentFeedFetched,
741 weak_ptr_factory_.GetWeakPtr(), 741 weak_ptr_factory_.GetWeakPtr(),
742 ui_state->weak_ptr_factory.GetWeakPtr())); 742 ui_state->weak_ptr_factory.GetWeakPtr()));
743 } 743 }
744 ui_state->num_fetched_documents = num_accumulated_entries; 744 ui_state->num_fetched_documents = num_accumulated_entries;
745 ui_state->feed_fetching_elapsed_time = base::TimeTicks::Now() - start_time; 745 ui_state->feed_fetching_elapsed_time = base::TimeTicks::Now() - start_time;
746 746
747 // Kick off the remaining part of the feeds. 747 // Kick off the remaining part of the feeds.
748 documents_service_->GetDocuments( 748 drive_service_->GetDocuments(
749 current_feed->next_link(), 749 current_feed->next_link(),
750 params->start_changestamp, 750 params->start_changestamp,
751 std::string(), // No search query. 751 std::string(), // No search query.
752 std::string(), // No directory resource ID. 752 std::string(), // No directory resource ID.
753 base::Bind(&GDataWapiFeedLoader::OnGetChangelist, 753 base::Bind(&GDataWapiFeedLoader::OnGetChangelist,
754 weak_ptr_factory_.GetWeakPtr(), 754 weak_ptr_factory_.GetWeakPtr(),
755 initial_origin, 755 initial_origin,
756 callback, 756 callback,
757 base::Owned( 757 base::Owned(
758 new GetDocumentsParams( 758 new GetDocumentsParams(
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 dir_iter != changed_dirs.end(); ++dir_iter) { 957 dir_iter != changed_dirs.end(); ++dir_iter) {
958 FOR_EACH_OBSERVER(Observer, observers_, 958 FOR_EACH_OBSERVER(Observer, observers_,
959 OnDirectoryChanged(*dir_iter)); 959 OnDirectoryChanged(*dir_iter));
960 } 960 }
961 } 961 }
962 962
963 return error; 963 return error;
964 } 964 }
965 965
966 } // namespace gdata 966 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_wapi_feed_loader.h ('k') | chrome/browser/chromeos/gdata/gdata_wapi_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698