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

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

Issue 10877006: Rename GDataErrorCode to DriveErrorCode, GDataFileError to DriveFileError (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: minor local variable name fix. 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 <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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 {-1, 120}, // Any size, dump if older than 120 minutes. 60 {-1, 120}, // Any size, dump if older than 120 minutes.
61 #endif 61 #endif
62 }; 62 };
63 63
64 // Loads the file at |path| into the string |serialized_proto| on a blocking 64 // Loads the file at |path| into the string |serialized_proto| on a blocking
65 // thread. 65 // thread.
66 void LoadProtoOnBlockingPool(const FilePath& path, 66 void LoadProtoOnBlockingPool(const FilePath& path,
67 LoadRootFeedParams* params) { 67 LoadRootFeedParams* params) {
68 base::PlatformFileInfo info; 68 base::PlatformFileInfo info;
69 if (!file_util::GetFileInfo(path, &info)) { 69 if (!file_util::GetFileInfo(path, &info)) {
70 params->load_error = GDATA_FILE_ERROR_NOT_FOUND; 70 params->load_error = DRIVE_FILE_ERROR_NOT_FOUND;
71 return; 71 return;
72 } 72 }
73 params->last_modified = info.last_modified; 73 params->last_modified = info.last_modified;
74 if (!file_util::ReadFileToString(path, &params->proto)) { 74 if (!file_util::ReadFileToString(path, &params->proto)) {
75 LOG(WARNING) << "Proto file not found at " << path.value(); 75 LOG(WARNING) << "Proto file not found at " << path.value();
76 params->load_error = GDATA_FILE_ERROR_NOT_FOUND; 76 params->load_error = DRIVE_FILE_ERROR_NOT_FOUND;
77 return; 77 return;
78 } 78 }
79 params->load_error = GDATA_FILE_OK; 79 params->load_error = DRIVE_FILE_OK;
80 } 80 }
81 81
82 // Saves json file content content in |feed| to |file_pathname| on blocking 82 // Saves json file content content in |feed| to |file_pathname| on blocking
83 // pool. Used for debugging. 83 // pool. Used for debugging.
84 void SaveFeedOnBlockingPoolForDebugging( 84 void SaveFeedOnBlockingPoolForDebugging(
85 const FilePath& file_path, 85 const FilePath& file_path,
86 scoped_ptr<base::Value> feed) { 86 scoped_ptr<base::Value> feed) {
87 std::string json; 87 std::string json;
88 base::JSONWriter::WriteWithOptions(feed.get(), 88 base::JSONWriter::WriteWithOptions(feed.get(),
89 base::JSONWriter::OPTIONS_PRETTY_PRINT, 89 base::JSONWriter::OPTIONS_PRETTY_PRINT,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 } 158 }
159 159
160 GetDocumentsParams::~GetDocumentsParams() { 160 GetDocumentsParams::~GetDocumentsParams() {
161 STLDeleteElements(feed_list.get()); 161 STLDeleteElements(feed_list.get());
162 } 162 }
163 163
164 LoadRootFeedParams::LoadRootFeedParams( 164 LoadRootFeedParams::LoadRootFeedParams(
165 bool should_load_from_server, 165 bool should_load_from_server,
166 const FileOperationCallback& callback) 166 const FileOperationCallback& callback)
167 : should_load_from_server(should_load_from_server), 167 : should_load_from_server(should_load_from_server),
168 load_error(GDATA_FILE_OK), 168 load_error(DRIVE_FILE_OK),
169 load_start_time(base::Time::Now()), 169 load_start_time(base::Time::Now()),
170 callback(callback) { 170 callback(callback) {
171 } 171 }
172 172
173 LoadRootFeedParams::~LoadRootFeedParams() { 173 LoadRootFeedParams::~LoadRootFeedParams() {
174 } 174 }
175 175
176 // Defines set of parameters for calling GDataWapiFeedLoader::LoadFromServer(). 176 // Defines set of parameters for calling GDataWapiFeedLoader::LoadFromServer().
177 // Value of |start_changestamp| determines the type of feed to load - 0 means 177 // Value of |start_changestamp| determines the type of feed to load - 0 means
178 // root feed, every other value would trigger delta feed. 178 // root feed, every other value would trigger delta feed.
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 GDataErrorCode status, 305 GDataErrorCode status,
306 scoped_ptr<base::Value> feed_data) { 306 scoped_ptr<base::Value> feed_data) {
307 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 307 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
308 308
309 LoadFeedParams params(initial_origin, 309 LoadFeedParams params(initial_origin,
310 base::Bind(&GDataWapiFeedLoader::OnFeedFromServerLoaded, 310 base::Bind(&GDataWapiFeedLoader::OnFeedFromServerLoaded,
311 weak_ptr_factory_.GetWeakPtr())); 311 weak_ptr_factory_.GetWeakPtr()));
312 params.start_changestamp = local_changestamp + 1; 312 params.start_changestamp = local_changestamp + 1;
313 params.load_finished_callback = callback; 313 params.load_finished_callback = callback;
314 314
315 GDataFileError error = util::GDataToGDataFileError(status); 315 DriveFileError error = util::GDataToDriveFileError(status);
316 if (error != GDATA_FILE_OK) { 316 if (error != DRIVE_FILE_OK) {
317 // Get changes starting from the next changestamp from what we have locally. 317 // Get changes starting from the next changestamp from what we have locally.
318 LoadFromServer(params); 318 LoadFromServer(params);
319 return; 319 return;
320 } 320 }
321 321
322 scoped_ptr<AccountMetadataFeed> account_metadata; 322 scoped_ptr<AccountMetadataFeed> account_metadata;
323 if (feed_data.get()) { 323 if (feed_data.get()) {
324 account_metadata = AccountMetadataFeed::CreateFrom(*feed_data); 324 account_metadata = AccountMetadataFeed::CreateFrom(*feed_data);
325 #ifndef NDEBUG 325 #ifndef NDEBUG
326 // Save account metadata feed for analysis. 326 // Save account metadata feed for analysis.
(...skipping 26 matching lines...) Expand all
353 // If our cache holds the latest state from the server, change the 353 // If our cache holds the latest state from the server, change the
354 // state to FROM_SERVER. 354 // state to FROM_SERVER.
355 resource_metadata_->set_origin( 355 resource_metadata_->set_origin(
356 initial_origin == FROM_CACHE ? FROM_SERVER : initial_origin); 356 initial_origin == FROM_CACHE ? FROM_SERVER : initial_origin);
357 changes_detected = false; 357 changes_detected = false;
358 } 358 }
359 359
360 // No changes detected, tell the client that the loading was successful. 360 // No changes detected, tell the client that the loading was successful.
361 if (!changes_detected) { 361 if (!changes_detected) {
362 if (!callback.is_null()) 362 if (!callback.is_null())
363 callback.Run(GDATA_FILE_OK); 363 callback.Run(DRIVE_FILE_OK);
364 return; 364 return;
365 } 365 }
366 366
367 // Load changes from the server. 367 // Load changes from the server.
368 params.start_changestamp = local_changestamp > 0 ? local_changestamp + 1 : 0; 368 params.start_changestamp = local_changestamp > 0 ? local_changestamp + 1 : 0;
369 params.root_feed_changestamp = account_metadata->largest_changestamp(); 369 params.root_feed_changestamp = account_metadata->largest_changestamp();
370 LoadFromServer(params); 370 LoadFromServer(params);
371 } 371 }
372 372
373 void GDataWapiFeedLoader::OnGetAboutResource( 373 void GDataWapiFeedLoader::OnGetAboutResource(
374 ContentOrigin initial_origin, 374 ContentOrigin initial_origin,
375 int64 local_changestamp, 375 int64 local_changestamp,
376 const FileOperationCallback& callback, 376 const FileOperationCallback& callback,
377 GDataErrorCode status, 377 GDataErrorCode status,
378 scoped_ptr<base::Value> feed_data) { 378 scoped_ptr<base::Value> feed_data) {
379 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 379 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
380 380
381 LoadFeedParams params(initial_origin, 381 LoadFeedParams params(initial_origin,
382 base::Bind(&GDataWapiFeedLoader::OnFeedFromServerLoaded, 382 base::Bind(&GDataWapiFeedLoader::OnFeedFromServerLoaded,
383 weak_ptr_factory_.GetWeakPtr())); 383 weak_ptr_factory_.GetWeakPtr()));
384 params.load_finished_callback = callback; 384 params.load_finished_callback = callback;
385 385
386 GDataFileError error = util::GDataToGDataFileError(status); 386 DriveFileError error = util::GDataToDriveFileError(status);
387 if (error != GDATA_FILE_OK) { 387 if (error != DRIVE_FILE_OK) {
388 // Get changes starting from the next changestamp from what we have locally. 388 // Get changes starting from the next changestamp from what we have locally.
389 LoadFromServer(params); 389 LoadFromServer(params);
390 return; 390 return;
391 } 391 }
392 392
393 scoped_ptr<AboutResource> about_resource; 393 scoped_ptr<AboutResource> about_resource;
394 if (feed_data.get()) 394 if (feed_data.get())
395 about_resource = AboutResource::CreateFrom(*feed_data); 395 about_resource = AboutResource::CreateFrom(*feed_data);
396 396
397 if (!about_resource.get()) { 397 if (!about_resource.get()) {
(...skipping 15 matching lines...) Expand all
413 // If our cache holds the latest state from the server, change the 413 // If our cache holds the latest state from the server, change the
414 // state to FROM_SERVER. 414 // state to FROM_SERVER.
415 resource_metadata_->set_origin( 415 resource_metadata_->set_origin(
416 initial_origin == FROM_CACHE ? FROM_SERVER : initial_origin); 416 initial_origin == FROM_CACHE ? FROM_SERVER : initial_origin);
417 changes_detected = false; 417 changes_detected = false;
418 } 418 }
419 419
420 // No changes detected, tell the client that the loading was successful. 420 // No changes detected, tell the client that the loading was successful.
421 if (!changes_detected) { 421 if (!changes_detected) {
422 if (!callback.is_null()) 422 if (!callback.is_null())
423 callback.Run(GDATA_FILE_OK); 423 callback.Run(DRIVE_FILE_OK);
424 return; 424 return;
425 } 425 }
426 426
427 // Load changes from the server. 427 // Load changes from the server.
428 params.start_changestamp = local_changestamp > 0 ? local_changestamp + 1 : 0; 428 params.start_changestamp = local_changestamp > 0 ? local_changestamp + 1 : 0;
429 params.root_feed_changestamp = largest_changestamp; 429 params.root_feed_changestamp = largest_changestamp;
430 LoadFromServer(params); 430 LoadFromServer(params);
431 } 431 }
432 432
433 void GDataWapiFeedLoader::OnGetApplicationList( 433 void GDataWapiFeedLoader::OnGetApplicationList(
434 GDataErrorCode status, 434 GDataErrorCode status,
435 scoped_ptr<base::Value> json) { 435 scoped_ptr<base::Value> json) {
436 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 436 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
437 437
438 GDataFileError error = util::GDataToGDataFileError(status); 438 DriveFileError error = util::GDataToDriveFileError(status);
439 if (error != GDATA_FILE_OK) 439 if (error != DRIVE_FILE_OK)
440 return; 440 return;
441 441
442 if (json.get()) { 442 if (json.get()) {
443 scoped_ptr<AppList> applist(AppList::CreateFrom(*json)); 443 scoped_ptr<AppList> applist(AppList::CreateFrom(*json));
444 if (applist.get()) { 444 if (applist.get()) {
445 VLOG(1) << "applist get success"; 445 VLOG(1) << "applist get success";
446 webapps_registry_->UpdateFromApplicationList(*applist.get()); 446 webapps_registry_->UpdateFromApplicationList(*applist.get());
447 } 447 }
448 } 448 }
449 } 449 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 const std::string& search_query, 513 const std::string& search_query,
514 const GURL& next_feed, 514 const GURL& next_feed,
515 const LoadDocumentFeedCallback& feed_load_callback) { 515 const LoadDocumentFeedCallback& feed_load_callback) {
516 LoadFeedParams params(initial_origin, feed_load_callback); 516 LoadFeedParams params(initial_origin, feed_load_callback);
517 params.search_query = search_query; 517 params.search_query = search_query;
518 params.feed_to_load = next_feed; 518 params.feed_to_load = next_feed;
519 LoadFromServer(params); 519 LoadFromServer(params);
520 } 520 }
521 521
522 void GDataWapiFeedLoader::OnFeedFromServerLoaded(GetDocumentsParams* params, 522 void GDataWapiFeedLoader::OnFeedFromServerLoaded(GetDocumentsParams* params,
523 GDataFileError error) { 523 DriveFileError error) {
524 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 524 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
525 525
526 if (error != GDATA_FILE_OK) { 526 if (error != DRIVE_FILE_OK) {
527 if (!params->callback.is_null()) 527 if (!params->callback.is_null())
528 params->callback.Run(error); 528 params->callback.Run(error);
529 return; 529 return;
530 } 530 }
531 531
532 error = UpdateFromFeed(*params->feed_list, 532 error = UpdateFromFeed(*params->feed_list,
533 params->start_changestamp, 533 params->start_changestamp,
534 params->root_feed_changestamp); 534 params->root_feed_changestamp);
535 535
536 if (error != GDATA_FILE_OK) { 536 if (error != DRIVE_FILE_OK) {
537 if (!params->callback.is_null()) 537 if (!params->callback.is_null())
538 params->callback.Run(error); 538 params->callback.Run(error);
539 539
540 return; 540 return;
541 } 541 }
542 542
543 // Save file system metadata to disk. 543 // Save file system metadata to disk.
544 SaveFileSystem(); 544 SaveFileSystem();
545 545
546 // Tell the client that the loading was successful. 546 // Tell the client that the loading was successful.
547 if (!params->callback.is_null()) { 547 if (!params->callback.is_null()) {
548 params->callback.Run(GDATA_FILE_OK); 548 params->callback.Run(DRIVE_FILE_OK);
549 } 549 }
550 550
551 FOR_EACH_OBSERVER(Observer, observers_, OnFeedFromServerLoaded()); 551 FOR_EACH_OBSERVER(Observer, observers_, OnFeedFromServerLoaded());
552 } 552 }
553 553
554 void GDataWapiFeedLoader::OnGetDocuments( 554 void GDataWapiFeedLoader::OnGetDocuments(
555 ContentOrigin initial_origin, 555 ContentOrigin initial_origin,
556 const LoadDocumentFeedCallback& callback, 556 const LoadDocumentFeedCallback& callback,
557 GetDocumentsParams* params, 557 GetDocumentsParams* params,
558 base::TimeTicks start_time, 558 base::TimeTicks start_time,
559 GDataErrorCode status, 559 GDataErrorCode status,
560 scoped_ptr<base::Value> data) { 560 scoped_ptr<base::Value> data) {
561 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 561 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
562 DCHECK(!callback.is_null()); 562 DCHECK(!callback.is_null());
563 563
564 if (params->feed_list->empty()) { 564 if (params->feed_list->empty()) {
565 UMA_HISTOGRAM_TIMES("Gdata.InitialFeedLoadTime", 565 UMA_HISTOGRAM_TIMES("Gdata.InitialFeedLoadTime",
566 base::TimeTicks::Now() - start_time); 566 base::TimeTicks::Now() - start_time);
567 } 567 }
568 568
569 GDataFileError error = util::GDataToGDataFileError(status); 569 DriveFileError error = util::GDataToDriveFileError(status);
570 if (error == GDATA_FILE_OK && 570 if (error == DRIVE_FILE_OK &&
571 (!data.get() || data->GetType() != Value::TYPE_DICTIONARY)) { 571 (!data.get() || data->GetType() != Value::TYPE_DICTIONARY)) {
572 error = GDATA_FILE_ERROR_FAILED; 572 error = DRIVE_FILE_ERROR_FAILED;
573 } 573 }
574 574
575 if (error != GDATA_FILE_OK) { 575 if (error != DRIVE_FILE_OK) {
576 resource_metadata_->set_origin(initial_origin); 576 resource_metadata_->set_origin(initial_origin);
577 callback.Run(params, error); 577 callback.Run(params, error);
578 return; 578 return;
579 } 579 }
580 580
581 GURL next_feed_url; 581 GURL next_feed_url;
582 scoped_ptr<DocumentFeed> current_feed(DocumentFeed::ExtractAndParse(*data)); 582 scoped_ptr<DocumentFeed> current_feed(DocumentFeed::ExtractAndParse(*data));
583 if (!current_feed.get()) { 583 if (!current_feed.get()) {
584 callback.Run(params, GDATA_FILE_ERROR_FAILED); 584 callback.Run(params, DRIVE_FILE_ERROR_FAILED);
585 return; 585 return;
586 } 586 }
587 const bool has_next_feed_url = current_feed->GetNextFeedURL(&next_feed_url); 587 const bool has_next_feed_url = current_feed->GetNextFeedURL(&next_feed_url);
588 588
589 #ifndef NDEBUG 589 #ifndef NDEBUG
590 // Save initial root feed for analysis. 590 // Save initial root feed for analysis.
591 std::string file_name = 591 std::string file_name =
592 base::StringPrintf("DEBUG_feed_%" PRId64 ".json", 592 base::StringPrintf("DEBUG_feed_%" PRId64 ".json",
593 params->start_changestamp); 593 params->start_changestamp);
594 util::PostBlockingPoolSequencedTask( 594 util::PostBlockingPoolSequencedTask(
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 GDataErrorCode status, 672 GDataErrorCode status,
673 scoped_ptr<base::Value> data) { 673 scoped_ptr<base::Value> data) {
674 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 674 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
675 DCHECK(!callback.is_null()); 675 DCHECK(!callback.is_null());
676 676
677 if (params->feed_list->empty()) { 677 if (params->feed_list->empty()) {
678 UMA_HISTOGRAM_TIMES("Drive.InitialFeedLoadTime", 678 UMA_HISTOGRAM_TIMES("Drive.InitialFeedLoadTime",
679 base::TimeTicks::Now() - start_time); 679 base::TimeTicks::Now() - start_time);
680 } 680 }
681 681
682 GDataFileError error = util::GDataToGDataFileError(status); 682 DriveFileError error = util::GDataToDriveFileError(status);
683 if (error == GDATA_FILE_OK && 683 if (error == DRIVE_FILE_OK &&
684 (!data.get() || data->GetType() != Value::TYPE_DICTIONARY)) { 684 (!data.get() || data->GetType() != Value::TYPE_DICTIONARY)) {
685 error = GDATA_FILE_ERROR_FAILED; 685 error = DRIVE_FILE_ERROR_FAILED;
686 } 686 }
687 687
688 if (error != GDATA_FILE_OK) { 688 if (error != DRIVE_FILE_OK) {
689 resource_metadata_->set_origin(initial_origin); 689 resource_metadata_->set_origin(initial_origin);
690 callback.Run(params, error); 690 callback.Run(params, error);
691 return; 691 return;
692 } 692 }
693 693
694 GURL next_feed_url; 694 GURL next_feed_url;
695 scoped_ptr<ChangeList> current_feed(ChangeList::CreateFrom(*data)); 695 scoped_ptr<ChangeList> current_feed(ChangeList::CreateFrom(*data));
696 if (!current_feed.get()) { 696 if (!current_feed.get()) {
697 callback.Run(params, GDATA_FILE_ERROR_FAILED); 697 callback.Run(params, DRIVE_FILE_ERROR_FAILED);
698 return; 698 return;
699 } 699 }
700 const bool has_next_feed = !current_feed->next_page_token().empty(); 700 const bool has_next_feed = !current_feed->next_page_token().empty();
701 701
702 #ifndef NDEBUG 702 #ifndef NDEBUG
703 // Save initial root feed for analysis. 703 // Save initial root feed for analysis.
704 std::string file_name = 704 std::string file_name =
705 base::StringPrintf("DEBUG_changelist_%" PRId64 ".json", 705 base::StringPrintf("DEBUG_changelist_%" PRId64 ".json",
706 params->start_changestamp); 706 params->start_changestamp);
707 util::PostBlockingPoolSequencedTask( 707 util::PostBlockingPoolSequencedTask(
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 843
844 void GDataWapiFeedLoader::OnProtoLoaded(LoadRootFeedParams* params) { 844 void GDataWapiFeedLoader::OnProtoLoaded(LoadRootFeedParams* params) {
845 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 845 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
846 846
847 // If we have already received updates from the server, bail out. 847 // If we have already received updates from the server, bail out.
848 if (resource_metadata_->origin() == FROM_SERVER) 848 if (resource_metadata_->origin() == FROM_SERVER)
849 return; 849 return;
850 850
851 // Update directory structure only if everything is OK and we haven't yet 851 // Update directory structure only if everything is OK and we haven't yet
852 // received the feed from the server yet. 852 // received the feed from the server yet.
853 if (params->load_error == GDATA_FILE_OK) { 853 if (params->load_error == DRIVE_FILE_OK) {
854 DVLOG(1) << "ParseFromString"; 854 DVLOG(1) << "ParseFromString";
855 if (resource_metadata_->ParseFromString(params->proto)) { 855 if (resource_metadata_->ParseFromString(params->proto)) {
856 resource_metadata_->set_last_serialized(params->last_modified); 856 resource_metadata_->set_last_serialized(params->last_modified);
857 resource_metadata_->set_serialized_size(params->proto.size()); 857 resource_metadata_->set_serialized_size(params->proto.size());
858 } else { 858 } else {
859 params->load_error = GDATA_FILE_ERROR_FAILED; 859 params->load_error = DRIVE_FILE_ERROR_FAILED;
860 LOG(WARNING) << "Parse of cached proto file failed"; 860 LOG(WARNING) << "Parse of cached proto file failed";
861 } 861 }
862 } 862 }
863 863
864 ContinueWithInitializedDirectoryService(params, params->load_error); 864 ContinueWithInitializedDirectoryService(params, params->load_error);
865 } 865 }
866 866
867 void GDataWapiFeedLoader::ContinueWithInitializedDirectoryService( 867 void GDataWapiFeedLoader::ContinueWithInitializedDirectoryService(
868 LoadRootFeedParams* params, 868 LoadRootFeedParams* params,
869 GDataFileError error) { 869 DriveFileError error) {
870 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 870 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
871 871
872 DVLOG(1) << "Time elapsed to load directory service from disk=" 872 DVLOG(1) << "Time elapsed to load directory service from disk="
873 << (base::Time::Now() - params->load_start_time).InMilliseconds() 873 << (base::Time::Now() - params->load_start_time).InMilliseconds()
874 << " milliseconds"; 874 << " milliseconds";
875 875
876 // TODO(satorux): Simplify the callback handling. crbug.com/142799 876 // TODO(satorux): Simplify the callback handling. crbug.com/142799
877 FileOperationCallback callback = params->callback; 877 FileOperationCallback callback = params->callback;
878 // If we got feed content from cache, tell the client that the loading was 878 // If we got feed content from cache, tell the client that the loading was
879 // successful. 879 // successful.
880 if (error == GDATA_FILE_OK && !callback.is_null()) { 880 if (error == DRIVE_FILE_OK && !callback.is_null()) {
881 callback.Run(GDATA_FILE_OK); 881 callback.Run(DRIVE_FILE_OK);
882 // Reset the callback so we don't run the same callback once 882 // Reset the callback so we don't run the same callback once
883 // ReloadFeedFromServerIfNeeded() is complete. 883 // ReloadFeedFromServerIfNeeded() is complete.
884 callback.Reset(); 884 callback.Reset();
885 } 885 }
886 886
887 if (!params->should_load_from_server) 887 if (!params->should_load_from_server)
888 return; 888 return;
889 889
890 // Decide the |initial_origin| to pass to ReloadFromServerIfNeeded(). 890 // Decide the |initial_origin| to pass to ReloadFromServerIfNeeded().
891 // This is used to restore directory content origin to its initial value when 891 // This is used to restore directory content origin to its initial value when
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 resource_metadata_->set_last_serialized(base::Time::Now()); 927 resource_metadata_->set_last_serialized(base::Time::Now());
928 resource_metadata_->set_serialized_size(serialized_proto->size()); 928 resource_metadata_->set_serialized_size(serialized_proto->size());
929 util::PostBlockingPoolSequencedTask( 929 util::PostBlockingPoolSequencedTask(
930 FROM_HERE, 930 FROM_HERE,
931 blocking_task_runner_, 931 blocking_task_runner_,
932 base::Bind(&SaveProtoOnBlockingPool, path, 932 base::Bind(&SaveProtoOnBlockingPool, path,
933 base::Passed(serialized_proto.Pass()))); 933 base::Passed(serialized_proto.Pass())));
934 } 934 }
935 } 935 }
936 936
937 GDataFileError GDataWapiFeedLoader::UpdateFromFeed( 937 DriveFileError GDataWapiFeedLoader::UpdateFromFeed(
938 const std::vector<DocumentFeed*>& feed_list, 938 const std::vector<DocumentFeed*>& feed_list,
939 int64 start_changestamp, 939 int64 start_changestamp,
940 int64 root_feed_changestamp) { 940 int64 root_feed_changestamp) {
941 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 941 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
942 DVLOG(1) << "Updating directory with a feed"; 942 DVLOG(1) << "Updating directory with a feed";
943 943
944 std::set<FilePath> changed_dirs; 944 std::set<FilePath> changed_dirs;
945 945
946 GDataWapiFeedProcessor feed_processor(resource_metadata_); 946 GDataWapiFeedProcessor feed_processor(resource_metadata_);
947 const GDataFileError error = feed_processor.ApplyFeeds( 947 const DriveFileError error = feed_processor.ApplyFeeds(
948 feed_list, 948 feed_list,
949 start_changestamp, 949 start_changestamp,
950 root_feed_changestamp, 950 root_feed_changestamp,
951 &changed_dirs); 951 &changed_dirs);
952 952
953 // Don't send directory content change notification while performing 953 // Don't send directory content change notification while performing
954 // the initial content retrieval. 954 // the initial content retrieval.
955 const bool should_notify_directory_changed = (start_changestamp != 0); 955 const bool should_notify_directory_changed = (start_changestamp != 0);
956 if (should_notify_directory_changed) { 956 if (should_notify_directory_changed) {
957 for (std::set<FilePath>::iterator dir_iter = changed_dirs.begin(); 957 for (std::set<FilePath>::iterator dir_iter = changed_dirs.begin();
958 dir_iter != changed_dirs.end(); ++dir_iter) { 958 dir_iter != changed_dirs.end(); ++dir_iter) {
959 FOR_EACH_OBSERVER(Observer, observers_, 959 FOR_EACH_OBSERVER(Observer, observers_,
960 OnDirectoryChanged(*dir_iter)); 960 OnDirectoryChanged(*dir_iter));
961 } 961 }
962 } 962 }
963 963
964 return error; 964 return error;
965 } 965 }
966 966
967 } // namespace gdata 967 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_wapi_feed_loader.h ('k') | chrome/browser/chromeos/gdata/gdata_wapi_feed_processor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698