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

Side by Side Diff: chrome/browser/history/top_sites_backend.cc

Issue 15984016: Call scoped_refptr<T>::get() rather than relying on implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/history/top_sites_backend.h" 5 #include "chrome/browser/history/top_sites_backend.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 23 matching lines...) Expand all
34 base::Bind(&TopSitesBackend::ShutdownDBOnDBThread, this)); 34 base::Bind(&TopSitesBackend::ShutdownDBOnDBThread, this));
35 } 35 }
36 36
37 void TopSitesBackend::GetMostVisitedThumbnails( 37 void TopSitesBackend::GetMostVisitedThumbnails(
38 const GetMostVisitedThumbnailsCallback& callback, 38 const GetMostVisitedThumbnailsCallback& callback,
39 CancelableTaskTracker* tracker) { 39 CancelableTaskTracker* tracker) {
40 scoped_refptr<MostVisitedThumbnails> thumbnails = new MostVisitedThumbnails(); 40 scoped_refptr<MostVisitedThumbnails> thumbnails = new MostVisitedThumbnails();
41 bool* need_history_migration = new bool(false); 41 bool* need_history_migration = new bool(false);
42 42
43 tracker->PostTaskAndReply( 43 tracker->PostTaskAndReply(
44 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB), 44 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB).get(),
45 FROM_HERE, 45 FROM_HERE,
46 base::Bind(&TopSitesBackend::GetMostVisitedThumbnailsOnDBThread, 46 base::Bind(&TopSitesBackend::GetMostVisitedThumbnailsOnDBThread,
47 this, thumbnails, need_history_migration), 47 this,
48 thumbnails,
49 need_history_migration),
48 base::Bind(callback, thumbnails, base::Owned(need_history_migration))); 50 base::Bind(callback, thumbnails, base::Owned(need_history_migration)));
49 } 51 }
50 52
51 void TopSitesBackend::UpdateTopSites(const TopSitesDelta& delta) { 53 void TopSitesBackend::UpdateTopSites(const TopSitesDelta& delta) {
52 BrowserThread::PostTask( 54 BrowserThread::PostTask(
53 BrowserThread::DB, FROM_HERE, 55 BrowserThread::DB, FROM_HERE,
54 base::Bind(&TopSitesBackend::UpdateTopSitesOnDBThread, this, delta)); 56 base::Bind(&TopSitesBackend::UpdateTopSitesOnDBThread, this, delta));
55 } 57 }
56 58
57 void TopSitesBackend::SetPageThumbnail(const MostVisitedURL& url, 59 void TopSitesBackend::SetPageThumbnail(const MostVisitedURL& url,
58 int url_rank, 60 int url_rank,
59 const Images& thumbnail) { 61 const Images& thumbnail) {
60 BrowserThread::PostTask( 62 BrowserThread::PostTask(
61 BrowserThread::DB, FROM_HERE, 63 BrowserThread::DB, FROM_HERE,
62 base::Bind(&TopSitesBackend::SetPageThumbnailOnDBThread, this, url, 64 base::Bind(&TopSitesBackend::SetPageThumbnailOnDBThread, this, url,
63 url_rank, thumbnail)); 65 url_rank, thumbnail));
64 } 66 }
65 67
66 void TopSitesBackend::ResetDatabase() { 68 void TopSitesBackend::ResetDatabase() {
67 BrowserThread::PostTask( 69 BrowserThread::PostTask(
68 BrowserThread::DB, FROM_HERE, 70 BrowserThread::DB, FROM_HERE,
69 base::Bind(&TopSitesBackend::ResetDatabaseOnDBThread, this, db_path_)); 71 base::Bind(&TopSitesBackend::ResetDatabaseOnDBThread, this, db_path_));
70 } 72 }
71 73
72 void TopSitesBackend::DoEmptyRequest(const base::Closure& reply, 74 void TopSitesBackend::DoEmptyRequest(const base::Closure& reply,
73 CancelableTaskTracker* tracker) { 75 CancelableTaskTracker* tracker) {
74 tracker->PostTaskAndReply( 76 tracker->PostTaskAndReply(
75 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB), 77 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB).get(),
76 FROM_HERE, 78 FROM_HERE,
77 base::Bind(&base::DoNothing), 79 base::Bind(&base::DoNothing),
78 reply); 80 reply);
79 } 81 }
80 82
81 TopSitesBackend::~TopSitesBackend() { 83 TopSitesBackend::~TopSitesBackend() {
82 DCHECK(!db_); // Shutdown should have happened first (which results in 84 DCHECK(!db_); // Shutdown should have happened first (which results in
83 // nulling out db). 85 // nulling out db).
84 } 86 }
85 87
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 136
135 void TopSitesBackend::ResetDatabaseOnDBThread(const base::FilePath& file_path) { 137 void TopSitesBackend::ResetDatabaseOnDBThread(const base::FilePath& file_path) {
136 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 138 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
137 db_.reset(NULL); 139 db_.reset(NULL);
138 file_util::Delete(db_path_, false); 140 file_util::Delete(db_path_, false);
139 db_.reset(new TopSitesDatabase()); 141 db_.reset(new TopSitesDatabase());
140 InitDBOnDBThread(db_path_); 142 InitDBOnDBThread(db_path_);
141 } 143 }
142 144
143 } // namespace history 145 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/shortcuts_backend_unittest.cc ('k') | chrome/browser/importer/external_process_importer_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698