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 "chrome/browser/api/webdata/web_data_service_base.h" | 5 #include "chrome/browser/api/webdata/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 28 matching lines...) Expand all Loading... | |
39 } | 39 } |
40 | 40 |
41 void WebDataServiceBase::ShutdownOnUIThread() { | 41 void WebDataServiceBase::ShutdownOnUIThread() { |
42 db_loaded_ = false; | 42 db_loaded_ = false; |
43 BrowserThread::PostTask( | 43 BrowserThread::PostTask( |
44 BrowserThread::DB, FROM_HERE, | 44 BrowserThread::DB, FROM_HERE, |
45 base::Bind(&WebDataServiceBase::ShutdownOnDBThread, this)); | 45 base::Bind(&WebDataServiceBase::ShutdownOnDBThread, this)); |
46 ShutdownDatabase(); | 46 ShutdownDatabase(); |
47 } | 47 } |
48 | 48 |
49 void WebDataServiceBase::AddTable(scoped_ptr<WebDatabaseTable> table) { | |
50 if (!wdbs_.get()) | |
51 wdbs_.reset(new WebDatabaseService(path)); | |
Cait (Slow)
2013/03/21 00:01:56
I think we can just add a temporary |path_| member
| |
52 wdbs_->AddTable(table.Pass()); | |
53 } | |
54 | |
49 void WebDataServiceBase::Init(const base::FilePath& path) { | 55 void WebDataServiceBase::Init(const base::FilePath& path) { |
50 wdbs_.reset(new WebDatabaseService(path)); | 56 DCHECK(wdbs_.get()); |
51 wdbs_->LoadDatabase(Bind(&WebDataServiceBase::DatabaseInitOnDB, this)); | 57 wdbs_->LoadDatabase(Bind(&WebDataServiceBase::DatabaseInitOnDB, this)); |
52 } | 58 } |
53 | 59 |
54 void WebDataServiceBase::UnloadDatabase() { | 60 void WebDataServiceBase::UnloadDatabase() { |
55 if (!wdbs_) | 61 if (!wdbs_) |
56 return; | 62 return; |
57 wdbs_->UnloadDatabase(); | 63 wdbs_->UnloadDatabase(); |
58 } | 64 } |
59 | 65 |
60 void WebDataServiceBase::ShutdownDatabase() { | 66 void WebDataServiceBase::ShutdownDatabase() { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 BrowserThread::PostTask( | 131 BrowserThread::PostTask( |
126 BrowserThread::UI, FROM_HERE, | 132 BrowserThread::UI, FROM_HERE, |
127 base::Bind(&WebDataServiceBase::NotifyDatabaseLoadedOnUIThread, this)); | 133 base::Bind(&WebDataServiceBase::NotifyDatabaseLoadedOnUIThread, this)); |
128 } else { | 134 } else { |
129 BrowserThread::PostTask( | 135 BrowserThread::PostTask( |
130 BrowserThread::UI, FROM_HERE, | 136 BrowserThread::UI, FROM_HERE, |
131 base::Bind(&WebDataServiceBase::DBInitFailed, this, status)); | 137 base::Bind(&WebDataServiceBase::DBInitFailed, this, status)); |
132 } | 138 } |
133 } | 139 } |
134 | 140 |
OLD | NEW |