Skip to content

Commit

Permalink
Replace scoped_ptr with std::unique_ptr in //components/sync_sessions
Browse files Browse the repository at this point in the history
R=pavely@chromium.org, stanisc@chromium.org, zea@chromium.org
TBR=brettw
BUG=554298

Review URL: https://codereview.chromium.org/1920503002

Cr-Commit-Position: refs/heads/master@{#389300}
  • Loading branch information
danakj authored and Commit bot committed Apr 22, 2016
1 parent ef0f419 commit 5b9c7ed
Show file tree
Hide file tree
Showing 23 changed files with 131 additions and 123 deletions.
2 changes: 1 addition & 1 deletion components/sync_sessions/fake_sync_sessions_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ FakeSyncSessionsClient::GetSyncedWindowDelegatesGetter() {
return nullptr;
}

scoped_ptr<browser_sync::LocalSessionEventRouter>
std::unique_ptr<browser_sync::LocalSessionEventRouter>
FakeSyncSessionsClient::GetLocalSessionEventRouter() {
return nullptr;
}
Expand Down
4 changes: 2 additions & 2 deletions components/sync_sessions/fake_sync_sessions_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class FakeSyncSessionsClient : public SyncSessionsClient {
bool ShouldSyncURL(const GURL& url) const override;
browser_sync::SyncedWindowDelegatesGetter* GetSyncedWindowDelegatesGetter()
override;
scoped_ptr<browser_sync::LocalSessionEventRouter> GetLocalSessionEventRouter()
override;
std::unique_ptr<browser_sync::LocalSessionEventRouter>
GetLocalSessionEventRouter() override;

private:
DISALLOW_COPY_AND_ASSIGN(FakeSyncSessionsClient);
Expand Down
4 changes: 2 additions & 2 deletions components/sync_sessions/favicon_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ FaviconCache::~FaviconCache() {}
syncer::SyncMergeResult FaviconCache::MergeDataAndStartSyncing(
syncer::ModelType type,
const syncer::SyncDataList& initial_sync_data,
scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
scoped_ptr<syncer::SyncErrorFactory> error_handler) {
std::unique_ptr<syncer::SyncChangeProcessor> sync_processor,
std::unique_ptr<syncer::SyncErrorFactory> error_handler) {
DCHECK(type == syncer::FAVICON_IMAGES || type == syncer::FAVICON_TRACKING);
if (type == syncer::FAVICON_IMAGES)
favicon_images_sync_processor_ = std::move(sync_processor);
Expand Down
10 changes: 5 additions & 5 deletions components/sync_sessions/favicon_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <stdint.h>

#include <map>
#include <memory>
#include <set>
#include <string>
#include <vector>
Expand All @@ -19,7 +20,6 @@
#include "base/memory/linked_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/memory/ref_counted_memory.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/scoped_observer.h"
#include "base/task/cancelable_task_tracker.h"
Expand Down Expand Up @@ -69,8 +69,8 @@ class FaviconCache : public syncer::SyncableService,
syncer::SyncMergeResult MergeDataAndStartSyncing(
syncer::ModelType type,
const syncer::SyncDataList& initial_sync_data,
scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
scoped_ptr<syncer::SyncErrorFactory> error_handler) override;
std::unique_ptr<syncer::SyncChangeProcessor> sync_processor,
std::unique_ptr<syncer::SyncErrorFactory> error_handler) override;
void StopSyncing(syncer::ModelType type) override;
syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override;
syncer::SyncError ProcessSyncChanges(
Expand Down Expand Up @@ -235,8 +235,8 @@ class FaviconCache : public syncer::SyncableService,
// TODO(zea): consider creating a favicon handler here for fetching unsynced
// favicons from the web.

scoped_ptr<syncer::SyncChangeProcessor> favicon_images_sync_processor_;
scoped_ptr<syncer::SyncChangeProcessor> favicon_tracking_sync_processor_;
std::unique_ptr<syncer::SyncChangeProcessor> favicon_images_sync_processor_;
std::unique_ptr<syncer::SyncChangeProcessor> favicon_tracking_sync_processor_;

// Maximum number of favicons to sync. 0 means no limit.
const size_t max_sync_favicon_limit_;
Expand Down
21 changes: 11 additions & 10 deletions components/sync_sessions/favicon_cache_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <stdint.h>

#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
Expand Down Expand Up @@ -276,8 +277,8 @@ class SyncFaviconCacheTest : public testing::Test {
testing::AssertionResult VerifyLocalCustomIcons(
const std::vector<TestFaviconData>& expected_icons);

scoped_ptr<syncer::SyncChangeProcessor> CreateAndPassProcessor();
scoped_ptr<syncer::SyncErrorFactory> CreateAndPassSyncErrorFactory();
std::unique_ptr<syncer::SyncChangeProcessor> CreateAndPassProcessor();
std::unique_ptr<syncer::SyncErrorFactory> CreateAndPassSyncErrorFactory();

FaviconCache* cache() { return &cache_; }
TestChangeProcessor* processor() { return sync_processor_.get(); }
Expand All @@ -297,8 +298,9 @@ class SyncFaviconCacheTest : public testing::Test {
FaviconCache cache_;

// Our dummy ChangeProcessor used to inspect changes pushed to Sync.
scoped_ptr<TestChangeProcessor> sync_processor_;
scoped_ptr<syncer::SyncChangeProcessorWrapperForTest> sync_processor_wrapper_;
std::unique_ptr<TestChangeProcessor> sync_processor_;
std::unique_ptr<syncer::SyncChangeProcessorWrapperForTest>
sync_processor_wrapper_;
};

SyncFaviconCacheTest::SyncFaviconCacheTest()
Expand Down Expand Up @@ -397,16 +399,15 @@ testing::AssertionResult SyncFaviconCacheTest::VerifyLocalCustomIcons(
return testing::AssertionSuccess();
}

scoped_ptr<syncer::SyncChangeProcessor>
std::unique_ptr<syncer::SyncChangeProcessor>
SyncFaviconCacheTest::CreateAndPassProcessor() {
return scoped_ptr<syncer::SyncChangeProcessor>(
return base::WrapUnique(
new syncer::SyncChangeProcessorWrapperForTest(sync_processor_.get()));
}

scoped_ptr<syncer::SyncErrorFactory> SyncFaviconCacheTest::
CreateAndPassSyncErrorFactory() {
return scoped_ptr<syncer::SyncErrorFactory>(
new syncer::SyncErrorFactoryMock());
std::unique_ptr<syncer::SyncErrorFactory>
SyncFaviconCacheTest::CreateAndPassSyncErrorFactory() {
return base::WrapUnique(new syncer::SyncErrorFactoryMock);
}

void SyncFaviconCacheTest::OnCustomFaviconDataAvailable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
namespace sync_sessions {

BookmarksPageRevisitObserver::BookmarksPageRevisitObserver(
scoped_ptr<BookmarksByUrlProvider> provider)
std::unique_ptr<BookmarksByUrlProvider> provider)
: provider_(std::move(provider)) {}

BookmarksPageRevisitObserver::~BookmarksPageRevisitObserver() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#ifndef COMPONENTS_SYNC_SESSIONS_REVISIT_BOOKMARKS_PAGE_REVISIT_OBSERVER_H_
#define COMPONENTS_SYNC_SESSIONS_REVISIT_BOOKMARKS_PAGE_REVISIT_OBSERVER_H_

#include <memory>
#include <vector>

#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "components/sync_sessions/revisit/page_visit_observer.h"

class GURL;
Expand Down Expand Up @@ -40,12 +40,12 @@ class BookmarksByUrlProvider {
class BookmarksPageRevisitObserver : public sync_sessions::PageVisitObserver {
public:
explicit BookmarksPageRevisitObserver(
scoped_ptr<BookmarksByUrlProvider> provider);
std::unique_ptr<BookmarksByUrlProvider> provider);
~BookmarksPageRevisitObserver() override;
void OnPageVisit(const GURL& url, const TransitionType transition) override;

private:
scoped_ptr<BookmarksByUrlProvider> provider_;
std::unique_ptr<BookmarksByUrlProvider> provider_;
DISALLOW_COPY_AND_ASSIGN(BookmarksPageRevisitObserver);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

#include "components/sync_sessions/revisit/bookmarks_page_revisit_observer.h"

#include <memory>
#include <vector>

#include "base/memory/scoped_ptr.h"
#include "base/memory/ptr_util.h"
#include "base/test/histogram_tester.h"
#include "components/bookmarks/browser/bookmark_node.h"
#include "components/sync_sessions/revisit/page_visit_observer.h"
Expand Down Expand Up @@ -37,8 +38,8 @@ class TestBookmarksByUrlProvider : public BookmarksByUrlProvider {
} // namespace

void RunObserver(const std::vector<const bookmarks::BookmarkNode*>& nodes) {
BookmarksPageRevisitObserver observer(scoped_ptr<BookmarksByUrlProvider>(
new TestBookmarksByUrlProvider(nodes)));
BookmarksPageRevisitObserver observer(
base::WrapUnique(new TestBookmarksByUrlProvider(nodes)));
observer.OnPageVisit(kExampleGurl, PageVisitObserver::kTransitionPage);
}

Expand Down
18 changes: 9 additions & 9 deletions components/sync_sessions/revisit/current_tab_matcher_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

#include "components/sync_sessions/revisit/current_tab_matcher.h"

#include <memory>
#include <string>

#include "base/memory/scoped_ptr.h"
#include "base/test/histogram_tester.h"
#include "base/time/time.h"
#include "components/sessions/core/serialized_navigation_entry.h"
Expand All @@ -31,8 +31,8 @@ sessions::SerializedNavigationEntry Entry(const std::string& url) {
"");
}

scoped_ptr<SessionTab> Tab(const int index, const base::Time timestamp) {
scoped_ptr<SessionTab> tab(new SessionTab());
std::unique_ptr<SessionTab> Tab(const int index, const base::Time timestamp) {
std::unique_ptr<SessionTab> tab(new SessionTab());
tab->current_navigation_index = index;
tab->timestamp = timestamp;
return tab;
Expand Down Expand Up @@ -61,14 +61,14 @@ TEST(CurrentTabMatcherTest, NoCheck) {
}

TEST(CurrentTabMatcherTest, EmptyTab) {
scoped_ptr<SessionTab> tab = Tab(0, base::Time::Now());
std::unique_ptr<SessionTab> tab = Tab(0, base::Time::Now());
CurrentTabMatcher matcher((PageEquality(GURL(kExampleUrl))));
matcher.Check(tab.get());
VerifyMiss(&matcher);
}

TEST(CurrentTabMatcherTest, SameUrl) {
scoped_ptr<SessionTab> tab = Tab(0, base::Time::Now());
std::unique_ptr<SessionTab> tab = Tab(0, base::Time::Now());
tab->navigations.push_back(Entry(kExampleUrl));

CurrentTabMatcher matcher((PageEquality(GURL(kExampleUrl))));
Expand All @@ -77,7 +77,7 @@ TEST(CurrentTabMatcherTest, SameUrl) {
}

TEST(CurrentTabMatcherTest, DifferentUrl) {
scoped_ptr<SessionTab> tab = Tab(0, base::Time::Now());
std::unique_ptr<SessionTab> tab = Tab(0, base::Time::Now());
tab->navigations.push_back(Entry(kDifferentUrl));

CurrentTabMatcher matcher((PageEquality(GURL(kExampleUrl))));
Expand All @@ -86,7 +86,7 @@ TEST(CurrentTabMatcherTest, DifferentUrl) {
}

TEST(CurrentTabMatcherTest, DifferentIndex) {
scoped_ptr<SessionTab> tab = Tab(0, base::Time::Now());
std::unique_ptr<SessionTab> tab = Tab(0, base::Time::Now());
tab->navigations.push_back(Entry(kDifferentUrl));
tab->navigations.push_back(Entry(kExampleUrl));

Expand All @@ -96,10 +96,10 @@ TEST(CurrentTabMatcherTest, DifferentIndex) {
}

TEST(CurrentTabMatcherTest, Timestamp) {
scoped_ptr<SessionTab> tab1 = Tab(0, base::Time::UnixEpoch());
std::unique_ptr<SessionTab> tab1 = Tab(0, base::Time::UnixEpoch());
tab1->navigations.push_back(Entry(kExampleUrl));

scoped_ptr<SessionTab> tab2 = Tab(0, base::Time::Now());
std::unique_ptr<SessionTab> tab2 = Tab(0, base::Time::Now());
tab2->navigations.push_back(Entry(kExampleUrl));

CurrentTabMatcher matcher1((PageEquality(GURL(kExampleUrl))));
Expand Down
33 changes: 17 additions & 16 deletions components/sync_sessions/revisit/offset_tab_matcher_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

#include "components/sync_sessions/revisit/offset_tab_matcher.h"

#include <memory>
#include <string>

#include "base/memory/scoped_ptr.h"
#include "base/test/histogram_tester.h"
#include "base/time/time.h"
#include "components/sessions/core/serialized_navigation_entry.h"
Expand All @@ -31,9 +31,10 @@ sessions::SerializedNavigationEntry Entry(const std::string& url) {
"");
}

scoped_ptr<SessionTab> Tab(const int index,
const base::Time timestamp = base::Time::Now()) {
scoped_ptr<SessionTab> tab(new SessionTab());
std::unique_ptr<SessionTab> Tab(
const int index,
const base::Time timestamp = base::Time::Now()) {
std::unique_ptr<SessionTab> tab(new SessionTab());
tab->current_navigation_index = index;
tab->timestamp = timestamp;
return tab;
Expand Down Expand Up @@ -66,14 +67,14 @@ TEST(OffsetTabMatcherTest, NoCheck) {
}

TEST(OffsetTabMatcherTest, EmptyTab) {
scoped_ptr<SessionTab> tab = Tab(0);
std::unique_ptr<SessionTab> tab = Tab(0);
OffsetTabMatcher matcher((PageEquality(GURL(kExampleUrl))));
matcher.Check(tab.get());
VerifyMiss(&matcher);
}

TEST(OffsetTabMatcherTest, HasMatchForward) {
scoped_ptr<SessionTab> tab = Tab(0);
std::unique_ptr<SessionTab> tab = Tab(0);
tab->navigations.push_back(Entry(kDifferentUrl));
tab->navigations.push_back(Entry(kExampleUrl));

Expand All @@ -83,7 +84,7 @@ TEST(OffsetTabMatcherTest, HasMatchForward) {
}

TEST(OffsetTabMatcherTest, HasMatchBackward) {
scoped_ptr<SessionTab> tab = Tab(1);
std::unique_ptr<SessionTab> tab = Tab(1);
tab->navigations.push_back(Entry(kExampleUrl));
tab->navigations.push_back(Entry(kDifferentUrl));

Expand All @@ -93,7 +94,7 @@ TEST(OffsetTabMatcherTest, HasMatchBackward) {
}

TEST(OffsetTabMatcherTest, NoMatch) {
scoped_ptr<SessionTab> tab = Tab(0);
std::unique_ptr<SessionTab> tab = Tab(0);
tab->navigations.push_back(Entry(kExampleUrl));
tab->navigations.push_back(Entry(kDifferentUrl));

Expand All @@ -103,7 +104,7 @@ TEST(OffsetTabMatcherTest, NoMatch) {
}

TEST(OffsetTabMatcherTest, MultipleBackwardOffsets) {
scoped_ptr<SessionTab> tab = Tab(4);
std::unique_ptr<SessionTab> tab = Tab(4);
tab->navigations.push_back(Entry(kExampleUrl));
tab->navigations.push_back(Entry(kExampleUrl));
tab->navigations.push_back(Entry(kExampleUrl)); // Expected.
Expand All @@ -116,7 +117,7 @@ TEST(OffsetTabMatcherTest, MultipleBackwardOffsets) {
}

TEST(OffsetTabMatcherTest, MultipleOffsets) {
scoped_ptr<SessionTab> tab = Tab(1);
std::unique_ptr<SessionTab> tab = Tab(1);
tab->navigations.push_back(Entry(kExampleUrl));
tab->navigations.push_back(Entry(kExampleUrl)); // Current.
tab->navigations.push_back(Entry(kExampleUrl));
Expand All @@ -129,7 +130,7 @@ TEST(OffsetTabMatcherTest, MultipleOffsets) {
}

TEST(OffsetTabMatcherTest, VeryForwardOffset) {
scoped_ptr<SessionTab> tab = Tab(0);
std::unique_ptr<SessionTab> tab = Tab(0);
for (int i = 0; i < 20; i++) {
tab->navigations.push_back(Entry(kDifferentUrl));
}
Expand All @@ -142,7 +143,7 @@ TEST(OffsetTabMatcherTest, VeryForwardOffset) {
}

TEST(OffsetTabMatcherTest, VeryBackwardOffset) {
scoped_ptr<SessionTab> tab = Tab(20);
std::unique_ptr<SessionTab> tab = Tab(20);
tab->navigations.push_back(Entry(kExampleUrl));
for (int i = 0; i < 20; i++) {
tab->navigations.push_back(Entry(kDifferentUrl));
Expand All @@ -155,11 +156,11 @@ TEST(OffsetTabMatcherTest, VeryBackwardOffset) {
}

TEST(OffsetTabMatcherTest, MultipleTabs) {
scoped_ptr<SessionTab> tab1 = Tab(0, base::Time::UnixEpoch());
std::unique_ptr<SessionTab> tab1 = Tab(0, base::Time::UnixEpoch());
tab1->navigations.push_back(Entry(kExampleUrl));
tab1->navigations.push_back(Entry(kExampleUrl));

scoped_ptr<SessionTab> tab2 = Tab(1, base::Time::Now());
std::unique_ptr<SessionTab> tab2 = Tab(1, base::Time::Now());
tab2->navigations.push_back(Entry(kExampleUrl));
tab2->navigations.push_back(Entry(kExampleUrl));

Expand All @@ -172,11 +173,11 @@ TEST(OffsetTabMatcherTest, MultipleTabs) {
TEST(OffsetTabMatcherTest, MultipleTabsSameTime) {
base::Time shared_now = base::Time::Now();

scoped_ptr<SessionTab> tab1 = Tab(0, shared_now);
std::unique_ptr<SessionTab> tab1 = Tab(0, shared_now);
tab1->navigations.push_back(Entry(kExampleUrl));
tab1->navigations.push_back(Entry(kExampleUrl));

scoped_ptr<SessionTab> tab2 = Tab(1, shared_now);
std::unique_ptr<SessionTab> tab2 = Tab(1, shared_now);
tab2->navigations.push_back(Entry(kExampleUrl));
tab2->navigations.push_back(Entry(kExampleUrl));

Expand Down
Loading

0 comments on commit 5b9c7ed

Please sign in to comment.