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

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

Issue 1873683002: Convert //chrome/browser/sync_file_system from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9
9 #include <string> 10 #include <string>
10 #include <utility> 11 #include <utility>
11 12
12 #include "base/bind.h" 13 #include "base/bind.h"
13 #include "base/format_macros.h" 14 #include "base/format_macros.h"
14 #include "base/logging.h" 15 #include "base/logging.h"
15 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ptr_util.h"
16 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
17 #include "base/metrics/histogram.h" 19 #include "base/metrics/histogram.h"
18 #include "base/single_thread_task_runner.h" 20 #include "base/single_thread_task_runner.h"
19 #include "base/stl_util.h" 21 #include "base/stl_util.h"
20 #include "base/thread_task_runner_handle.h" 22 #include "base/thread_task_runner_handle.h"
21 #include "chrome/browser/extensions/api/sync_file_system/extension_sync_event_ob server.h" 23 #include "chrome/browser/extensions/api/sync_file_system/extension_sync_event_ob server.h"
22 #include "chrome/browser/extensions/api/sync_file_system/sync_file_system_api_he lpers.h" 24 #include "chrome/browser/extensions/api/sync_file_system/sync_file_system_api_he lpers.h"
23 #include "chrome/browser/profiles/profile.h" 25 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/sync/profile_sync_service_factory.h" 26 #include "chrome/browser/sync/profile_sync_service_factory.h"
25 #include "chrome/browser/sync_file_system/local/local_file_sync_service.h" 27 #include "chrome/browser/sync_file_system/local/local_file_sync_service.h"
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 CheckIfIdle(); 443 CheckIfIdle();
442 } 444 }
443 445
444 SyncFileSystemService::SyncFileSystemService(Profile* profile) 446 SyncFileSystemService::SyncFileSystemService(Profile* profile)
445 : profile_(profile), 447 : profile_(profile),
446 sync_enabled_(true), 448 sync_enabled_(true),
447 promoting_demoted_changes_(false) { 449 promoting_demoted_changes_(false) {
448 } 450 }
449 451
450 void SyncFileSystemService::Initialize( 452 void SyncFileSystemService::Initialize(
451 scoped_ptr<LocalFileSyncService> local_service, 453 std::unique_ptr<LocalFileSyncService> local_service,
452 scoped_ptr<RemoteFileSyncService> remote_service) { 454 std::unique_ptr<RemoteFileSyncService> remote_service) {
453 DCHECK_CURRENTLY_ON(BrowserThread::UI); 455 DCHECK_CURRENTLY_ON(BrowserThread::UI);
454 DCHECK(local_service); 456 DCHECK(local_service);
455 DCHECK(remote_service); 457 DCHECK(remote_service);
456 DCHECK(profile_); 458 DCHECK(profile_);
457 459
458 local_service_ = std::move(local_service); 460 local_service_ = std::move(local_service);
459 remote_service_ = std::move(remote_service); 461 remote_service_ = std::move(remote_service);
460 462
461 scoped_ptr<LocalSyncRunner> local_syncer( 463 std::unique_ptr<LocalSyncRunner> local_syncer(
462 new LocalSyncRunner(kLocalSyncName, this)); 464 new LocalSyncRunner(kLocalSyncName, this));
463 scoped_ptr<RemoteSyncRunner> remote_syncer( 465 std::unique_ptr<RemoteSyncRunner> remote_syncer(
464 new RemoteSyncRunner(kRemoteSyncName, this, remote_service_.get())); 466 new RemoteSyncRunner(kRemoteSyncName, this, remote_service_.get()));
465 467
466 local_service_->AddChangeObserver(local_syncer.get()); 468 local_service_->AddChangeObserver(local_syncer.get());
467 local_service_->SetLocalChangeProcessorCallback( 469 local_service_->SetLocalChangeProcessorCallback(
468 base::Bind(&GetLocalChangeProcessorAdapter, AsWeakPtr())); 470 base::Bind(&GetLocalChangeProcessorAdapter, AsWeakPtr()));
469 471
470 remote_service_->AddServiceObserver(remote_syncer.get()); 472 remote_service_->AddServiceObserver(remote_syncer.get());
471 remote_service_->AddFileStatusObserver(this); 473 remote_service_->AddFileStatusObserver(this);
472 remote_service_->SetRemoteChangeProcessor(local_service_.get()); 474 remote_service_->SetRemoteChangeProcessor(local_service_.get());
473 475
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 base::Bind( 567 base::Bind(
566 &SyncFileSystemService::DidDumpFiles, 568 &SyncFileSystemService::DidDumpFiles,
567 AsWeakPtr(), 569 AsWeakPtr(),
568 origin, 570 origin,
569 callback)); 571 callback));
570 } 572 }
571 573
572 void SyncFileSystemService::DidDumpFiles( 574 void SyncFileSystemService::DidDumpFiles(
573 const GURL& origin, 575 const GURL& origin,
574 const DumpFilesCallback& callback, 576 const DumpFilesCallback& callback,
575 scoped_ptr<base::ListValue> dump_files) { 577 std::unique_ptr<base::ListValue> dump_files) {
576 if (!dump_files || !dump_files->GetSize() || 578 if (!dump_files || !dump_files->GetSize() ||
577 !local_service_ || !remote_service_) { 579 !local_service_ || !remote_service_) {
578 callback.Run(base::ListValue()); 580 callback.Run(base::ListValue());
579 return; 581 return;
580 } 582 }
581 583
582 base::ListValue* files = dump_files.get(); 584 base::ListValue* files = dump_files.get();
583 base::Callback<void(base::DictionaryValue*, 585 base::Callback<void(base::DictionaryValue*,
584 SyncStatusCode, 586 SyncStatusCode,
585 SyncFileStatus)> completion_callback = 587 SyncFileStatus)> completion_callback =
(...skipping 13 matching lines...) Expand all
599 nullptr, SYNC_FILE_ERROR_FAILED, SYNC_FILE_STATUS_UNKNOWN); 601 nullptr, SYNC_FILE_ERROR_FAILED, SYNC_FILE_STATUS_UNKNOWN);
600 continue; 602 continue;
601 } 603 }
602 604
603 base::FilePath file_path = base::FilePath::FromUTF8Unsafe(path_string); 605 base::FilePath file_path = base::FilePath::FromUTF8Unsafe(path_string);
604 FileSystemURL url = CreateSyncableFileSystemURL(origin, file_path); 606 FileSystemURL url = CreateSyncableFileSystemURL(origin, file_path);
605 GetFileSyncStatus(url, base::Bind(completion_callback, file)); 607 GetFileSyncStatus(url, base::Bind(completion_callback, file));
606 } 608 }
607 } 609 }
608 610
609 void SyncFileSystemService::DidDumpDatabase(const DumpFilesCallback& callback, 611 void SyncFileSystemService::DidDumpDatabase(
610 scoped_ptr<base::ListValue> list) { 612 const DumpFilesCallback& callback,
613 std::unique_ptr<base::ListValue> list) {
611 if (!list) 614 if (!list)
612 list = make_scoped_ptr(new base::ListValue); 615 list = base::WrapUnique(new base::ListValue);
613 callback.Run(*list); 616 callback.Run(*list);
614 } 617 }
615 618
616 void SyncFileSystemService::DidGetExtensionStatusMap( 619 void SyncFileSystemService::DidGetExtensionStatusMap(
617 const ExtensionStatusMapCallback& callback, 620 const ExtensionStatusMapCallback& callback,
618 scoped_ptr<RemoteFileSyncService::OriginStatusMap> status_map) { 621 std::unique_ptr<RemoteFileSyncService::OriginStatusMap> status_map) {
619 if (!status_map) 622 if (!status_map)
620 status_map = make_scoped_ptr(new RemoteFileSyncService::OriginStatusMap); 623 status_map = base::WrapUnique(new RemoteFileSyncService::OriginStatusMap);
621 callback.Run(*status_map); 624 callback.Run(*status_map);
622 } 625 }
623 626
624 void SyncFileSystemService::SetSyncEnabledForTesting(bool enabled) { 627 void SyncFileSystemService::SetSyncEnabledForTesting(bool enabled) {
625 sync_enabled_ = enabled; 628 sync_enabled_ = enabled;
626 remote_service_->SetSyncEnabled(sync_enabled_); 629 remote_service_->SetSyncEnabled(sync_enabled_);
627 } 630 }
628 631
629 void SyncFileSystemService::DidGetLocalChangeStatus( 632 void SyncFileSystemService::DidGetLocalChangeStatus(
630 const SyncFileStatusCallback& callback, 633 const SyncFileStatusCallback& callback,
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 local_sync_runners_.begin(); 765 local_sync_runners_.begin();
763 iter != local_sync_runners_.end(); ++iter) 766 iter != local_sync_runners_.end(); ++iter)
764 ((*iter)->*method)(); 767 ((*iter)->*method)();
765 for (ScopedVector<SyncProcessRunner>::iterator iter = 768 for (ScopedVector<SyncProcessRunner>::iterator iter =
766 remote_sync_runners_.begin(); 769 remote_sync_runners_.begin();
767 iter != remote_sync_runners_.end(); ++iter) 770 iter != remote_sync_runners_.end(); ++iter)
768 ((*iter)->*method)(); 771 ((*iter)->*method)();
769 } 772 }
770 773
771 } // namespace sync_file_system 774 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698