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

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

Issue 11106007: drive: Rename 'gdata' namespace to 'drive' in chrome/browser/chromeos/drive (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 2 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/drive/gdata_wapi_feed_loader.h" 5 #include "chrome/browser/chromeos/drive/gdata_wapi_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 10 matching lines...) Expand all
21 #include "chrome/browser/chromeos/drive/drive_webapps_registry.h" 21 #include "chrome/browser/chromeos/drive/drive_webapps_registry.h"
22 #include "chrome/browser/chromeos/drive/gdata_wapi_feed_loader_observer.h" 22 #include "chrome/browser/chromeos/drive/gdata_wapi_feed_loader_observer.h"
23 #include "chrome/browser/chromeos/drive/gdata_wapi_feed_processor.h" 23 #include "chrome/browser/chromeos/drive/gdata_wapi_feed_processor.h"
24 #include "chrome/browser/google_apis/drive_api_parser.h" 24 #include "chrome/browser/google_apis/drive_api_parser.h"
25 #include "chrome/browser/google_apis/gdata_util.h" 25 #include "chrome/browser/google_apis/gdata_util.h"
26 #include "chrome/common/chrome_switches.h" 26 #include "chrome/common/chrome_switches.h"
27 #include "content/public/browser/browser_thread.h" 27 #include "content/public/browser/browser_thread.h"
28 28
29 using content::BrowserThread; 29 using content::BrowserThread;
30 30
31 namespace gdata { 31 namespace drive {
32 32
33 namespace { 33 namespace {
34 34
35 const FilePath::CharType kAccountMetadataFile[] = 35 const FilePath::CharType kAccountMetadataFile[] =
36 FILE_PATH_LITERAL("account_metadata.json"); 36 FILE_PATH_LITERAL("account_metadata.json");
37 const FilePath::CharType kFilesystemProtoFile[] = 37 const FilePath::CharType kFilesystemProtoFile[] =
38 FILE_PATH_LITERAL("file_system.pb"); 38 FILE_PATH_LITERAL("file_system.pb");
39 const FilePath::CharType kResourceMetadataDBFile[] = 39 const FilePath::CharType kResourceMetadataDBFile[] =
40 FILE_PATH_LITERAL("resource_metadata.db"); 40 FILE_PATH_LITERAL("resource_metadata.db");
41 41
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 141
142 // Run params->feed_load_callback with |error|. 142 // Run params->feed_load_callback with |error|.
143 void RunFeedLoadCallback(scoped_ptr<LoadFeedParams> params, 143 void RunFeedLoadCallback(scoped_ptr<LoadFeedParams> params,
144 DriveFileError error) { 144 DriveFileError error) {
145 // Need a reference before calling Pass(). 145 // Need a reference before calling Pass().
146 const LoadDocumentFeedCallback& feed_load_callback = 146 const LoadDocumentFeedCallback& feed_load_callback =
147 params->feed_load_callback; 147 params->feed_load_callback;
148 feed_load_callback.Run(params.Pass(), error); 148 feed_load_callback.Run(params.Pass(), error);
149 } 149 }
150 150
151 // Parses a DocumentFeed from |data|. 151 // Parses a gdata::DocumentFeed from |data|.
152 void ParseFeedOnBlockingPool( 152 void ParseFeedOnBlockingPool(
153 scoped_ptr<base::Value> data, 153 scoped_ptr<base::Value> data,
154 scoped_ptr<DocumentFeed>* out_current_feed) { 154 scoped_ptr<gdata::DocumentFeed>* out_current_feed) {
155 DCHECK(out_current_feed); 155 DCHECK(out_current_feed);
156 out_current_feed->reset(DocumentFeed::ExtractAndParse(*data).release()); 156 out_current_feed->reset(
157 gdata::DocumentFeed::ExtractAndParse(*data).release());
157 } 158 }
158 159
159 } // namespace 160 } // namespace
160 161
161 LoadFeedParams::LoadFeedParams( 162 LoadFeedParams::LoadFeedParams(
162 ContentOrigin initial_origin, 163 ContentOrigin initial_origin,
163 const LoadDocumentFeedCallback& feed_load_callback) 164 const LoadDocumentFeedCallback& feed_load_callback)
164 : initial_origin(initial_origin), 165 : initial_origin(initial_origin),
165 start_changestamp(0), 166 start_changestamp(0),
166 root_feed_changestamp(0), 167 root_feed_changestamp(0),
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 weak_ptr_factory_.GetWeakPtr(), 274 weak_ptr_factory_.GetWeakPtr(),
274 initial_origin, 275 initial_origin,
275 local_changestamp, 276 local_changestamp,
276 callback)); 277 callback));
277 } 278 }
278 279
279 void GDataWapiFeedLoader::OnGetAccountMetadata( 280 void GDataWapiFeedLoader::OnGetAccountMetadata(
280 ContentOrigin initial_origin, 281 ContentOrigin initial_origin,
281 int64 local_changestamp, 282 int64 local_changestamp,
282 const FileOperationCallback& callback, 283 const FileOperationCallback& callback,
283 GDataErrorCode status, 284 gdata::GDataErrorCode status,
284 scoped_ptr<base::Value> feed_data) { 285 scoped_ptr<base::Value> feed_data) {
285 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 286 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
286 287
287 scoped_ptr<LoadFeedParams> params(new LoadFeedParams( 288 scoped_ptr<LoadFeedParams> params(new LoadFeedParams(
288 initial_origin, 289 initial_origin,
289 base::Bind(&GDataWapiFeedLoader::OnFeedFromServerLoaded, 290 base::Bind(&GDataWapiFeedLoader::OnFeedFromServerLoaded,
290 weak_ptr_factory_.GetWeakPtr()))); 291 weak_ptr_factory_.GetWeakPtr())));
291 params->start_changestamp = local_changestamp + 1; 292 params->start_changestamp = local_changestamp + 1;
292 params->load_finished_callback = callback; 293 params->load_finished_callback = callback;
293 294
294 DriveFileError error = util::GDataToDriveFileError(status); 295 DriveFileError error = util::GDataToDriveFileError(status);
295 if (error != DRIVE_FILE_OK) { 296 if (error != DRIVE_FILE_OK) {
296 // Get changes starting from the next changestamp from what we have locally. 297 // Get changes starting from the next changestamp from what we have locally.
297 LoadFromServer(params.Pass()); 298 LoadFromServer(params.Pass());
298 return; 299 return;
299 } 300 }
300 301
301 scoped_ptr<AccountMetadataFeed> account_metadata; 302 scoped_ptr<gdata::AccountMetadataFeed> account_metadata;
302 if (feed_data.get()) { 303 if (feed_data.get()) {
303 account_metadata = AccountMetadataFeed::CreateFrom(*feed_data); 304 account_metadata = gdata::AccountMetadataFeed::CreateFrom(*feed_data);
304 #ifndef NDEBUG 305 #ifndef NDEBUG
305 // Save account metadata feed for analysis. 306 // Save account metadata feed for analysis.
306 const FilePath path = 307 const FilePath path =
307 cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_META).Append( 308 cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_META).Append(
308 kAccountMetadataFile); 309 kAccountMetadataFile);
309 util::PostBlockingPoolSequencedTask( 310 gdata::util::PostBlockingPoolSequencedTask(
310 FROM_HERE, 311 FROM_HERE,
311 blocking_task_runner_, 312 blocking_task_runner_,
312 base::Bind(&SaveFeedOnBlockingPoolForDebugging, 313 base::Bind(&SaveFeedOnBlockingPoolForDebugging,
313 path, base::Passed(&feed_data))); 314 path, base::Passed(&feed_data)));
314 #endif 315 #endif
315 } 316 }
316 317
317 if (!account_metadata.get()) { 318 if (!account_metadata.get()) {
318 LoadFromServer(params.Pass()); 319 LoadFromServer(params.Pass());
319 return; 320 return;
(...skipping 26 matching lines...) Expand all
346 // Load changes from the server. 347 // Load changes from the server.
347 params->start_changestamp = local_changestamp > 0 ? local_changestamp + 1 : 0; 348 params->start_changestamp = local_changestamp > 0 ? local_changestamp + 1 : 0;
348 params->root_feed_changestamp = account_metadata->largest_changestamp(); 349 params->root_feed_changestamp = account_metadata->largest_changestamp();
349 LoadFromServer(params.Pass()); 350 LoadFromServer(params.Pass());
350 } 351 }
351 352
352 void GDataWapiFeedLoader::OnGetAboutResource( 353 void GDataWapiFeedLoader::OnGetAboutResource(
353 ContentOrigin initial_origin, 354 ContentOrigin initial_origin,
354 int64 local_changestamp, 355 int64 local_changestamp,
355 const FileOperationCallback& callback, 356 const FileOperationCallback& callback,
356 GDataErrorCode status, 357 gdata::GDataErrorCode status,
357 scoped_ptr<base::Value> feed_data) { 358 scoped_ptr<base::Value> feed_data) {
358 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 359 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
359 360
360 scoped_ptr<LoadFeedParams> params(new LoadFeedParams( 361 scoped_ptr<LoadFeedParams> params(new LoadFeedParams(
361 initial_origin, 362 initial_origin,
362 base::Bind(&GDataWapiFeedLoader::OnFeedFromServerLoaded, 363 base::Bind(&GDataWapiFeedLoader::OnFeedFromServerLoaded,
363 weak_ptr_factory_.GetWeakPtr()))); 364 weak_ptr_factory_.GetWeakPtr())));
364 params->load_finished_callback = callback; 365 params->load_finished_callback = callback;
365 366
366 DriveFileError error = util::GDataToDriveFileError(status); 367 DriveFileError error = util::GDataToDriveFileError(status);
367 if (error != DRIVE_FILE_OK) { 368 if (error != DRIVE_FILE_OK) {
368 // Get changes starting from the next changestamp from what we have locally. 369 // Get changes starting from the next changestamp from what we have locally.
369 LoadFromServer(params.Pass()); 370 LoadFromServer(params.Pass());
370 return; 371 return;
371 } 372 }
372 373
373 scoped_ptr<AboutResource> about_resource; 374 scoped_ptr<gdata::AboutResource> about_resource;
374 if (feed_data.get()) 375 if (feed_data.get())
375 about_resource = AboutResource::CreateFrom(*feed_data); 376 about_resource = gdata::AboutResource::CreateFrom(*feed_data);
376 377
377 if (!about_resource.get()) { 378 if (!about_resource.get()) {
378 LoadFromServer(params.Pass()); 379 LoadFromServer(params.Pass());
379 return; 380 return;
380 } 381 }
381 382
382 bool changes_detected = true; 383 bool changes_detected = true;
383 int64 largest_changestamp = about_resource->largest_change_id(); 384 int64 largest_changestamp = about_resource->largest_change_id();
384 resource_metadata_->InitializeRootEntry(about_resource->root_folder_id()); 385 resource_metadata_->InitializeRootEntry(about_resource->root_folder_id());
385 386
(...skipping 18 matching lines...) Expand all
404 return; 405 return;
405 } 406 }
406 407
407 // Load changes from the server. 408 // Load changes from the server.
408 params->start_changestamp = local_changestamp > 0 ? local_changestamp + 1 : 0; 409 params->start_changestamp = local_changestamp > 0 ? local_changestamp + 1 : 0;
409 params->root_feed_changestamp = largest_changestamp; 410 params->root_feed_changestamp = largest_changestamp;
410 LoadFromServer(params.Pass()); 411 LoadFromServer(params.Pass());
411 } 412 }
412 413
413 void GDataWapiFeedLoader::OnGetApplicationList( 414 void GDataWapiFeedLoader::OnGetApplicationList(
414 GDataErrorCode status, 415 gdata::GDataErrorCode status,
415 scoped_ptr<base::Value> json) { 416 scoped_ptr<base::Value> json) {
416 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 417 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
417 418
418 DriveFileError error = util::GDataToDriveFileError(status); 419 DriveFileError error = util::GDataToDriveFileError(status);
419 if (error != DRIVE_FILE_OK) 420 if (error != DRIVE_FILE_OK)
420 return; 421 return;
421 422
422 if (json.get()) { 423 if (json.get()) {
423 scoped_ptr<AppList> applist(AppList::CreateFrom(*json)); 424 scoped_ptr<gdata::AppList> applist(gdata::AppList::CreateFrom(*json));
424 if (applist.get()) { 425 if (applist.get()) {
425 VLOG(1) << "applist get success"; 426 VLOG(1) << "applist get success";
426 webapps_registry_->UpdateFromApplicationList(*applist.get()); 427 webapps_registry_->UpdateFromApplicationList(*applist.get());
427 } 428 }
428 } 429 }
429 } 430 }
430 431
431 void GDataWapiFeedLoader::LoadFromServer(scoped_ptr<LoadFeedParams> params) { 432 void GDataWapiFeedLoader::LoadFromServer(scoped_ptr<LoadFeedParams> params) {
432 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 433 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
433 434
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 params->load_finished_callback.Run(DRIVE_FILE_OK); 512 params->load_finished_callback.Run(DRIVE_FILE_OK);
512 513
513 FOR_EACH_OBSERVER(GDataWapiFeedLoaderObserver, 514 FOR_EACH_OBSERVER(GDataWapiFeedLoaderObserver,
514 observers_, 515 observers_,
515 OnFeedFromServerLoaded()); 516 OnFeedFromServerLoaded());
516 } 517 }
517 518
518 void GDataWapiFeedLoader::OnGetDocuments( 519 void GDataWapiFeedLoader::OnGetDocuments(
519 scoped_ptr<LoadFeedParams> params, 520 scoped_ptr<LoadFeedParams> params,
520 base::TimeTicks start_time, 521 base::TimeTicks start_time,
521 GDataErrorCode status, 522 gdata::GDataErrorCode status,
522 scoped_ptr<base::Value> data) { 523 scoped_ptr<base::Value> data) {
523 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 524 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
524 525
525 if (params->feed_list.empty()) { 526 if (params->feed_list.empty()) {
526 UMA_HISTOGRAM_TIMES("Drive.InitialFeedLoadTime", 527 UMA_HISTOGRAM_TIMES("Drive.InitialFeedLoadTime",
527 base::TimeTicks::Now() - start_time); 528 base::TimeTicks::Now() - start_time);
528 } 529 }
529 530
530 DriveFileError error = util::GDataToDriveFileError(status); 531 DriveFileError error = util::GDataToDriveFileError(status);
531 if (error == DRIVE_FILE_OK && 532 if (error == DRIVE_FILE_OK &&
532 (!data.get() || data->GetType() != Value::TYPE_DICTIONARY)) { 533 (!data.get() || data->GetType() != Value::TYPE_DICTIONARY)) {
533 error = DRIVE_FILE_ERROR_FAILED; 534 error = DRIVE_FILE_ERROR_FAILED;
534 } 535 }
535 536
536 if (error != DRIVE_FILE_OK) { 537 if (error != DRIVE_FILE_OK) {
537 resource_metadata_->set_origin(params->initial_origin); 538 resource_metadata_->set_origin(params->initial_origin);
538 RunFeedLoadCallback(params.Pass(), error); 539 RunFeedLoadCallback(params.Pass(), error);
539 return; 540 return;
540 } 541 }
541 542
542 scoped_ptr<DocumentFeed>* current_feed = new scoped_ptr<DocumentFeed>; 543 scoped_ptr<gdata::DocumentFeed>* current_feed =
543 util::PostBlockingPoolSequencedTaskAndReply( 544 new scoped_ptr<gdata::DocumentFeed>;
545 gdata::util::PostBlockingPoolSequencedTaskAndReply(
544 FROM_HERE, 546 FROM_HERE,
545 blocking_task_runner_, 547 blocking_task_runner_,
546 base::Bind(&ParseFeedOnBlockingPool, 548 base::Bind(&ParseFeedOnBlockingPool,
547 base::Passed(&data), 549 base::Passed(&data),
548 current_feed), 550 current_feed),
549 base::Bind(&GDataWapiFeedLoader::OnParseFeed, 551 base::Bind(&GDataWapiFeedLoader::OnParseFeed,
550 weak_ptr_factory_.GetWeakPtr(), 552 weak_ptr_factory_.GetWeakPtr(),
551 base::Passed(&params), 553 base::Passed(&params),
552 start_time, 554 start_time,
553 base::Owned(current_feed))); 555 base::Owned(current_feed)));
554 } 556 }
555 557
556 void GDataWapiFeedLoader::OnParseFeed(scoped_ptr<LoadFeedParams> params, 558 void GDataWapiFeedLoader::OnParseFeed(
557 base::TimeTicks start_time, 559 scoped_ptr<LoadFeedParams> params,
558 scoped_ptr<DocumentFeed>* current_feed) { 560 base::TimeTicks start_time,
561 scoped_ptr<gdata::DocumentFeed>* current_feed) {
559 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 562 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
560 DCHECK(current_feed); 563 DCHECK(current_feed);
561 564
562 if (!current_feed->get()) { 565 if (!current_feed->get()) {
563 RunFeedLoadCallback(params.Pass(), DRIVE_FILE_ERROR_FAILED); 566 RunFeedLoadCallback(params.Pass(), DRIVE_FILE_ERROR_FAILED);
564 return; 567 return;
565 } 568 }
566 569
567 GURL next_feed_url; 570 GURL next_feed_url;
568 const bool has_next_feed_url = 571 const bool has_next_feed_url =
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 UMA_HISTOGRAM_TIMES("Drive.EntireFeedLoadTime", 624 UMA_HISTOGRAM_TIMES("Drive.EntireFeedLoadTime",
622 base::TimeTicks::Now() - start_time); 625 base::TimeTicks::Now() - start_time);
623 626
624 // Run the callback so the client can process the retrieved feeds. 627 // Run the callback so the client can process the retrieved feeds.
625 RunFeedLoadCallback(params.Pass(), DRIVE_FILE_OK); 628 RunFeedLoadCallback(params.Pass(), DRIVE_FILE_OK);
626 } 629 }
627 630
628 void GDataWapiFeedLoader::OnGetChangelist( 631 void GDataWapiFeedLoader::OnGetChangelist(
629 scoped_ptr<LoadFeedParams> params, 632 scoped_ptr<LoadFeedParams> params,
630 base::TimeTicks start_time, 633 base::TimeTicks start_time,
631 GDataErrorCode status, 634 gdata::GDataErrorCode status,
632 scoped_ptr<base::Value> data) { 635 scoped_ptr<base::Value> data) {
633 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 636 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
634 637
635 if (params->feed_list.empty()) { 638 if (params->feed_list.empty()) {
636 UMA_HISTOGRAM_TIMES("Drive.InitialFeedLoadTime", 639 UMA_HISTOGRAM_TIMES("Drive.InitialFeedLoadTime",
637 base::TimeTicks::Now() - start_time); 640 base::TimeTicks::Now() - start_time);
638 } 641 }
639 642
640 DriveFileError error = util::GDataToDriveFileError(status); 643 DriveFileError error = util::GDataToDriveFileError(status);
641 if (error == DRIVE_FILE_OK && 644 if (error == DRIVE_FILE_OK &&
642 (!data.get() || data->GetType() != Value::TYPE_DICTIONARY)) { 645 (!data.get() || data->GetType() != Value::TYPE_DICTIONARY)) {
643 error = DRIVE_FILE_ERROR_FAILED; 646 error = DRIVE_FILE_ERROR_FAILED;
644 } 647 }
645 648
646 if (error != DRIVE_FILE_OK) { 649 if (error != DRIVE_FILE_OK) {
647 resource_metadata_->set_origin(params->initial_origin); 650 resource_metadata_->set_origin(params->initial_origin);
648 RunFeedLoadCallback(params.Pass(), error); 651 RunFeedLoadCallback(params.Pass(), error);
649 return; 652 return;
650 } 653 }
651 654
652 GURL next_feed_url; 655 GURL next_feed_url;
653 scoped_ptr<ChangeList> current_feed(ChangeList::CreateFrom(*data)); 656 scoped_ptr<gdata::ChangeList> current_feed(
657 gdata::ChangeList::CreateFrom(*data));
654 if (!current_feed.get()) { 658 if (!current_feed.get()) {
655 RunFeedLoadCallback(params.Pass(), DRIVE_FILE_ERROR_FAILED); 659 RunFeedLoadCallback(params.Pass(), DRIVE_FILE_ERROR_FAILED);
656 return; 660 return;
657 } 661 }
658 const bool has_next_feed = !current_feed->next_page_token().empty(); 662 const bool has_next_feed = !current_feed->next_page_token().empty();
659 663
660 #ifndef NDEBUG 664 #ifndef NDEBUG
661 // Save initial root feed for analysis. 665 // Save initial root feed for analysis.
662 std::string file_name = 666 std::string file_name =
663 base::StringPrintf("DEBUG_changelist_%" PRId64 ".json", 667 base::StringPrintf("DEBUG_changelist_%" PRId64 ".json",
664 params->start_changestamp); 668 params->start_changestamp);
665 util::PostBlockingPoolSequencedTask( 669 gdata::util::PostBlockingPoolSequencedTask(
666 FROM_HERE, 670 FROM_HERE,
667 blocking_task_runner_, 671 blocking_task_runner_,
668 base::Bind(&SaveFeedOnBlockingPoolForDebugging, 672 base::Bind(&SaveFeedOnBlockingPoolForDebugging,
669 cache_->GetCacheDirectoryPath( 673 cache_->GetCacheDirectoryPath(
670 DriveCache::CACHE_TYPE_META).Append(file_name), 674 DriveCache::CACHE_TYPE_META).Append(file_name),
671 base::Passed(&data))); 675 base::Passed(&data)));
672 #endif 676 #endif
673 677
674 // Add the current feed to the list of collected feeds for this directory. 678 // Add the current feed to the list of collected feeds for this directory.
675 scoped_ptr<DocumentFeed> feed = 679 scoped_ptr<gdata::DocumentFeed> feed =
676 DocumentFeed::CreateFromChangeList(*current_feed); 680 gdata::DocumentFeed::CreateFromChangeList(*current_feed);
677 params->feed_list.push_back(feed.release()); 681 params->feed_list.push_back(feed.release());
678 682
679 // Compute and notify the number of entries fetched so far. 683 // Compute and notify the number of entries fetched so far.
680 int num_accumulated_entries = 0; 684 int num_accumulated_entries = 0;
681 for (size_t i = 0; i < params->feed_list.size(); ++i) 685 for (size_t i = 0; i < params->feed_list.size(); ++i)
682 num_accumulated_entries += params->feed_list[i]->entries().size(); 686 num_accumulated_entries += params->feed_list[i]->entries().size();
683 687
684 // Check if we need to collect more data to complete the directory list. 688 // Check if we need to collect more data to complete the directory list.
685 if (has_next_feed) { 689 if (has_next_feed) {
686 // Post an UI update event to make the UI smoother. 690 // Post an UI update event to make the UI smoother.
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 if (UseLevelDB()) { 873 if (UseLevelDB()) {
870 resource_metadata_->SaveToDB(); 874 resource_metadata_->SaveToDB();
871 } else { 875 } else {
872 const FilePath path = 876 const FilePath path =
873 cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_META).Append( 877 cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_META).Append(
874 kFilesystemProtoFile); 878 kFilesystemProtoFile);
875 scoped_ptr<std::string> serialized_proto(new std::string()); 879 scoped_ptr<std::string> serialized_proto(new std::string());
876 resource_metadata_->SerializeToString(serialized_proto.get()); 880 resource_metadata_->SerializeToString(serialized_proto.get());
877 resource_metadata_->set_last_serialized(base::Time::Now()); 881 resource_metadata_->set_last_serialized(base::Time::Now());
878 resource_metadata_->set_serialized_size(serialized_proto->size()); 882 resource_metadata_->set_serialized_size(serialized_proto->size());
879 util::PostBlockingPoolSequencedTask( 883 gdata::util::PostBlockingPoolSequencedTask(
880 FROM_HERE, 884 FROM_HERE,
881 blocking_task_runner_, 885 blocking_task_runner_,
882 base::Bind(&SaveProtoOnBlockingPool, path, 886 base::Bind(&SaveProtoOnBlockingPool, path,
883 base::Passed(serialized_proto.Pass()))); 887 base::Passed(serialized_proto.Pass())));
884 } 888 }
885 } 889 }
886 890
887 DriveFileError GDataWapiFeedLoader::UpdateFromFeed( 891 DriveFileError GDataWapiFeedLoader::UpdateFromFeed(
888 const ScopedVector<DocumentFeed>& feed_list, 892 const ScopedVector<gdata::DocumentFeed>& feed_list,
889 int64 start_changestamp, 893 int64 start_changestamp,
890 int64 root_feed_changestamp) { 894 int64 root_feed_changestamp) {
891 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 895 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
892 DVLOG(1) << "Updating directory with a feed"; 896 DVLOG(1) << "Updating directory with a feed";
893 897
894 std::set<FilePath> changed_dirs; 898 std::set<FilePath> changed_dirs;
895 899
896 GDataWapiFeedProcessor feed_processor(resource_metadata_); 900 GDataWapiFeedProcessor feed_processor(resource_metadata_);
897 const DriveFileError error = feed_processor.ApplyFeeds( 901 const DriveFileError error = feed_processor.ApplyFeeds(
898 feed_list, 902 feed_list,
899 start_changestamp, 903 start_changestamp,
900 root_feed_changestamp, 904 root_feed_changestamp,
901 &changed_dirs); 905 &changed_dirs);
902 906
903 // Don't send directory content change notification while performing 907 // Don't send directory content change notification while performing
904 // the initial content retrieval. 908 // the initial content retrieval.
905 const bool should_notify_directory_changed = (start_changestamp != 0); 909 const bool should_notify_directory_changed = (start_changestamp != 0);
906 if (should_notify_directory_changed) { 910 if (should_notify_directory_changed) {
907 for (std::set<FilePath>::iterator dir_iter = changed_dirs.begin(); 911 for (std::set<FilePath>::iterator dir_iter = changed_dirs.begin();
908 dir_iter != changed_dirs.end(); ++dir_iter) { 912 dir_iter != changed_dirs.end(); ++dir_iter) {
909 FOR_EACH_OBSERVER(GDataWapiFeedLoaderObserver, observers_, 913 FOR_EACH_OBSERVER(GDataWapiFeedLoaderObserver, observers_,
910 OnDirectoryChanged(*dir_iter)); 914 OnDirectoryChanged(*dir_iter));
911 } 915 }
912 } 916 }
913 917
914 return error; 918 return error;
915 } 919 }
916 920
917 } // namespace gdata 921 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698