Chromium Code Reviews| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/memory/weak_ptr.h" | 6 #include "base/memory/weak_ptr.h" |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/task/cancelable_task_tracker.h" | 9 #include "base/task/cancelable_task_tracker.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| 11 #include "chrome/browser/history/history_notifications.h" | 11 #include "chrome/browser/history/history_notifications.h" |
| 12 #include "chrome/browser/history/history_service_factory.h" | 12 #include "chrome/browser/history/history_service_factory.h" |
| 13 #include "chrome/browser/history/history_unittest_base.h" | 13 #include "chrome/browser/history/history_unittest_base.h" |
| 14 #include "chrome/browser/history/top_sites.h" | 14 #include "chrome/browser/history/top_sites.h" |
| 15 #include "chrome/browser/history/top_sites_factory.h" | |
| 15 #include "chrome/browser/history/top_sites_impl.h" | 16 #include "chrome/browser/history/top_sites_impl.h" |
| 16 #include "chrome/common/chrome_constants.h" | 17 #include "chrome/common/chrome_constants.h" |
| 17 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
| 18 #include "chrome/test/base/testing_profile.h" | 19 #include "chrome/test/base/testing_profile.h" |
| 19 #include "components/history/core/browser/history_db_task.h" | 20 #include "components/history/core/browser/history_db_task.h" |
| 20 #include "components/history/core/browser/history_types.h" | 21 #include "components/history/core/browser/history_types.h" |
| 21 #include "components/history/core/browser/top_sites_cache.h" | 22 #include "components/history/core/browser/top_sites_cache.h" |
| 22 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
| 23 #include "content/public/test/test_browser_thread.h" | 24 #include "content/public/test/test_browser_thread.h" |
| 24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 229 // Waits for top sites to finish processing a task. This is useful if you need | 230 // Waits for top sites to finish processing a task. This is useful if you need |
| 230 // to wait until top sites finishes processing a task. | 231 // to wait until top sites finishes processing a task. |
| 231 void WaitForTopSites() { | 232 void WaitForTopSites() { |
| 232 top_sites()->backend_->DoEmptyRequest( | 233 top_sites()->backend_->DoEmptyRequest( |
| 233 base::Bind(&TopSitesImplTest::QuitCallback, base::Unretained(this)), | 234 base::Bind(&TopSitesImplTest::QuitCallback, base::Unretained(this)), |
| 234 &top_sites_tracker_); | 235 &top_sites_tracker_); |
| 235 base::MessageLoop::current()->Run(); | 236 base::MessageLoop::current()->Run(); |
| 236 } | 237 } |
| 237 | 238 |
| 238 TopSitesImpl* top_sites() { | 239 TopSitesImpl* top_sites() { |
| 239 return static_cast<TopSitesImpl*>(profile_->GetTopSites()); | 240 return static_cast<TopSitesImpl*>( |
| 241 TopSitesFactory::GetForProfile(profile_).get()); | |
|
sdefresne
2015/01/21 17:57:23
This line won't compile, it need to be:
return st
| |
| 240 } | 242 } |
| 241 TestingProfile* profile() {return profile_.get();} | 243 TestingProfile* profile() {return profile_.get();} |
| 242 HistoryService* history_service() { | 244 HistoryService* history_service() { |
| 243 return HistoryServiceFactory::GetForProfile( | 245 return HistoryServiceFactory::GetForProfile( |
| 244 profile_.get(), ServiceAccessType::EXPLICIT_ACCESS); | 246 profile_.get(), ServiceAccessType::EXPLICIT_ACCESS); |
| 245 } | 247 } |
| 246 | 248 |
| 247 MostVisitedURLList GetPrepopulatePages() { | 249 MostVisitedURLList GetPrepopulatePages() { |
| 248 return top_sites()->GetPrepopulatePages(); | 250 return top_sites()->GetPrepopulatePages(); |
| 249 } | 251 } |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 364 MostVisitedURLList empty; | 366 MostVisitedURLList empty; |
| 365 top_sites()->thread_safe_cache_->SetTopSites(empty); | 367 top_sites()->thread_safe_cache_->SetTopSites(empty); |
| 366 } | 368 } |
| 367 | 369 |
| 368 void CreateTopSitesAndObserver() { | 370 void CreateTopSitesAndObserver() { |
| 369 if (top_sites_observer_) | 371 if (top_sites_observer_) |
| 370 top_sites_observer_.reset(); | 372 top_sites_observer_.reset(); |
| 371 | 373 |
| 372 profile_->CreateTopSites(); | 374 profile_->CreateTopSites(); |
| 373 top_sites_observer_.reset( | 375 top_sites_observer_.reset( |
| 374 new TestTopSitesObserver(profile_.get(), profile_->GetTopSites())); | 376 new TestTopSitesObserver(profile_.get(), TopSitesFactory::GetForProfile(pro file_)); |
|
sdefresne
2015/01/21 17:57:23
This line is incorrectly formatted, it should have
| |
| 375 } | 377 } |
| 376 | 378 |
| 377 private: | 379 private: |
| 378 base::MessageLoopForUI message_loop_; | 380 base::MessageLoopForUI message_loop_; |
| 379 content::TestBrowserThread ui_thread_; | 381 content::TestBrowserThread ui_thread_; |
| 380 content::TestBrowserThread db_thread_; | 382 content::TestBrowserThread db_thread_; |
| 381 scoped_ptr<TestingProfile> profile_; | 383 scoped_ptr<TestingProfile> profile_; |
| 382 scoped_ptr<TestTopSitesObserver> top_sites_observer_; | 384 scoped_ptr<TestTopSitesObserver> top_sites_observer_; |
| 383 // To cancel HistoryService tasks. | 385 // To cancel HistoryService tasks. |
| 384 base::CancelableTaskTracker history_tracker_; | 386 base::CancelableTaskTracker history_tracker_; |
| (...skipping 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1682 ASSERT_EQ(orig_thumbnail.getSize(), thumbnail.getSize()); | 1684 ASSERT_EQ(orig_thumbnail.getSize(), thumbnail.getSize()); |
| 1683 orig_thumbnail.lockPixels(); | 1685 orig_thumbnail.lockPixels(); |
| 1684 thumbnail.lockPixels(); | 1686 thumbnail.lockPixels(); |
| 1685 EXPECT_EQ(0, memcmp(orig_thumbnail.getPixels(), thumbnail.getPixels(), | 1687 EXPECT_EQ(0, memcmp(orig_thumbnail.getPixels(), thumbnail.getPixels(), |
| 1686 orig_thumbnail.getSize())); | 1688 orig_thumbnail.getSize())); |
| 1687 thumbnail.unlockPixels(); | 1689 thumbnail.unlockPixels(); |
| 1688 orig_thumbnail.unlockPixels(); | 1690 orig_thumbnail.unlockPixels(); |
| 1689 } | 1691 } |
| 1690 | 1692 |
| 1691 } // namespace history | 1693 } // namespace history |
| OLD | NEW |