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

Side by Side Diff: chrome/browser/webdata/web_data_service_base.cc

Issue 12853004: Move creation of WebDatabaseTable subclasses to WebDatabaseServiceFactory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix WIN test Created 7 years, 9 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) 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 11 matching lines...) Expand all
22 //////////////////////////////////////////////////////////////////////////////// 22 ////////////////////////////////////////////////////////////////////////////////
23 // 23 //
24 // WebDataServiceBase implementation. 24 // WebDataServiceBase implementation.
25 // 25 //
26 //////////////////////////////////////////////////////////////////////////////// 26 ////////////////////////////////////////////////////////////////////////////////
27 27
28 using base::Bind; 28 using base::Bind;
29 using base::Time; 29 using base::Time;
30 using content::BrowserThread; 30 using content::BrowserThread;
31 31
32 WebDataServiceBase::WebDataServiceBase(const ProfileErrorCallback& callback) 32 WebDataServiceBase::WebDataServiceBase(const base::FilePath& path,
33 const ProfileErrorCallback& callback)
33 : db_loaded_(false), 34 : db_loaded_(false),
35 path_(path),
34 profile_error_callback_(callback) { 36 profile_error_callback_(callback) {
35 // WebDataService requires DB thread if instantiated. 37 // WebDataService requires DB thread if instantiated.
36 // Set WebDataServiceFactory::GetInstance()->SetTestingFactory(&profile, NULL) 38 // Set WebDataServiceFactory::GetInstance()->SetTestingFactory(&profile, NULL)
37 // if you do not want to instantiate WebDataService in your test. 39 // if you do not want to instantiate WebDataService in your test.
38 DCHECK(BrowserThread::IsWellKnownThread(BrowserThread::DB)); 40 DCHECK(BrowserThread::IsWellKnownThread(BrowserThread::DB));
39 } 41 }
40 42
41 void WebDataServiceBase::ShutdownOnUIThread() { 43 void WebDataServiceBase::ShutdownOnUIThread() {
42 db_loaded_ = false; 44 db_loaded_ = false;
43 BrowserThread::PostTask( 45 BrowserThread::PostTask(
44 BrowserThread::DB, FROM_HERE, 46 BrowserThread::DB, FROM_HERE,
45 base::Bind(&WebDataServiceBase::ShutdownOnDBThread, this)); 47 base::Bind(&WebDataServiceBase::ShutdownOnDBThread, this));
46 ShutdownDatabase(); 48 ShutdownDatabase();
47 } 49 }
48 50
49 void WebDataServiceBase::Init(const base::FilePath& path) { 51 void WebDataServiceBase::AddTable(scoped_ptr<WebDatabaseTable> table) {
50 wdbs_.reset(new WebDatabaseService(path)); 52 if (!wdbs_.get())
53 wdbs_.reset(new WebDatabaseService(path_));
54 wdbs_->AddTable(table.Pass());
55 }
56
57 void WebDataServiceBase::Init() {
58 DCHECK(wdbs_.get());
51 wdbs_->LoadDatabase(Bind(&WebDataServiceBase::DatabaseInitOnDB, this)); 59 wdbs_->LoadDatabase(Bind(&WebDataServiceBase::DatabaseInitOnDB, this));
52 } 60 }
53 61
54 void WebDataServiceBase::UnloadDatabase() { 62 void WebDataServiceBase::UnloadDatabase() {
55 if (!wdbs_) 63 if (!wdbs_)
56 return; 64 return;
57 wdbs_->UnloadDatabase(); 65 wdbs_->UnloadDatabase();
58 } 66 }
59 67
60 void WebDataServiceBase::ShutdownDatabase() { 68 void WebDataServiceBase::ShutdownDatabase() {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 BrowserThread::PostTask( 134 BrowserThread::PostTask(
127 BrowserThread::UI, FROM_HERE, 135 BrowserThread::UI, FROM_HERE,
128 base::Bind(&WebDataServiceBase::NotifyDatabaseLoadedOnUIThread, this)); 136 base::Bind(&WebDataServiceBase::NotifyDatabaseLoadedOnUIThread, this));
129 } else { 137 } else {
130 BrowserThread::PostTask( 138 BrowserThread::PostTask(
131 BrowserThread::UI, FROM_HERE, 139 BrowserThread::UI, FROM_HERE,
132 base::Bind(&WebDataServiceBase::DBInitFailed, this, status)); 140 base::Bind(&WebDataServiceBase::DBInitFailed, this, status));
133 } 141 }
134 } 142 }
135 143
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698