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

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

Issue 8892023: Eliminated the last few uses of MessageLoop::QuitTask in chrome/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: One more... Created 9 years 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/history_backend.h" 5 #include "chrome/browser/history/history_backend.h"
6 6
7 #include <list> 7 #include <list>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/callback.h"
12 #include "base/command_line.h" 13 #include "base/command_line.h"
13 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
14 #include "base/file_util.h" 15 #include "base/file_util.h"
15 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/scoped_vector.h" 17 #include "base/memory/scoped_vector.h"
17 #include "base/message_loop.h" 18 #include "base/message_loop.h"
18 #include "base/metrics/histogram.h" 19 #include "base/metrics/histogram.h"
19 #include "base/string_util.h" 20 #include "base/string_util.h"
20 #include "base/time.h" 21 #include "base/time.h"
21 #include "chrome/browser/autocomplete/history_url_provider.h" 22 #include "chrome/browser/autocomplete/history_url_provider.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 HistoryBackend::HistoryBackend(const FilePath& history_dir, 203 HistoryBackend::HistoryBackend(const FilePath& history_dir,
203 int id, 204 int id,
204 Delegate* delegate, 205 Delegate* delegate,
205 BookmarkService* bookmark_service) 206 BookmarkService* bookmark_service)
206 : delegate_(delegate), 207 : delegate_(delegate),
207 id_(id), 208 id_(id),
208 history_dir_(history_dir), 209 history_dir_(history_dir),
209 ALLOW_THIS_IN_INITIALIZER_LIST(expirer_(this, bookmark_service)), 210 ALLOW_THIS_IN_INITIALIZER_LIST(expirer_(this, bookmark_service)),
210 recent_redirects_(kMaxRedirectCount), 211 recent_redirects_(kMaxRedirectCount),
211 backend_destroy_message_loop_(NULL), 212 backend_destroy_message_loop_(NULL),
212 backend_destroy_task_(NULL),
213 segment_queried_(false), 213 segment_queried_(false),
214 bookmark_service_(bookmark_service) { 214 bookmark_service_(bookmark_service) {
215 } 215 }
216 216
217 HistoryBackend::~HistoryBackend() { 217 HistoryBackend::~HistoryBackend() {
218 DCHECK(!scheduled_commit_) << "Deleting without cleanup"; 218 DCHECK(!scheduled_commit_) << "Deleting without cleanup";
219 ReleaseDBTasks(); 219 ReleaseDBTasks();
220 220
221 // First close the databases before optionally running the "destroy" task. 221 // First close the databases before optionally running the "destroy" task.
222 if (db_.get()) { 222 if (db_.get()) {
223 // Commit the long-running transaction. 223 // Commit the long-running transaction.
224 db_->CommitTransaction(); 224 db_->CommitTransaction();
225 db_.reset(); 225 db_.reset();
226 } 226 }
227 if (thumbnail_db_.get()) { 227 if (thumbnail_db_.get()) {
228 thumbnail_db_->CommitTransaction(); 228 thumbnail_db_->CommitTransaction();
229 thumbnail_db_.reset(); 229 thumbnail_db_.reset();
230 } 230 }
231 if (archived_db_.get()) { 231 if (archived_db_.get()) {
232 archived_db_->CommitTransaction(); 232 archived_db_->CommitTransaction();
233 archived_db_.reset(); 233 archived_db_.reset();
234 } 234 }
235 if (text_database_.get()) { 235 if (text_database_.get()) {
236 text_database_->CommitTransaction(); 236 text_database_->CommitTransaction();
237 text_database_.reset(); 237 text_database_.reset();
238 } 238 }
239 239
240 if (backend_destroy_task_) { 240 if (!backend_destroy_task_.is_null()) {
241 // Notify an interested party (typically a unit test) that we're done. 241 // Notify an interested party (typically a unit test) that we're done.
242 DCHECK(backend_destroy_message_loop_); 242 DCHECK(backend_destroy_message_loop_);
243 backend_destroy_message_loop_->PostTask(FROM_HERE, backend_destroy_task_); 243 backend_destroy_message_loop_->PostTask(FROM_HERE, backend_destroy_task_);
244 } 244 }
245 } 245 }
246 246
247 void HistoryBackend::Init(const std::string& languages, bool force_fail) { 247 void HistoryBackend::Init(const std::string& languages, bool force_fail) {
248 if (!force_fail) 248 if (!force_fail)
249 InitImpl(languages); 249 InitImpl(languages);
250 delegate_->DBLoaded(id_); 250 delegate_->DBLoaded(id_);
251 } 251 }
252 252
253 void HistoryBackend::SetOnBackendDestroyTask(MessageLoop* message_loop, 253 void HistoryBackend::SetOnBackendDestroyTask(MessageLoop* message_loop,
254 Task* task) { 254 const base::Closure& task) {
255 if (backend_destroy_task_) { 255 if (!backend_destroy_task_.is_null())
256 DLOG(WARNING) << "Setting more than one destroy task, overriding"; 256 DLOG(WARNING) << "Setting more than one destroy task, overriding";
257 delete backend_destroy_task_;
258 }
259 backend_destroy_message_loop_ = message_loop; 257 backend_destroy_message_loop_ = message_loop;
260 backend_destroy_task_ = task; 258 backend_destroy_task_ = task;
261 } 259 }
262 260
263 void HistoryBackend::Closing() { 261 void HistoryBackend::Closing() {
264 // Any scheduled commit will have a reference to us, we must make it 262 // Any scheduled commit will have a reference to us, we must make it
265 // release that reference before we can be destroyed. 263 // release that reference before we can be destroyed.
266 CancelScheduledCommit(); 264 CancelScheduledCommit();
267 265
268 // Release our reference to the delegate, this reference will be keeping the 266 // Release our reference to the delegate, this reference will be keeping the
(...skipping 2047 matching lines...) Expand 10 before | Expand all | Expand 10 after
2316 break; 2314 break;
2317 } 2315 }
2318 } 2316 }
2319 } 2317 }
2320 UMA_HISTOGRAM_TIMES("History.GetFavIconFromDB", // historical name 2318 UMA_HISTOGRAM_TIMES("History.GetFavIconFromDB", // historical name
2321 TimeTicks::Now() - beginning_time); 2319 TimeTicks::Now() - beginning_time);
2322 return success; 2320 return success;
2323 } 2321 }
2324 2322
2325 } // namespace history 2323 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/history_backend.h ('k') | chrome/browser/history/history_querying_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698