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

Side by Side Diff: chrome/browser/sync_file_system/sync_file_system_service.cc

Issue 452063002: [SyncFS] Crash fix on chrome://syncfs-internals (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 541
542 v2_remote_service_->DumpDatabase( 542 v2_remote_service_->DumpDatabase(
543 base::Bind(&SyncFileSystemService::DidDumpV2Database, 543 base::Bind(&SyncFileSystemService::DidDumpV2Database,
544 AsWeakPtr(), callback, base::Passed(&list))); 544 AsWeakPtr(), callback, base::Passed(&list)));
545 } 545 }
546 546
547 void SyncFileSystemService::DidDumpV2Database( 547 void SyncFileSystemService::DidDumpV2Database(
548 const DumpFilesCallback& callback, 548 const DumpFilesCallback& callback,
549 scoped_ptr<base::ListValue> v1list, 549 scoped_ptr<base::ListValue> v1list,
550 scoped_ptr<base::ListValue> v2list) { 550 scoped_ptr<base::ListValue> v2list) {
551 DCHECK(v1list); 551 if (!v1list)
552 v1list = make_scoped_ptr(new base::ListValue);
552 553
553 if (v2list) { 554 if (v2list) {
554 for (base::ListValue::iterator itr = v2list->begin(); 555 for (base::ListValue::iterator itr = v2list->begin();
555 itr != v2list->end();) { 556 itr != v2list->end();) {
556 scoped_ptr<base::Value> item; 557 scoped_ptr<base::Value> item;
557 itr = v2list->Erase(itr, &item); 558 itr = v2list->Erase(itr, &item);
558 v1list->Append(item.release()); 559 v1list->Append(item.release());
559 } 560 }
560 } 561 }
561 562
562 callback.Run(*v1list); 563 callback.Run(*v1list);
563 } 564 }
564 565
565 void SyncFileSystemService::DidGetExtensionStatusMap( 566 void SyncFileSystemService::DidGetExtensionStatusMap(
566 const ExtensionStatusMapCallback& callback, 567 const ExtensionStatusMapCallback& callback,
567 scoped_ptr<RemoteFileSyncService::OriginStatusMap> status_map) { 568 scoped_ptr<RemoteFileSyncService::OriginStatusMap> status_map) {
569 if (!status_map)
570 status_map = make_scoped_ptr(new RemoteFileSyncService::OriginStatusMap);
568 if (!v2_remote_service_) { 571 if (!v2_remote_service_) {
569 callback.Run(*status_map); 572 callback.Run(*status_map);
570 return; 573 return;
571 } 574 }
572 575
573 v2_remote_service_->GetOriginStatusMap( 576 v2_remote_service_->GetOriginStatusMap(
574 base::Bind(&SyncFileSystemService::DidGetV2ExtensionStatusMap, 577 base::Bind(&SyncFileSystemService::DidGetV2ExtensionStatusMap,
575 AsWeakPtr(), 578 AsWeakPtr(),
576 callback, 579 callback,
577 base::Passed(&status_map))); 580 base::Passed(&status_map)));
578 } 581 }
579 582
580 void SyncFileSystemService::DidGetV2ExtensionStatusMap( 583 void SyncFileSystemService::DidGetV2ExtensionStatusMap(
581 const ExtensionStatusMapCallback& callback, 584 const ExtensionStatusMapCallback& callback,
582 scoped_ptr<RemoteFileSyncService::OriginStatusMap> status_map_v1, 585 scoped_ptr<RemoteFileSyncService::OriginStatusMap> status_map_v1,
583 scoped_ptr<RemoteFileSyncService::OriginStatusMap> status_map_v2) { 586 scoped_ptr<RemoteFileSyncService::OriginStatusMap> status_map_v2) {
584 // Merge |status_map_v2| into |status_map_v1|. 587 // Merge |status_map_v2| into |status_map_v1|.
585 status_map_v1->insert(status_map_v2->begin(), status_map_v2->end()); 588 if (!status_map_v1)
589 status_map_v1 = make_scoped_ptr(new RemoteFileSyncService::OriginStatusMap);
590 if (status_map_v2)
591 status_map_v1->insert(status_map_v2->begin(), status_map_v2->end());
586 592
587 callback.Run(*status_map_v1); 593 callback.Run(*status_map_v1);
588 } 594 }
589 595
590 void SyncFileSystemService::SetSyncEnabledForTesting(bool enabled) { 596 void SyncFileSystemService::SetSyncEnabledForTesting(bool enabled) {
591 sync_enabled_ = enabled; 597 sync_enabled_ = enabled;
592 remote_service_->SetSyncEnabled(sync_enabled_); 598 remote_service_->SetSyncEnabled(sync_enabled_);
593 if (v2_remote_service_) 599 if (v2_remote_service_)
594 v2_remote_service_->SetSyncEnabled(sync_enabled_); 600 v2_remote_service_->SetSyncEnabled(sync_enabled_);
595 } 601 }
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 v2_remote_service_->AddServiceObserver(v2_remote_syncer.get()); 759 v2_remote_service_->AddServiceObserver(v2_remote_syncer.get());
754 v2_remote_service_->AddFileStatusObserver(this); 760 v2_remote_service_->AddFileStatusObserver(this);
755 v2_remote_service_->SetRemoteChangeProcessor(local_service_.get()); 761 v2_remote_service_->SetRemoteChangeProcessor(local_service_.get());
756 v2_remote_service_->SetSyncEnabled(sync_enabled_); 762 v2_remote_service_->SetSyncEnabled(sync_enabled_);
757 remote_sync_runners_.push_back(v2_remote_syncer.release()); 763 remote_sync_runners_.push_back(v2_remote_syncer.release());
758 } 764 }
759 return v2_remote_service_.get(); 765 return v2_remote_service_.get();
760 } 766 }
761 767
762 } // namespace sync_file_system 768 } // namespace sync_file_system
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698