| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/profiles/profile_statistics.h" | 5 #include "chrome/browser/profiles/profile_statistics.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 content::BrowserContext* context) { | 35 content::BrowserContext* context) { |
| 36 Profile* profile = Profile::FromBrowserContext(context); | 36 Profile* profile = Profile::FromBrowserContext(context); |
| 37 std::unique_ptr<bookmarks::BookmarkModel> bookmark_model( | 37 std::unique_ptr<bookmarks::BookmarkModel> bookmark_model( |
| 38 new bookmarks::BookmarkModel(base::WrapUnique(new ChromeBookmarkClient( | 38 new bookmarks::BookmarkModel(base::WrapUnique(new ChromeBookmarkClient( |
| 39 profile, ManagedBookmarkServiceFactory::GetForProfile(profile))))); | 39 profile, ManagedBookmarkServiceFactory::GetForProfile(profile))))); |
| 40 return std::move(bookmark_model); | 40 return std::move(bookmark_model); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void LoadBookmarkModel(Profile* profile, | 43 void LoadBookmarkModel(Profile* profile, |
| 44 bookmarks::BookmarkModel* bookmark_model) { | 44 bookmarks::BookmarkModel* bookmark_model) { |
| 45 bookmark_model->Load(profile->GetPrefs(), | 45 bookmark_model->Load(profile->GetPrefs(), profile->GetPath(), |
| 46 profile->GetPath(), | |
| 47 profile->GetIOTaskRunner(), | 46 profile->GetIOTaskRunner(), |
| 48 content::BrowserThread::GetMessageLoopProxyForThread( | 47 content::BrowserThread::GetTaskRunnerForThread( |
| 49 content::BrowserThread::UI)); | 48 content::BrowserThread::UI)); |
| 50 } | 49 } |
| 51 | 50 |
| 52 bookmarks::BookmarkModel* CreateBookmarkModelWithoutLoad(Profile* profile) { | 51 bookmarks::BookmarkModel* CreateBookmarkModelWithoutLoad(Profile* profile) { |
| 53 return static_cast<bookmarks::BookmarkModel*>( | 52 return static_cast<bookmarks::BookmarkModel*>( |
| 54 BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse( | 53 BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse( |
| 55 profile, BuildBookmarkModelWithoutLoad)); | 54 profile, BuildBookmarkModelWithoutLoad)); |
| 56 } | 55 } |
| 57 | 56 |
| 58 class BookmarkStatHelper { | 57 class BookmarkStatHelper { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 run_loop2.RunUntilIdle(); | 176 run_loop2.RunUntilIdle(); |
| 178 EXPECT_EQ(0, bookmark_stat_helper.GetNumOfTimesCalled()); | 177 EXPECT_EQ(0, bookmark_stat_helper.GetNumOfTimesCalled()); |
| 179 | 178 |
| 180 // Load the bookmark model. When the model is loaded (asynchronously), the | 179 // Load the bookmark model. When the model is loaded (asynchronously), the |
| 181 // observer added by WaitOrCountBookmarks is run. | 180 // observer added by WaitOrCountBookmarks is run. |
| 182 LoadBookmarkModel(profile, bookmark_model); | 181 LoadBookmarkModel(profile, bookmark_model); |
| 183 | 182 |
| 184 run_loop_aggregator_destruction.Run(); | 183 run_loop_aggregator_destruction.Run(); |
| 185 EXPECT_EQ(1, bookmark_stat_helper.GetNumOfTimesCalled()); | 184 EXPECT_EQ(1, bookmark_stat_helper.GetNumOfTimesCalled()); |
| 186 } | 185 } |
| OLD | NEW |