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/sync_file_system/sync_file_system_service.h" | 5 #include "chrome/browser/sync_file_system/sync_file_system_service.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
528 GetFileSyncStatus(url, base::Bind(completion_callback, file)); | 528 GetFileSyncStatus(url, base::Bind(completion_callback, file)); |
529 } | 529 } |
530 } | 530 } |
531 | 531 |
532 void SyncFileSystemService::DidDumpDatabase( | 532 void SyncFileSystemService::DidDumpDatabase( |
533 const DumpFilesCallback& callback, scoped_ptr<base::ListValue> list) { | 533 const DumpFilesCallback& callback, scoped_ptr<base::ListValue> list) { |
534 if (!list) | 534 if (!list) |
535 list = make_scoped_ptr(new base::ListValue); | 535 list = make_scoped_ptr(new base::ListValue); |
536 | 536 |
537 if (!v2_remote_service_) { | 537 if (!v2_remote_service_) { |
538 callback.Run(*list); | 538 if (list) |
peria
2014/08/08 09:45:04
Change for this part seems to do nothing, in actua
tzik
2014/08/08 09:50:57
Done.
| |
539 callback.Run(*list); | |
540 else | |
541 callback.Run(base::ListValue()); | |
539 return; | 542 return; |
540 } | 543 } |
541 | 544 |
542 v2_remote_service_->DumpDatabase( | 545 v2_remote_service_->DumpDatabase( |
543 base::Bind(&SyncFileSystemService::DidDumpV2Database, | 546 base::Bind(&SyncFileSystemService::DidDumpV2Database, |
544 AsWeakPtr(), callback, base::Passed(&list))); | 547 AsWeakPtr(), callback, base::Passed(&list))); |
545 } | 548 } |
546 | 549 |
547 void SyncFileSystemService::DidDumpV2Database( | 550 void SyncFileSystemService::DidDumpV2Database( |
548 const DumpFilesCallback& callback, | 551 const DumpFilesCallback& callback, |
549 scoped_ptr<base::ListValue> v1list, | 552 scoped_ptr<base::ListValue> v1list, |
550 scoped_ptr<base::ListValue> v2list) { | 553 scoped_ptr<base::ListValue> v2list) { |
551 DCHECK(v1list); | 554 if (!v1list) |
555 v1list.reset(new base::ListValue); | |
peria
2014/08/08 09:45:05
= make_scoped_ptr(new base::ListValue);
to be sam
tzik
2014/08/08 09:50:57
Done.
| |
552 | 556 |
553 if (v2list) { | 557 if (v2list) { |
554 for (base::ListValue::iterator itr = v2list->begin(); | 558 for (base::ListValue::iterator itr = v2list->begin(); |
555 itr != v2list->end();) { | 559 itr != v2list->end();) { |
556 scoped_ptr<base::Value> item; | 560 scoped_ptr<base::Value> item; |
557 itr = v2list->Erase(itr, &item); | 561 itr = v2list->Erase(itr, &item); |
558 v1list->Append(item.release()); | 562 v1list->Append(item.release()); |
559 } | 563 } |
560 } | 564 } |
561 | 565 |
562 callback.Run(*v1list); | 566 callback.Run(*v1list); |
563 } | 567 } |
564 | 568 |
565 void SyncFileSystemService::DidGetExtensionStatusMap( | 569 void SyncFileSystemService::DidGetExtensionStatusMap( |
566 const ExtensionStatusMapCallback& callback, | 570 const ExtensionStatusMapCallback& callback, |
567 scoped_ptr<RemoteFileSyncService::OriginStatusMap> status_map) { | 571 scoped_ptr<RemoteFileSyncService::OriginStatusMap> status_map) { |
568 if (!v2_remote_service_) { | 572 if (!v2_remote_service_) { |
peria
2014/08/08 09:45:04
I recommend to put
if (!status_map)
status_map
tzik
2014/08/08 09:50:57
Done.
| |
569 callback.Run(*status_map); | 573 if (status_map) |
574 callback.Run(*status_map); | |
575 else | |
576 callback.Run(RemoteFileSyncService::OriginStatusMap()); | |
570 return; | 577 return; |
571 } | 578 } |
572 | 579 |
573 v2_remote_service_->GetOriginStatusMap( | 580 v2_remote_service_->GetOriginStatusMap( |
574 base::Bind(&SyncFileSystemService::DidGetV2ExtensionStatusMap, | 581 base::Bind(&SyncFileSystemService::DidGetV2ExtensionStatusMap, |
575 AsWeakPtr(), | 582 AsWeakPtr(), |
576 callback, | 583 callback, |
577 base::Passed(&status_map))); | 584 base::Passed(&status_map))); |
578 } | 585 } |
579 | 586 |
580 void SyncFileSystemService::DidGetV2ExtensionStatusMap( | 587 void SyncFileSystemService::DidGetV2ExtensionStatusMap( |
581 const ExtensionStatusMapCallback& callback, | 588 const ExtensionStatusMapCallback& callback, |
582 scoped_ptr<RemoteFileSyncService::OriginStatusMap> status_map_v1, | 589 scoped_ptr<RemoteFileSyncService::OriginStatusMap> status_map_v1, |
583 scoped_ptr<RemoteFileSyncService::OriginStatusMap> status_map_v2) { | 590 scoped_ptr<RemoteFileSyncService::OriginStatusMap> status_map_v2) { |
584 // Merge |status_map_v2| into |status_map_v1|. | 591 // Merge |status_map_v2| into |status_map_v1|. |
585 status_map_v1->insert(status_map_v2->begin(), status_map_v2->end()); | 592 if (!status_map_v1) |
593 status_map_v1.reset(new RemoteFileSyncService::OriginStatusMap); | |
594 if (status_map_v2) | |
595 status_map_v1->insert(status_map_v2->begin(), status_map_v2->end()); | |
586 | 596 |
587 callback.Run(*status_map_v1); | 597 callback.Run(*status_map_v1); |
588 } | 598 } |
589 | 599 |
590 void SyncFileSystemService::SetSyncEnabledForTesting(bool enabled) { | 600 void SyncFileSystemService::SetSyncEnabledForTesting(bool enabled) { |
591 sync_enabled_ = enabled; | 601 sync_enabled_ = enabled; |
592 remote_service_->SetSyncEnabled(sync_enabled_); | 602 remote_service_->SetSyncEnabled(sync_enabled_); |
593 if (v2_remote_service_) | 603 if (v2_remote_service_) |
594 v2_remote_service_->SetSyncEnabled(sync_enabled_); | 604 v2_remote_service_->SetSyncEnabled(sync_enabled_); |
595 } | 605 } |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
753 v2_remote_service_->AddServiceObserver(v2_remote_syncer.get()); | 763 v2_remote_service_->AddServiceObserver(v2_remote_syncer.get()); |
754 v2_remote_service_->AddFileStatusObserver(this); | 764 v2_remote_service_->AddFileStatusObserver(this); |
755 v2_remote_service_->SetRemoteChangeProcessor(local_service_.get()); | 765 v2_remote_service_->SetRemoteChangeProcessor(local_service_.get()); |
756 v2_remote_service_->SetSyncEnabled(sync_enabled_); | 766 v2_remote_service_->SetSyncEnabled(sync_enabled_); |
757 remote_sync_runners_.push_back(v2_remote_syncer.release()); | 767 remote_sync_runners_.push_back(v2_remote_syncer.release()); |
758 } | 768 } |
759 return v2_remote_service_.get(); | 769 return v2_remote_service_.get(); |
760 } | 770 } |
761 | 771 |
762 } // namespace sync_file_system | 772 } // namespace sync_file_system |
OLD | NEW |