| 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 "components/webdata/common/web_data_service_base.h" | 5 #include "components/webdata/common/web_data_service_base.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 db_loaded_ = true; | 38 db_loaded_ = true; |
| 39 } | 39 } |
| 40 | 40 |
| 41 void WebDataServiceBase::WebDatabaseLoadFailed(sql::InitStatus status) { | 41 void WebDataServiceBase::WebDatabaseLoadFailed(sql::InitStatus status) { |
| 42 if (!profile_error_callback_.is_null()) | 42 if (!profile_error_callback_.is_null()) |
| 43 profile_error_callback_.Run(status); | 43 profile_error_callback_.Run(status); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void WebDataServiceBase::ShutdownOnUIThread() { | 46 void WebDataServiceBase::ShutdownOnUIThread() { |
| 47 db_loaded_ = false; | 47 db_loaded_ = false; |
| 48 BrowserThread::PostTask( | |
| 49 BrowserThread::DB, FROM_HERE, | |
| 50 base::Bind(&WebDataServiceBase::ShutdownOnDBThread, this)); | |
| 51 } | 48 } |
| 52 | 49 |
| 53 void WebDataServiceBase::Init() { | 50 void WebDataServiceBase::Init() { |
| 54 DCHECK(wdbs_.get()); | 51 DCHECK(wdbs_.get()); |
| 55 wdbs_->AddObserver(this); | 52 wdbs_->AddObserver(this); |
| 56 wdbs_->LoadDatabase(); | 53 wdbs_->LoadDatabase(); |
| 57 } | 54 } |
| 58 | 55 |
| 59 void WebDataServiceBase::UnloadDatabase() { | 56 void WebDataServiceBase::UnloadDatabase() { |
| 60 if (!wdbs_) | 57 if (!wdbs_) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 return; | 90 return; |
| 94 wdbs_->RemoveObserver(observer); | 91 wdbs_->RemoveObserver(observer); |
| 95 } | 92 } |
| 96 | 93 |
| 97 WebDatabase* WebDataServiceBase::GetDatabase() { | 94 WebDatabase* WebDataServiceBase::GetDatabase() { |
| 98 if (!wdbs_) | 95 if (!wdbs_) |
| 99 return NULL; | 96 return NULL; |
| 100 return wdbs_->GetDatabaseOnDB(); | 97 return wdbs_->GetDatabaseOnDB(); |
| 101 } | 98 } |
| 102 | 99 |
| 103 base::SupportsUserData* WebDataServiceBase::GetDBUserData() { | 100 WebDataServiceBase::~WebDataServiceBase() { |
| 104 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | |
| 105 if (!db_thread_user_data_) | |
| 106 db_thread_user_data_.reset(new SupportsUserDataAggregatable()); | |
| 107 return db_thread_user_data_.get(); | |
| 108 } | 101 } |
| 109 | |
| 110 WebDataServiceBase::~WebDataServiceBase() { | |
| 111 DCHECK(!db_thread_user_data_.get()) << "Forgot to call ShutdownOnUIThread?"; | |
| 112 } | |
| 113 | |
| 114 void WebDataServiceBase::ShutdownOnDBThread() { | |
| 115 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | |
| 116 db_thread_user_data_.reset(); | |
| 117 } | |
| OLD | NEW |