OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/webdata/web_data_service.h" | 5 #include "chrome/browser/webdata/web_data_service.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 #include "chrome/browser/search_engines/template_url.h" | 10 #include "chrome/browser/search_engines/template_url.h" |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 } | 401 } |
402 } | 402 } |
403 | 403 |
404 void WebDataService::InitializeDatabase(const FilePath& path) { | 404 void WebDataService::InitializeDatabase(const FilePath& path) { |
405 DCHECK(!db_); | 405 DCHECK(!db_); |
406 // In the rare case where the db fails to initialize a dialog may get shown | 406 // In the rare case where the db fails to initialize a dialog may get shown |
407 // the blocks the caller, yet allows other messages through. For this reason | 407 // the blocks the caller, yet allows other messages through. For this reason |
408 // we only set db_ to the created database if creation is successful. That | 408 // we only set db_ to the created database if creation is successful. That |
409 // way other methods won't do anything as db_ is still NULL. | 409 // way other methods won't do anything as db_ is still NULL. |
410 WebDatabase* db = new WebDatabase(); | 410 WebDatabase* db = new WebDatabase(); |
411 if (!db->Init(path.ToWStringHack())) { | 411 if (!db->Init(path)) { |
412 NOTREACHED() << "Cannot initialize the web database"; | 412 NOTREACHED() << "Cannot initialize the web database"; |
413 delete db; | 413 delete db; |
414 return; | 414 return; |
415 } | 415 } |
416 | 416 |
417 db_ = db; | 417 db_ = db; |
418 | |
419 db_->BeginTransaction(); | 418 db_->BeginTransaction(); |
420 } | 419 } |
421 | 420 |
422 void WebDataService::ShutdownDatabase() { | 421 void WebDataService::ShutdownDatabase() { |
423 if (db_) { | 422 if (db_) { |
424 db_->CommitTransaction(); | 423 db_->CommitTransaction(); |
425 delete db_; | 424 delete db_; |
426 db_ = NULL; | 425 db_ = NULL; |
427 } | 426 } |
428 } | 427 } |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 Task* t = NewRunnableMethod(s, | 708 Task* t = NewRunnableMethod(s, |
710 &WebDataService::RequestCompleted, | 709 &WebDataService::RequestCompleted, |
711 handle_); | 710 handle_); |
712 message_loop_->PostTask(FROM_HERE, t); | 711 message_loop_->PostTask(FROM_HERE, t); |
713 } | 712 } |
714 | 713 |
715 int WebDataService::GetNextRequestHandle() { | 714 int WebDataService::GetNextRequestHandle() { |
716 AutoLock l(pending_lock_); | 715 AutoLock l(pending_lock_); |
717 return ++next_request_handle_; | 716 return ++next_request_handle_; |
718 } | 717 } |
OLD | NEW |